:root {
  color-scheme: light;
  --bg: #f5f6f7;
  --ink: #17191c;
  --muted: #767d86;
  --line: #d9dde2;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --accent: #1f2937;
  --accent-dark: #111827;
  --red: #b42318;
  --blue: #344054;
  --green: #23645a;
  --cat-fill: #fff7ed;
  --cat-line: #2f343a;
  --cat-blush: #f4c7b8;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  touch-action: pan-y;
  overscroll-behavior: none;
}

button,
textarea,
select,
input {
  font: inherit;
  min-width: 0;
}

button {
  cursor: pointer;
}

button {
  transition: transform 150ms ease, background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, color 180ms ease;
}

button:active {
  transform: scale(0.98);
}

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: calc(max(18px, env(safe-area-inset-top)) + 78px) 16px calc(max(28px, env(safe-area-inset-bottom)) + 82px);
}

.topbar {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 20;
  width: min(760px, 100%);
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  padding: max(8px, env(safe-area-inset-top)) 64px 8px;
  background: rgba(245, 246, 247, 0.96);
  backdrop-filter: blur(14px);
  text-align: center;
}

body:not([data-active-view="details"]) .topbar {
  display: none;
}

body:not([data-active-view="details"]) .app-shell {
  padding-top: max(8px, env(safe-area-inset-top));
}

.brand-lockup {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 0 auto;
  text-align: left;
}

.topbar .icon-button {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 31px;
  line-height: 1.08;
  letter-spacing: 0;
  font-weight: 650;
}

h2 {
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: 0;
  font-weight: 650;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

main {
  display: grid;
  gap: 15px;
}

.entry-panel,
.image-panel,
.manual-panel,
.record-mode-panel,
.review-panel,
.period-panel,
.overview-panel,
.chart-panel,
.ledger-panel,
.backup-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 19px;
}

.entry-panel:not(.hidden),
.image-panel:not(.hidden),
.manual-panel:not(.hidden),
.record-mode-panel:not(.hidden),
.review-panel:not(.hidden),
.period-panel:not(.hidden),
.overview-panel:not(.hidden),
.chart-panel:not(.hidden),
.ledger-panel:not(.hidden),
.backup-panel:not(.hidden),
.stats-grid:not(.hidden) {
  animation: panelIn 240ms ease both;
}

.cat-sticker {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: contain;
  flex: 0 0 auto;
}

.cat-sticker-large {
  width: 68px;
  height: 68px;
  margin-bottom: 0;
  filter: drop-shadow(0 3px 5px rgba(16, 24, 40, 0.08));
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.compact-head {
  margin-bottom: 12px;
}

.input-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  padding: 13px;
  line-height: 1.5;
  outline: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 41, 55, 0.08);
}

label span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 7px;
}

.entry-actions,
.backup-actions {
  display: flex;
  flex-direction: row;
  gap: 10px;
  margin-top: 12px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 650;
}

.primary-button {
  background: var(--accent);
  color: white;
  padding: 0 16px;
}

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

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.08);
}

.primary-button:disabled,
.secondary-button:disabled,
.icon-button:disabled {
  cursor: default;
  opacity: 0.58;
}

.secondary-button,
.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
}

.secondary-button {
  flex: 1;
  padding: 0 12px;
}

.danger-button {
  border-color: rgba(159, 52, 52, 0.28);
  color: #9f3434;
}

.ghost-button {
  padding: 0 12px;
  white-space: nowrap;
}

.icon-button {
  width: 44px;
  flex: 0 0 44px;
}

.icon-button.recording {
  border-color: rgba(180, 35, 24, 0.34);
  background: rgba(180, 35, 24, 0.1);
  color: var(--red);
  box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.08);
}

.icon-button.recording svg {
  animation: micPulse 1.05s ease-in-out infinite;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.title-with-icon,
.view-tabs button,
.stat-box span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.title-with-icon svg,
.view-tabs svg,
.stat-box svg {
  width: 17px;
  height: 17px;
}

.helper-text {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.record-list > .helper-text,
.category-bars > .helper-text,
.trend-chart > .helper-text {
  min-height: 52px;
  border: 1px dashed rgba(217, 221, 226, 0.9);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
}

.voice-config {
  margin-top: 14px;
  padding-top: 14px;
}

.voice-live-status {
  display: none;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  margin-top: 10px;
  border: 1px solid rgba(180, 35, 24, 0.24);
  border-radius: 8px;
  background: rgba(180, 35, 24, 0.07);
  color: var(--red);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 650;
}

.voice-live-status.active {
  display: flex;
}

.voice-live-status strong {
  font-size: 14px;
  white-space: nowrap;
}

.voice-live-status span:last-child {
  color: #8f2b23;
}

.recording-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.34);
  animation: recordingDot 1.05s ease-out infinite;
}

