/* ── Transactions ──────────────────────────────────────────── */
#view-transactions {
  position: relative;
}

.tx-toolbar {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tx-toolbar .tx-filter-row {
  border-bottom: none;
  background: transparent;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 7px;
  gap: 5px;
  align-items: center;
}

.tx-toolbar.is-search-open .tx-filter-row {
  padding-bottom: 6px;
}

.tx-filter-row .filter-btn {
  padding: 6px 11px;
  border-radius: 20px;
  background: transparent;
  border: none;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--text-2);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.tx-filter-row .filter-btn:not(.on):active {
  background: var(--surface-2);
}

.tx-filter-row .filter-btn.on {
  transform: scale(0.98);
  box-shadow: var(--shadow-inset);
  filter: brightness(0.97) saturate(0.98);
  font-weight: 600;
}

.tx-filter-row .filter-btn.on[data-tx-filter="all"] {
  background: var(--accent-muted);
  color: var(--accent);
}

.tx-filter-row .filter-btn.on[data-tx-filter="income"] {
  background: var(--income-bg);
  color: var(--income);
}

.tx-filter-row .filter-btn.on[data-tx-filter="expense"] {
  background: var(--expense-bg);
  color: var(--expense);
}

.tx-filter-row .filter-btn--period {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.tx-filter-row .filter-btn--period:active {
  background: var(--surface-2);
}

.tx-filter-row .filter-btn--period.on {
  background: var(--accent-muted);
  color: var(--accent);
  box-shadow: var(--shadow-inset);
}

.tx-filter-row .filter-btn--period.on svg {
  color: var(--accent);
}

.tx-filter-row .filter-btn--icon {
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  max-width: none;
}

.tx-filter-row .filter-btn--icon svg {
  width: 17px;
  height: 17px;
  color: var(--text-2);
}

#tx-hero-wrap {
  flex-shrink: 0;
  padding: 0 16px 8px;
}

.tx-toolbar.is-search-open #tx-hero-wrap {
  padding-bottom: 6px;
}

.tx-head {
  flex-shrink: 0;
  overflow: visible;
}

.tx-morph-shell {
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  transform: none;
}

.tx-morph.panel {
  padding: 11px 14px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-lg);
}

.tx-morph-stage {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
}

.tx-morph-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 0 auto;
  max-width: 100%;
}

.tx-morph-period {
  position: relative;
  display: grid;
  place-items: start start;
  flex-shrink: 0;
}

.tx-morph-period-full,
.tx-morph-period-short {
  grid-area: 1 / 1;
  white-space: nowrap;
  transform-origin: left center;
}

.tx-morph-period-full {
  opacity: 1;
  max-height: none;
  overflow: visible;
}

.tx-morph-period-short {
  display: none;
}

.tx-morph-tags {
  flex: 1 1 auto;
  min-width: 0;
  max-height: none;
  opacity: 1;
  overflow: hidden;
}

.tx-morph-rule {
  display: none;
}

.tx-hero-formula {
  display: flex;
  align-items: baseline;
  flex-wrap: nowrap;
  justify-content: flex-end;
  width: 100%;
  margin-top: 10px;
  gap: 6px 12px;
  min-width: 0;
}

.tx-hero-term {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
}

.tx-hero-val {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.tx-hero-term--inc .tx-hero-val,
.tx-hero-term--exp .tx-hero-val {
  font-size: 15px;
  font-weight: 600;
  opacity: 0.72;
}

.tx-hero-term--inc .tx-hero-sign {
  font-size: 14px;
  font-weight: 600;
  color: var(--income);
  opacity: 0.72;
}

.tx-hero-term--exp .tx-hero-sign {
  font-size: 14px;
  font-weight: 600;
  color: var(--expense);
  opacity: 0.72;
}

.tx-hero-val.inc {
  color: var(--income);
}

.tx-hero-val.exp {
  color: var(--expense);
}

.tx-hero-term--net .tx-hero-val {
  font-size: 20px;
  font-weight: 600;
}

.tx-hero-sep {
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-3);
  opacity: 0.45;
  flex-shrink: 0;
  user-select: none;
  margin: 0 1px;
}

.tx-search-line {
  position: relative;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0 16px;
  transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.24s ease,
    padding 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.tx-toolbar.is-search-open .tx-search-line {
  max-height: 52px;
  opacity: 1;
  padding-bottom: 10px;
}

.tx-search-input {
  display: block;
  width: 100%;
  height: 36px;
  margin: 0;
  padding: 0 36px 0 12px;
  box-sizing: border-box;
  border: none;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: box-shadow 0.2s ease, background 0.2s ease;
}

.tx-search-input::placeholder {
  color: var(--text-3);
}

.tx-search-input:focus {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--accent-ring);
}