@keyframes recordingDot {
  0% {
    box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.34);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(180, 35, 24, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(180, 35, 24, 0);
  }
}

@keyframes micPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

.voice-endpoint-panel {
  display: none;
  padding-top: 10px;
}

.voice-endpoint-drawer.open .voice-endpoint-panel {
  display: block;
}

.image-upload {
  position: relative;
  display: grid;
  place-items: center;
  gap: 7px;
  min-height: 176px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 28px 18px 18px;
  text-align: center;
  overflow: hidden;
}

.image-upload::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(255, 247, 237, 0.9), transparent 36%),
    radial-gradient(circle at 88% 14%, rgba(244, 199, 184, 0.18), transparent 20%);
}

.image-upload > * {
  position: relative;
  z-index: 1;
}

.upload-cat {
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 1;
  width: 84px;
  height: 84px;
  opacity: 0.96;
  animation: catPeek 4.2s ease-in-out infinite;
}

.image-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.image-upload-icon {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent);
  margin-top: 10px;
}

.image-upload strong {
  font-size: 16px;
  font-weight: 700;
}

.image-upload small {
  color: var(--muted);
  font-size: 13px;
}

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

.image-actions .primary-button,
.image-actions .secondary-button {
  width: 100%;
  min-width: 0;
  padding: 0 10px;
  text-align: center;
}

.image-actions svg {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
}

.image-file-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.image-file-swipe {
  --image-swipe-offset: 0px;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
}

.image-file-delete {
  position: absolute;
  inset: 0 0 0 auto;
  width: 64px;
  border: 0;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.image-file-chip {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  padding: 0 10px;
  transform: translateX(var(--image-swipe-offset));
  transition: transform 180ms ease;
}

.image-file-swipe.open .image-file-chip {
  transform: translateX(-64px);
}

.image-file-swipe.dragging .image-file-chip {
  transition: none;
}

.image-file-chip span {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #eef1f4;
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  margin: 0;
}

.image-file-chip strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-file-chip small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.ai-key-drawer {
  margin-top: 12px;
  min-height: 22px;
  overflow: hidden;
}

.ai-key-panel {
  display: none;
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 12px;
}

.voice-endpoint-drawer {
  min-height: 22px;
  overflow: hidden;
}

.ai-key-drawer.open .ai-key-panel {
  display: block;
}

.ai-key-row {
  grid-template-columns: minmax(0, 1fr) 72px 72px;
}

.ai-usage-stats {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.ai-usage-stats span:first-child {
  color: var(--ink);
  font-weight: 700;
}

.inline-input {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  padding: 0 12px;
  font-size: 16px;
  outline: none;
}

select {
  width: 100%;
  height: 48px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--panel-strong);
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) 21px, calc(100% - 12px) 21px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  color: var(--ink);
  padding: 0 34px 0 12px;
  font-size: 16px;
  font-weight: 500;
  line-height: 48px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

#categoryFilter {
  width: 100%;
  flex: 1 1 auto;
  height: 42px;
  min-height: 42px;
  padding-left: 12px;
  padding-right: 30px;
  background-position: calc(100% - 18px) 18px, calc(100% - 12px) 18px;
  font-size: 15px;
  line-height: 42px;
}

.ledger-filter-head {
  justify-content: stretch;
  margin-bottom: 10px;
}

input[type="date"],
input[type="month"],
input[type="number"] {
  display: block;
  max-width: 100%;
  line-height: 48px;
}

input[type="date"],
input[type="month"] {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 10px;
}

input[type="date"]::-webkit-date-and-time-value,
input[type="month"]::-webkit-date-and-time-value {
  text-align: left;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
  margin-right: 0;
}

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

.manual-form > label,
.manual-form > .form-field {
  min-width: 0;
}

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

.record-editor .edit-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 10px;
  row-gap: 11px;
}

.manual-form select,
.edit-form select {
  width: 100%;
  max-width: none;
  height: 48px;
  min-height: 48px;
}