.tx-search-input::-webkit-search-cancel-button,
.tx-search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.tx-search-clear {
  position: absolute;
  right: 16px;
  top: 18px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.tx-search-clear[hidden] {
  display: none;
}

.tx-search-clear:active {
  color: var(--text-2);
}

.tx-search-fab {
  position: absolute;
  right: 16px;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 14px);
  z-index: 90;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease, transform 0.2s ease;
}

.tx-search-fab svg {
  width: 20px;
  height: 20px;
}

.tx-search-fab:active {
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
  transform: scale(0.96);
}

.tx-search-fab.has-query::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--surface);
}

.tx-search-fab[hidden] {
  display: none;
}

.tx-filter-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 4px;
  opacity: 0.8;
}

.tx-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg);
  padding: 8px 0 12px;
}

.tx-list-sentinel {
  height: 1px;
  margin-top: 8px;
}

.tx-list-loading {
  padding: 8px 12px 0;
}

.tx-day-group {
  margin: 0 12px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  outline: 1px solid var(--border);
  box-shadow: none;
  touch-action: pan-y;
  transition:
    box-shadow 0.45s cubic-bezier(0.33, 1, 0.68, 1),
    background 0.3s ease,
    outline-color 0.3s ease,
    margin 0.35s cubic-bezier(0.33, 1, 0.68, 1),
    opacity 0.38s cubic-bezier(0.33, 1, 0.68, 1),
    filter 0.38s cubic-bezier(0.33, 1, 0.68, 1);
}

.tx-list:has(.tx-day-group.is-open) .tx-day-group:not(.is-open) {
  opacity: 0.46;
  filter: saturate(0.62) brightness(0.95);
}

@media (hover: hover) {
  .tx-list:has(.tx-day-group.is-open) .tx-day-group:not(.is-open):hover {
    opacity: 0.58;
    filter: saturate(0.74) brightness(0.98);
  }
}

.tx-list:has(.tx-day-group.is-open) .tx-day-group:not(.is-open):active {
  opacity: 0.52;
  filter: saturate(0.68) brightness(0.96);
}

.tx-day-group.is-open {
  position: relative;
  z-index: 2;
  margin: 2px 10px;
  overflow: visible;
  background: var(--surface);
  outline: none;
  border: 1px solid var(--overlay-border);
  box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--overlay-border);
}

.tx-day-group.is-open + .tx-day-group.is-open {
  margin-top: 0;
}

.tx-day-group:nth-child(even) {
  background: var(--surface-2);
  outline-color: var(--border);
}

.tx-day-group:nth-child(even).is-open {
  background: var(--surface);
  border-color: var(--overlay-border);
}

.tx-day-head {
  width: 100%;
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  gap: 0 10px;
  align-items: center;
  padding: 14px 14px;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  min-width: 0;
  touch-action: pan-y;
  transition: filter 0.15s ease, border-color 0.4s cubic-bezier(0.33, 1, 0.68, 1);
}

.tx-day-group.is-open .tx-day-head {
  border-bottom-color: var(--border);
  border-radius: 10px 10px 0 0;
  transition-delay: 0.05s;
}

.tx-day-head:active {
  filter: brightness(0.98);
}

.tx-day-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-3);
  opacity: 0.7;
  transform: rotate(0deg);
  transition:
    transform 0.52s cubic-bezier(0.33, 1, 0.68, 1),
    opacity 0.32s ease;
}

.tx-day-group.is-open .tx-day-chevron {
  transform: rotate(90deg);
  opacity: 1;
}

.tx-day-group:not(.is-open) .tx-day-chevron {
  transition:
    transform 0.36s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.24s ease;
}

.tx-day-date {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.tx-day-wd {
  font-weight: 500;
  color: var(--text-3);
}

.tx-day-sum {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: -0.01em;
  text-align: right;
  flex-shrink: 0;
}

.tx-day-sum.inc { color: var(--income); }
.tx-day-sum.exp { color: var(--expense); }

.tx-day-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.36s cubic-bezier(0.4, 0, 0.2, 1);
}

.tx-day-group:not(.is-open) .tx-day-body {
  pointer-events: none;
}

.tx-day-group.is-open .tx-day-body {
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.54s cubic-bezier(0.22, 1, 0.36, 1);
}

.tx-day-list {
  overflow: hidden;
  min-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  background: transparent;
  transition:
    opacity 0.22s cubic-bezier(0.4, 0, 1, 1),
    transform 0.34s cubic-bezier(0.4, 0, 0.2, 1);
}

.tx-day-group.is-open .tx-day-list {
  opacity: 1;
  transform: translateY(0);
  padding: 2px 0 4px;
  background: var(--surface-2);
  border-radius: 0 0 10px 10px;
  transition:
    opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1) 0.08s,
    transform 0.54s cubic-bezier(0.22, 1, 0.36, 1) 0.05s;
}

.tx-day-group .tx {
  background: transparent;
  border-bottom: none;
}

.tx-day-group.is-open .tx {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  margin: 0;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  background: transparent;
  min-height: 40px;
}

.tx-day-group:nth-child(even).is-open .tx {
  border-bottom-color: var(--border);
}

.tx-day-group.is-open .tx:last-child {
  border-bottom: none;
  padding-bottom: 10px;
  border-radius: 0 0 10px 10px;
}

.tx-day-group.is-open .tx:first-child {
  padding-top: 8px;
}

.tx-day-group.is-open .tx:active {
  background: var(--fill-pressed);
  filter: none;
}

.tx-day-group.is-open .tx .tag-strip-wrap,
.tx-day-group.is-open .tx .tx-tags {
  --tag-fade-bg: var(--surface-2);
}

.tx-day-group:nth-child(even).is-open .tx .tag-strip-wrap,
.tx-day-group:nth-child(even).is-open .tx .tx-tags {
  --tag-fade-bg: var(--surface-2);
}

.tx-day-group.is-open .tx:active .tag-strip-wrap,
.tx-day-group.is-open .tx:active .tx-tags {
  --tag-fade-bg: var(--surface-2);
}

.tx {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  min-width: 0;
  background: var(--surface);
  -webkit-tap-highlight-color: transparent;
}

.tx:last-child { border-bottom: none; }

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

.tx-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}

.tx-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text);
}

.tx-tags {
  flex: 0 1 36%;
  min-width: 0;
  margin: 0;
  padding: 0;
}

.tx-tags .tag-strip {
  flex-wrap: nowrap;
}

.tx-tags .tag {
  font-size: 10px;
  padding: 2px 6px;
  line-height: 1.3;
}

.tx .tag-strip-wrap {
  margin: 0;
  padding: 0;
  --tag-fade-bg: var(--surface);
}

.tx-sum {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.tx-sum.inc { color: var(--income); }
.tx-sum.exp { color: var(--expense); }

.tx-menu-wrap {
  flex-shrink: 0;
  margin: -4px -6px -4px 0;
}

.tx-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-family: var(--font);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  touch-action: manipulation;
  transition: background 0.15s ease, color 0.15s ease;
}

.tx-menu-btn-icon {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.tx-menu-btn:hover,
.tx-menu-btn[aria-expanded="true"] {
  background: var(--surface-2);
  color: var(--text-2);
}

.tx-menu-btn:active {
  background: var(--fill-pressed);
}

.tx.is-menu-open {
  background: var(--surface-2);
}

.tx-context-menu {
  position: fixed;
  z-index: 280;
  min-width: 148px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.tx-context-menu-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease;
}

.tx-context-menu-item:active {
  background: var(--fill-pressed);
}

.tx-context-menu-item--danger {
  color: var(--danger);
}

.tx-context-menu-item--danger:active {
  background: var(--danger-bg);
}

.tx-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 48px 24px;
  text-align: center;
  background: var(--surface);
  min-height: 240px;
}

.tx-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-3);
  margin-bottom: 4px;
}

.tx-empty p {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.tx-empty-hint {
  font-size: 13px;
  color: var(--text-3);
  max-width: 260px;
  line-height: 1.4;
}

.tx-empty-add {
  margin-top: 12px;
  width: auto;
  min-width: 180px;
}

@media (prefers-reduced-motion: reduce) {
  .tx-day-group {
    transition: none;
  }

  .tx-list:has(.tx-day-group.is-open) .tx-day-group:not(.is-open) {
    opacity: 0.5;
    filter: saturate(0.68);
  }

  .tx-day-body,
  .tx-day-list,
  .tx-day-chevron,
  .tx-day-head,
  .tx-search-line {
    transition: none;
  }

  .tx-day-group:not(.is-open) .tx-day-list {
    display: none;
  }

  .tx-day-group.is-open .tx-day-list {
    opacity: 1;
    transform: none;
  }

  .tx-toolbar:not(.is-search-open) .tx-search-line {
    display: none;
  }
}