#recordModeSelect,
#manualPayment,
#manualType {
  height: 48px;
  min-height: 48px;
  font-size: 16px;
  line-height: 48px;
}

.record-mode-panel label {
  display: block;
  width: calc((100% - 12px) / 2);
}

.form-field > span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 7px;
}

.date-field input {
  min-width: 0;
}

.category-field {
  display: grid;
  gap: 10px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}

.choice-button {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 8px;
  font-weight: 650;
  text-align: center;
  white-space: nowrap;
}

.choice-swipe {
  --choice-swipe-offset: 0px;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  touch-action: pan-y;
  min-width: 0;
}

.choice-swipe .choice-button {
  position: relative;
  z-index: 1;
  transform: translateX(var(--choice-swipe-offset));
  transition: transform 180ms ease;
}

.choice-swipe.open .choice-button {
  transform: translateX(-56px);
}

.choice-swipe.dragging .choice-button {
  transition: none;
}

.choice-delete-button {
  position: absolute;
  inset: 0 0 0 auto;
  z-index: 0;
  width: 50px;
  height: 100%;
  border: 0;
  border-radius: 0 8px 8px 0;
  background: var(--red);
  color: #ffffff;
  display: grid;
  place-items: center;
  padding: 0;
}

.choice-delete-button svg {
  width: 18px;
  height: 18px;
}

.choice-button span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  margin: 0;
  color: inherit;
  font-size: 16px;
  line-height: 1;
}

.choice-button.active {
  border-color: var(--accent);
  background: #eef1f4;
  color: var(--accent-dark);
  animation: choicePop 190ms ease both;
}

.add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 8px;
  margin-top: 8px;
}

.add-drawer {
  margin-top: 8px;
}

.drawer-handle {
  width: 100%;
  height: 24px;
  min-height: 24px;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  padding: 0;
  touch-action: pan-y;
}

.drawer-handle::before {
  content: "";
  width: 44px;
  height: 2px;
  border-radius: 999px;
  background: var(--line);
}

.add-drawer .add-row {
  display: none;
  margin-top: 6px;
}

.add-drawer.open .add-row {
  display: grid;
}

.add-row .secondary-button {
  flex: 0 0 auto;
  width: 100%;
  padding: 0;
}

.wide-field,
.checkbox-field,
.manual-submit,
.edit-actions {
  grid-column: 1 / -1;
}

.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  padding: 0;
}

.checkbox-field span {
  margin: 0;
  color: var(--ink);
}

.hidden {
  display: none !important;
}

.full-width {
  width: 100%;
}

.view-tabs {
  position: fixed;
  left: 50%;
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 18;
  width: min(736px, calc(100% - 24px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.12);
  backdrop-filter: blur(14px);
}

.period-panel {
  position: sticky;
  top: calc(max(0px, env(safe-area-inset-top)) + 90px);
  z-index: 7;
  overflow: visible;
  padding: 12px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

body:not([data-active-view="details"]) .period-panel {
  top: max(8px, env(safe-area-inset-top));
}

.view-tabs button {
  min-width: 0;
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  justify-content: center;
  gap: 6px;
  padding: 0 6px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.view-tabs button.active {
  border-color: var(--line);
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: var(--shadow);
  animation: tabPop 220ms ease both;
}

.view-tabs .add-tab {
  width: 58px;
  min-height: 58px;
  justify-self: center;
  border-radius: 18px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.22);
}

.view-tabs .add-tab svg {
  width: 28px;
  height: 28px;
}

.view-tabs .add-tab.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

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

.stat-box {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  padding: 13px;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.stat-box:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(16, 24, 40, 0.06);
}

.stat-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.stat-box strong {
  display: block;
  margin-top: 9px;
  font-size: 20px;
  line-height: 1.1;
  overflow-wrap: anywhere;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 3px;
}

.segmented-control button {
  min-width: 44px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
}

.segmented-control button.active {
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.period-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.period-controls .segmented-control {
  width: 100%;
  height: 42px;
  align-items: center;
}

.flow-filter {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.flow-filter button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--muted);
  font-weight: 650;
}

.flow-filter button.active {
  border-color: var(--accent);
  background: #eef1f4;
  color: var(--ink);
}

.flow-filter button[data-flow="expense"].active {
  border-color: rgba(159, 52, 52, 0.32);
  background: rgba(159, 52, 52, 0.07);
  color: #9f3434;
}

.flow-filter button[data-flow="income"].active {
  border-color: rgba(35, 100, 90, 0.28);
  background: rgba(35, 100, 90, 0.07);
  color: var(--green);
}

.period-picker {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px 44px;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 0;
}

.period-picker label {
  min-width: 0;
}

.period-date-field {
  display: block;
}

.period-date-control {
  position: relative;
  display: block;
  margin: 0;
  min-height: 44px;
}

.period-date-control input {
  position: absolute;
  inset: 0;
  z-index: 2;
  height: 44px;
  min-height: 44px;
  padding: 0;
  opacity: 0.01;
  color: transparent;
  background: transparent;
  cursor: pointer;
}

.period-date-display {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  padding: 0 10px;
  text-align: center;
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.period-date-control.year-mode {
  display: block;
}

.period-date-control.year-mode input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  padding: 0 10px;
  line-height: 40px;
}

.year-suffix {
  position: absolute;
  top: 50%;
  right: 12px;
  margin: 0;
  transform: translateY(-50%);
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  pointer-events: none;
}

.period-date-control.year-mode .year-suffix {
  position: absolute;
  left: calc(10px + 3.9ch);
  right: auto;
  transform: translateY(-50%);
}

.period-picker input,
.period-picker select {
  width: 100%;
  height: 44px;
  min-height: 44px;
  font-size: 14px;
}

.period-picker .secondary-button {
  min-width: 0;
}

.period-picker .icon-button,
.period-picker .secondary-button {
  height: 44px;
  min-height: 44px;
  padding: 0;
}

.refresh-period-button svg {
  width: 18px;
  height: 18px;
}

.period-summary {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.period-summary > div {
  min-height: 92px;
  background: var(--panel-strong);
  padding: 14px;
}

.period-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.period-summary strong {
  display: block;
  margin-top: 12px;
  font-size: 24px;
  line-height: 1.05;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.overview-home {
  display: grid;
  gap: 10px;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.overview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  padding: 16px;
}

.overview-home[data-subpage="bill"] > .bill-card,
.overview-home[data-subpage="bill"] > .budget-card,
.overview-home[data-subpage="bill"] > .asset-card,
.overview-home[data-subpage="budget"] > .bill-card,
.overview-home[data-subpage="budget"] > .budget-card,
.overview-home[data-subpage="budget"] > .asset-card,
.overview-home[data-subpage="asset"] > .bill-card,
.overview-home[data-subpage="asset"] > .budget-card,
.overview-home[data-subpage="asset"] > .asset-card {
  display: none;
}

.overview-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  margin-bottom: 12px;
}

.overview-card h2 {
  font-size: 18px;
  line-height: 1.15;
}

.chevron-button {
  width: 30px;
  height: 30px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  transition: transform 180ms ease, background 180ms ease;
}

.chevron-button.open {
  transform: rotate(90deg);
  background: #f4f5f5;
}

.subpage-head {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  align-items: center;
  min-height: 34px;
  margin-bottom: 10px;
}

.subpage-head h2 {
  text-align: center;
}

.back-button {
  width: 32px;
  height: 32px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.bill-grid,
.asset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}

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

.bill-grid > div,
.asset-grid > div {
  min-width: 0;
  border: 1px solid rgba(32, 35, 35, 0.06);
  border-radius: 8px;
  background: rgba(247, 248, 247, 0.74);
  padding: 10px 9px;
}

.asset-grid > div {
  display: grid;
  grid-template-rows: 16px minmax(0, 1fr);
  align-items: center;
  height: 64px;
  min-height: 64px;
}

.asset-grid > div:first-child {
  grid-column: 1 / -1;
  grid-template-rows: 18px auto;
  height: auto;
  min-height: 74px;
  padding: 12px;
}

.asset-grid > div:first-child strong {
  font-size: 22px;
}

.bill-grid span,
.asset-grid span,
.budget-lines span {
  display: block;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bill-grid strong,
.asset-grid strong,
.budget-lines strong {
  display: block;
  margin-top: 0;
  font-size: 16px;
  line-height: 1.1;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bill-month {
  display: block;
}

.bill-month strong,
.bill-month em {
  font-style: normal;
}

.bill-month strong {
  font-size: 18px;
  font-weight: 650;
}

.bill-month span {
  color: var(--muted);
  font-size: 13px;
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.budget-body {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.budget-ring {
  --budget-percent: 0%;
  width: 112px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, var(--panel-strong) 0 54%, transparent 55%),
    conic-gradient(var(--accent) var(--budget-percent), #edf0f2 0);
}

.budget-ring > div {
  display: grid;
  gap: 3px;
  justify-items: center;
  align-content: center;
  text-align: center;
  line-height: 1.1;
}

.budget-ring span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.budget-ring strong {
  display: block;
  margin-top: 3px;
  font-size: 17px;
  text-align: center;
}

.bill-page-card,
.budget-page-card,
.asset-page-card {
  display: grid;
  gap: 12px;
}

.bill-detail-head {
  display: grid;
  gap: 10px;
}

.compact-segment {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  width: 100%;
  height: 40px;
  min-height: 40px;
  overflow: hidden;
}

.compact-segment button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 32px;
  min-height: 32px;
  font-size: 13px;
  line-height: 1;
  padding: 0 8px;
}

.bill-summary-mini {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border: 1px solid rgba(32, 35, 35, 0.08);
  border-radius: 8px;
  background: rgba(247, 248, 247, 0.78);
  overflow: hidden;
}

.bill-summary-mini span {
  min-width: 0;
  border-right: 1px solid rgba(32, 35, 35, 0.06);
  padding: 10px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-align: center;
}

.bill-summary-mini span:last-child {
  border-right: 0;
}

.bill-summary-mini em {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bill-summary-mini strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.bill-detail-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  border: 1px solid rgba(32, 35, 35, 0.06);
  border-radius: 8px;
  background: rgba(247, 248, 247, 0.74);
  padding: 10px;
}

.bill-detail-row strong,
.bill-detail-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bill-detail-row strong {
  font-size: 14px;
}

.bill-detail-row span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.bill-detail-row span::before {
  color: var(--muted);
}

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

.budget-add-toggle {
  width: 100%;
  min-height: 40px;
}

.budget-plan-form label {
  min-width: 0;
}

.budget-picker-trigger {
  width: 100%;
  height: 48px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--panel-strong);
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) 21px, calc(100% - 12px) 21px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  color: var(--ink);
  padding: 0 34px 0 12px;
  font-size: 16px;
  font-weight: 500;
  line-height: 48px;
  text-align: left;
}

.budget-scroll-picker {
  position: relative;
  margin-top: 8px;
  height: 112px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-padding-block: 39px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, transparent 0 38px, var(--panel-strong) 38px 73px, transparent 73px),
    linear-gradient(180deg, rgba(248, 250, 252, 0.92), rgba(255, 255, 255, 0.2) 30%, rgba(255, 255, 255, 0.2) 70%, rgba(248, 250, 252, 0.92)),
    linear-gradient(#f8fafc, #fff);
  padding: 39px 6px;
  -webkit-overflow-scrolling: touch;
}

.budget-scroll-picker button {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  scroll-snap-align: center;
}

.budget-scroll-picker button.active {
  background: transparent;
  color: var(--ink);
}

.budget-plan-form button {
  grid-column: 1 / -1;
  min-height: 40px;
}

.budget-plan-table {
  display: grid;
  gap: 8px;
}

.budget-plan-swipe {
  --budget-swipe-offset: 0px;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  touch-action: pan-y;
}

.budget-swipe-actions,
.asset-swipe-actions {
  position: absolute;
  inset: 0 0 0 auto;
  z-index: 0;
  display: grid;
  grid-template-columns: repeat(2, 56px);
  width: 112px;
  height: 100%;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, visibility 120ms ease;
}

.budget-plan-swipe.open .budget-swipe-actions,
.budget-plan-swipe.dragging .budget-swipe-actions,
.asset-item-swipe.open .asset-swipe-actions,
.asset-item-swipe.dragging .asset-swipe-actions {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.budget-swipe-actions button,
.asset-swipe-actions button {
  border: 0;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.budget-swipe-actions button:first-child,
.asset-swipe-actions button:first-child {
  background: var(--accent);
}

.budget-swipe-actions button:last-child,
.asset-swipe-actions button:last-child {
  background: var(--red);
}

.asset-hero-card {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(32, 35, 35, 0.08);
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fafc, #fff);
  padding: 16px;
}

.asset-hero-card > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.asset-hero-card > strong {
  display: block;
  width: 100%;
  padding: 4px 0 8px;
  font-size: 30px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.asset-hero-card > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.asset-hero-card small {
  display: grid;
  align-content: center;
  min-width: 0;
  min-height: 64px;
  border: 1px solid rgba(32, 35, 35, 0.1);
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.asset-hero-card b {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-item-form {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.asset-add-toggle {
  width: 100%;
  min-height: 40px;
}

.asset-item-form label {
  min-width: 0;
}

.asset-item-form button {
  grid-column: 1 / -1;
  min-height: 40px;
}

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

.asset-item-swipe {
  --asset-swipe-offset: 0px;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  touch-action: pan-y;
}

.asset-item-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 10px;
  align-items: center;
  border: 1px solid rgba(32, 35, 35, 0.06);
  border-radius: 8px;
  background: #f7f8f7;
  padding: 10px;
  transform: translate3d(var(--asset-swipe-offset), 0, 0);
  transition: transform 180ms ease;
  will-change: transform;
  backface-visibility: hidden;
}

.asset-item-swipe.open .asset-item-row {
  transform: translate3d(-112px, 0, 0);
}

.asset-item-swipe.dragging .asset-item-row {
  transition: none;
}

.asset-item-row strong,
.asset-item-row span,
.asset-item-row b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-item-row strong {
  display: block;
  font-size: 14px;
}

.asset-item-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.asset-item-row b {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.budget-plan-table-head,
.budget-plan-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto);
  align-items: center;
  gap: 8px;
}

.budget-plan-table-head {
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.budget-plan-row {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(32, 35, 35, 0.06);
  border-radius: 8px;
  background: #f7f8f7;
  padding: 0 10px;
  text-align: left;
  transform: translate3d(var(--budget-swipe-offset), 0, 0);
  transition: transform 180ms ease;
  will-change: transform;
  backface-visibility: hidden;
}

.budget-plan-swipe.open .budget-plan-row {
  transform: translate3d(-112px, 0, 0);
}

.budget-plan-swipe.dragging .budget-plan-row {
  transition: none;
}

.budget-plan-row span,
.budget-plan-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.budget-plan-row strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.budget-lines {
  display: grid;
  gap: 8px;
}

.budget-lines div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  border: 1px solid rgba(32, 35, 35, 0.06);
  border-radius: 8px;
  background: rgba(247, 248, 247, 0.74);
  padding: 0 10px;
}

.budget-lines strong {
  margin-top: 0;
}

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

.chart-period {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.donut-wrap,
.trend-wrap {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 164px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.donut-chart {
  width: 164px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(#1f2937 0deg 360deg);
  position: relative;
  animation: chartIn 420ms ease both;
}

.donut-chart::after {
  content: "";
  position: absolute;
  inset: 31px;
  border-radius: 50%;
  background: #fbfcfd;
}

.donut-chart > div {
  position: relative;
  z-index: 1;
  width: 88px;
  display: grid;
  gap: 7px;
  padding: 0 5px;
  text-align: center;
  white-space: normal;
}

.donut-chart span,
.chart-subhead span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.chart-subhead strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
  line-height: 1.15;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.donut-chart strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.1;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart-legend {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.legend-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.legend-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-subhead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.trend-chart {
  display: grid;
  grid-template-columns: repeat(var(--bar-count, 6), minmax(38px, 1fr));
  align-items: end;
  gap: 8px;
  min-height: 180px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.trend-item {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  min-width: 0;
  height: 180px;
}

.trend-bar-shell {
  display: flex;
  align-items: end;
  min-height: 140px;
  border-radius: 7px;
  background: #eef1f4;
  overflow: hidden;
}

.trend-bar {
  width: 100%;
  min-height: 3px;
  border-radius: 7px 7px 0 0;
  background: var(--accent);
  transform-origin: bottom;
  animation: barGrow 520ms ease both;
}

.trend-label {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draft-list,
.record-list,
.category-bars {
  display: grid;
  gap: 12px;
}

.record-group {
  display: grid;
  gap: 8px;
}

.record-group h3 {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.category-bars {
  margin-bottom: 16px;
}

#saveDraftsButton {
  margin-top: 12px;
}

.draft-row,
.record-row {
  display: grid;
  grid-template-columns: minmax(38px, auto) minmax(0, 1fr) max-content;
  align-items: center;
  column-gap: 9px;
  row-gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  padding: 8px 10px;
}

.draft-row,
.record-swipe {
  animation: listItemIn 220ms ease both;
}

.record-swipe {
  --swipe-offset: 0px;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  touch-action: pan-y;
}

.record-swipe .record-row {
  position: relative;
  z-index: 3;
  transform: translateX(var(--swipe-offset));
  transition: transform 180ms ease;
  cursor: pointer;
}

.record-swipe.open .record-row {
  transform: translateX(-108px);
}

.record-swipe.open .swipe-actions {
  z-index: 4;
}

.record-swipe.dragging .record-row {
  transition: none;
}

.draft-row {
  grid-template-columns: 1fr;
}

.draft-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.draft-summary {
  min-width: 0;
}

.draft-summary strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draft-primary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) max-content;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}

.draft-primary .amount {
  font-size: 18px;
  font-weight: 800;
}

.draft-actions {
  display: flex;
  gap: 10px;
}

.draft-toggle,
.draft-remove {
  min-height: 34px;
  padding: 0 10px;
}

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

.draft-edit-form label {
  min-width: 0;
}

.draft-edit-form .wide-field {
  grid-column: 1 / -1;
}

.draft-edit-form input,
.draft-edit-form select {
  height: 44px;
  min-height: 44px;
  font-size: 15px;
}

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

.record-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  font-weight: 680;
}

.record-name {
  min-width: 0;
  margin-top: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-meta,
.draft-meta {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.record-meta {
  display: none;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.record-swipe.detail-open .record-meta {
  display: flex;
}

.record-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.amount {
  font-weight: 680;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.income-amount {
  color: var(--green);
}

.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--blue);
  padding: 4px 9px;
  font-size: 13px;
  font-weight: 650;
}

.record-category-tag {
  max-width: 4.75em;
  min-width: 38px;
  padding: 3px 6px;
  font-size: 11px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag.flow-tag {
  border-width: 1.5px;
}

.tag.expense {
  border-color: rgba(159, 52, 52, 0.28);
  background: rgba(159, 52, 52, 0.06);
  color: #9f3434;
}

.tag.reimburse {
  border-color: #bcc5d1;
  background: #f2f4f7;
  color: var(--accent-dark);
}

.tag.income {
  border-color: rgba(35, 100, 90, 0.24);
  background: rgba(35, 100, 90, 0.06);
  color: var(--green);
}

.swipe-actions {
  position: absolute;
  inset: 0 0 0 auto;
  z-index: 2;
  width: 104px;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

.delete-button,
.edit-swipe-button {
  border: 0;
  color: #ffffff;
  display: grid;
  place-items: center;
  padding: 0;
}

.edit-swipe-button {
  background: var(--accent);
}

.delete-button {
  border-radius: 0 8px 8px 0;
  background: #b42318;
}

.delete-button:hover {
  background: #991b1b;
}

.edit-swipe-button:hover {
  background: var(--accent-dark);
}

.delete-button svg,
.edit-swipe-button svg {
  width: 20px;
  height: 20px;
  display: block;
}

.record-editor {
  display: none;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: #fbfcfd;
  padding: 12px;
  margin-top: -8px;
}

.record-editor label {
  min-width: 0;
}

.record-editor label span {
  margin-bottom: 6px;
  font-size: 11px;
}

.record-editor input,
.record-editor select {
  height: 38px;
  min-height: 38px;
  padding-left: 11px;
  font-size: 14px;
  line-height: 38px;
}

.record-editor select {
  padding-right: 28px;
  background-position: calc(100% - 16px) 16px, calc(100% - 10px) 16px;
}

.ledger-panel .section-head > div {
  min-width: 0;
}

.ledger-panel .title-with-icon {
  white-space: nowrap;
}

.record-editor .wide-field {
  grid-column: span 2;
}

.record-editor .edit-name-field input {
  font-weight: 650;
}

.record-editor .checkbox-field,
.record-editor .edit-actions {
  grid-column: 1 / -1;
}

.record-editor .checkbox-field {
  min-height: 34px;
  margin-top: 0;
  padding: 0 8px;
}

.record-editor .checkbox-field input {
  width: 16px;
  height: 16px;
  min-height: 16px;
}

.record-swipe.editing .record-editor {
  display: block;
  position: relative;
  z-index: 2;
}

.record-swipe.editing .record-row {
  border-radius: 8px 8px 0 0;
  transform: translateX(0);
}

.record-swipe.editing .swipe-actions {
  display: none;
}

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

.record-editor .edit-actions button {
  min-height: 38px;
  padding: 0 12px;
  font-size: 14px;
}

.category-line {
  display: grid;
  gap: 7px;
}

.category-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.bar-track {
  height: 9px;
  border-radius: 999px;
  background: #eef1f4;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left;
  animation: fillGrow 440ms ease both;
}

.save-state {
  color: var(--green);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

dialog {
  width: min(360px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  padding: 18px;
}

dialog::backdrop {
  background: rgba(34, 31, 27, 0.24);
}

dialog p {
  margin: 10px 0 16px;
  color: var(--muted);
  line-height: 1.5;
}

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

  h1 {
    font-size: 30px;
  }

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

  .overview-card {
    padding: 14px;
  }

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

  .bill-grid strong,
  .asset-grid strong,
  .budget-lines strong {
    font-size: 15px;
  }

  .bill-month strong {
    font-size: 15px;
  }

  .budget-body {
    grid-template-columns: 94px minmax(0, 1fr);
    gap: 10px;
  }

  .budget-ring {
    width: 92px;
  }

  .budget-ring strong {
    font-size: 15px;
  }

  .budget-plan-form,
  .asset-item-form,
  .bill-detail-row {
    grid-template-columns: 1fr;
  }

  .asset-hero-card > strong {
    font-size: 26px;
  }

  .asset-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: auto;
    gap: 8px;
  }

  .asset-grid > div {
    height: 60px;
    min-height: 60px;
    padding-left: 7px;
    padding-right: 7px;
  }

  .asset-grid > div:first-child {
    grid-column: 1 / -1;
    height: auto;
    min-height: 72px;
    padding: 11px 10px;
  }

  .asset-grid strong {
    font-size: 13px;
  }

  .asset-grid > div:first-child strong {
    font-size: 20px;
  }

  .view-tabs {
    gap: 4px;
    padding: 7px;
  }

  .view-tabs button {
    min-height: 46px;
    gap: 2px;
    padding: 0 3px;
    font-size: 11px;
  }

  .view-tabs svg {
    width: 14px;
    height: 14px;
  }

  .view-tabs .add-tab {
    width: 56px;
    min-height: 56px;
    border-radius: 17px;
  }

  .period-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .period-picker {
    grid-template-columns: 42px minmax(0, 1fr) 42px 42px;
    gap: 10px;
  }

  .period-picker .secondary-button {
    width: 100%;
  }

  .record-row {
    grid-template-columns: minmax(36px, auto) minmax(0, 1fr) minmax(66px, max-content);
    column-gap: 7px;
    padding: 8px;
  }

  .record-category-tag {
    max-width: 4.2em;
    min-width: 36px;
    padding-inline: 5px;
    font-size: 10px;
  }

  .record-name {
    font-size: 13px;
  }

  .amount {
    font-size: 14px;
  }

  .chart-grid,
  .donut-wrap {
    grid-template-columns: 1fr;
  }

  .donut-chart {
    width: 172px;
    margin: 0 auto;
  }

  .trend-chart {
    gap: 6px;
    grid-template-columns: repeat(var(--bar-count, 6), minmax(32px, 1fr));
  }

  .section-head {
    align-items: flex-start;
  }

  .draft-head {
    grid-template-columns: 1fr;
  }

  .draft-actions {
    width: 100%;
  }

  .draft-actions button {
    flex: 1;
  }

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

  .entry-actions,
  .inline-input {
    flex-wrap: wrap;
  }

  .backup-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .inline-input {
    display: flex;
  }

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

  .primary-button {
    flex: 1;
  }

  .manual-form,
  .edit-form {
    grid-template-columns: 1fr;
  }

  .record-mode-panel label {
    width: 100%;
  }

  .record-editor .wide-field {
    grid-column: 1 / -1;
  }
}

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

@keyframes tabPop {
  0% {
    transform: scale(0.98);
  }
  70% {
    transform: scale(1.025);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes choicePop {
  0% {
    transform: scale(0.98);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes listItemIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fillGrow {
  from {
    transform: scaleX(0.18);
  }
  to {
    transform: scaleX(1);
  }
}

@keyframes barGrow {
  from {
    transform: scaleY(0.12);
  }
  to {
    transform: scaleY(1);
  }
}

@keyframes chartIn {
  from {
    opacity: 0;
    transform: rotate(-8deg) scale(0.96);
  }
  to {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
}

@keyframes catPeek {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-2px) rotate(-2deg);
  }
}

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