/* =================================================================
   TX LAYOUT — desktop
   ================================================================= */
.tx-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: start;
}

.tx-form-card,
.tx-list-card,
.budget-form-card,
.budget-list-card {
  padding: 24px;
}

.tx-form-header {
  margin-bottom: 20px;
}
.tx-form-title {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* Income / Expense toggle */
.tx-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid var(--border-color);
  margin-bottom: 20px;
}
.tx-type-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background 0.18s,
    color 0.18s;
  color: var(--text-muted);
  background: transparent;
}
.tx-type-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

#tx-income:checked + .tx-type-income {
  background: rgba(0, 255, 159, 0.12);
  color: var(--neon-green);
  box-shadow: inset 0 0 0 1.5px var(--neon-green);
}
#tx-expense:checked + .tx-type-expense {
  background: rgba(255, 0, 110, 0.12);
  color: var(--neon-pink);
  box-shadow: inset 0 0 0 1.5px var(--neon-pink);
}
#tx-transfer:checked + .tx-type-transfer {
  background: rgba(0, 240, 255, 0.12);
  color: var(--neon-blue);
  box-shadow: inset 0 0 0 1.5px var(--neon-blue);
}
#tx-debt:checked + .tx-type-debt {
  background: rgba(255, 193, 7, 0.14);
  color: #ffc107;
  box-shadow: inset 0 0 0 1.5px #ffc107;
}
#planned-income:checked + .tx-type-income {
  background: rgba(0, 255, 159, 0.12);
  color: var(--neon-green);
  box-shadow: inset 0 0 0 1.5px var(--neon-green);
}
#planned-expense:checked + .tx-type-expense {
  background: rgba(255, 0, 110, 0.12);
  color: var(--neon-pink);
  box-shadow: inset 0 0 0 1.5px var(--neon-pink);
}

/* Fields */
.tx-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tx-field.is-hidden,
.tx-field-group.is-hidden,
.js-transfer-tx-field.is-hidden,
.js-standard-tx-field.is-hidden,
.js-debt-tx-field.is-hidden {
  display: none !important;
}
.tx-field-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.tx-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tx-field-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tx-amount-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.6);
  transition: border-color 0.18s;
}
.tx-amount-wrap:focus-within {
  border-color: var(--neon-green);
  box-shadow: 0 0 0 2px rgba(0, 255, 159, 0.12);
}
.tx-currency-badge {
  padding: 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border-right: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  height: 38px;
  white-space: nowrap;
}
.tx-currency-badge.income {
  color: var(--neon-green);
}
.tx-currency-badge.expense {
  color: var(--neon-pink);
}

.tx-amount-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 9px 12px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 0;
}
.tx-amount-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.tx-input,
.tx-select {
  width: 100%;
  padding: 9px 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition:
    border-color 0.18s,
    box-shadow 0.18s;
}
.tx-input:focus,
.tx-select:focus {
  border-color: var(--neon-green);
  box-shadow: 0 0 0 2px rgba(0, 255, 159, 0.12);
}

.tx-cat-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
}
.tx-cat-wrap .tx-select {
  flex: 1;
}

.tx-add-cat-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--border-color);
  background: transparent;
  color: var(--neon-green);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s;
}
.tx-add-cat-btn:hover {
  border-color: var(--neon-green);
  background: rgba(0, 255, 159, 0.1);
}

.tx-datetime-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.tx-datetime-row .tx-input {
  flex: 1;
}

.tx-icon-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s;
}
.tx-icon-btn svg {
  width: 15px;
  height: 15px;
}
.tx-icon-btn:hover {
  border-color: var(--neon-blue);
  color: var(--neon-blue);
}

.tx-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 18px;
  padding: 12px 20px;
  background: linear-gradient(135deg, rgba(0, 255, 159, 0.15), rgba(0, 240, 255, 0.08));
  border: 1.5px solid var(--neon-green);
  border-radius: 10px;
  color: var(--neon-green);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
}
.tx-submit-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.tx-submit-btn:hover {
  background: linear-gradient(135deg, rgba(0, 255, 159, 0.25), rgba(0, 240, 255, 0.15));
  box-shadow: 0 0 20px rgba(0, 255, 159, 0.25);
}

/* TX list */
.tx-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.tx-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tx-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 0.9rem;
}

.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.tx-row:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border-color-soft);
}

.tx-row-icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tx-row-icon svg {
  width: 15px;
  height: 15px;
}
.tx-row-icon--income {
  background: rgba(0, 255, 159, 0.12);
  color: var(--neon-green);
}
.tx-row-icon--expense {
  background: rgba(255, 0, 110, 0.12);
  color: var(--neon-pink);
}
.tx-row-icon--transfer {
  background: rgba(0, 240, 255, 0.12);
  color: var(--neon-blue);
}
.tx-row-icon--adjustment {
  background: rgba(159, 168, 218, 0.14);
  color: #9fa8da;
}
.tx-row-icon--debt {
  background: rgba(255, 193, 7, 0.12);
  color: #ffc107;
}

.tx-row-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tx-row-meta-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tx-row-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.tx-row-acc {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.tx-row-note {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.tx-row-right {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.tx-row-amount {
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
}
.tx-row-amount--income {
  color: var(--neon-green);
}
.tx-row-amount--expense {
  color: var(--neon-pink);
}
.tx-row-amount--transfer {
  color: var(--neon-blue);
}
.tx-row-amount--adjustment {
  color: #9fa8da;
}
.tx-row-amount--debt {
  color: #ffc107;
}

.tx-row-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.tx-row:hover .tx-row-actions {
  opacity: 1;
}

.tx-act-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.tx-act-btn svg {
  width: 12px;
  height: 12px;
}
.tx-act-btn:hover {
  border-color: var(--neon-blue);
  color: var(--neon-blue);
}
.tx-act-btn.danger:hover {
  border-color: var(--neon-pink);
  color: var(--neon-pink);
}
/* =================================================================
   MOBILE - tx list 1C-style + modal
   ================================================================= */
@media (max-width: 760px) {
  .tx-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .tx-form-card {
    display: none;
  }
  .tx-list-card {
    padding: 0 0 80px;
    background: transparent;
    border: none;
    box-shadow: none;
  }

  .tx-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
  }
  .tx-list-header .tx-form-title {
    margin: 0;
    font-size: 0.78rem;
  }

  .tx-add-inline-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--neon-green);
    background: rgba(0, 255, 159, 0.08);
    color: var(--neon-green);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: all 0.18s;
  }
  .tx-add-inline-btn svg {
    width: 14px;
    height: 14px;
  }

  .tx-list {
    flex-direction: column;
    overflow-x: visible;
    scroll-snap-type: none;
    padding: 0;
    gap: 0;
  }

  /* 1C-style row — grid: icon | meta | amount */
  .tx-row {
    width: 100%;
    display: grid;
    grid-template-columns: 32px 1fr auto;
    grid-template-rows: auto;
    column-gap: 10px;
    padding: 10px 14px 10px 12px;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border-color-soft);
    background: transparent;
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
    align-items: center;
  }
  .tx-row:first-child {
    border-top: 1px solid var(--border-color-soft);
  }

  .tx-row-icon {
    grid-column: 1;
    grid-row: 1;
    width: 28px;
    height: 28px;
    margin-top: 2px;
    flex-shrink: 0;
    align-self: center;
  }

  .tx-row-meta {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
    padding-left: 0;
  }

  .tx-row-meta-top {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
  }

  .tx-row-date {
    font-size: 0.73rem;
    color: var(--text-secondary);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    text-align: left;
  }

  .tx-row-acc {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
  }

  .tx-row-note {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-align: left;
  }

  .tx-row-right {
    grid-column: 3;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    padding-left: 8px;
    padding-top: 2px;
  }

  .tx-row-amount {
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }

  /* Swipe-reveal */
  .tx-row-actions {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: stretch;
    opacity: 1;
    transform: translateX(100%);
    transition: transform 0.22s ease;
  }
  .tx-row.is-swiped .tx-row-actions {
    transform: translateX(0);
  }
  .tx-row.is-swiped {
    transform: translateX(-88px);
  }

  .tx-act-btn {
    width: 44px;
    height: 100%;
    border-radius: 0;
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
  }
  .tx-act-btn:hover {
    background: rgba(0, 240, 255, 0.15);
  }
  .tx-act-btn.danger {
    background: rgba(255, 0, 110, 0.12);
  }
  .tx-act-btn.danger:hover {
    background: rgba(255, 0, 110, 0.3);
  }

  .tx-fab {
    display: none;
  }

  /* Modal */
  /* Backdrop as flex centering container */
  /* Backdrop - positioned by JS via visualViewport */
  .tx-mobile-backdrop {
    background: rgba(0, 0, 0, 0.75);
    z-index: 299;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .tx-mobile-backdrop.is-open {
    opacity: 1;
    pointer-events: all;
  }
  .tx-mobile-sheet {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 80vh;
    border-radius: 16px;
    border: 1.5px solid var(--border-color);
    background: #0f172a;
    padding: 20px 18px 28px;
    overflow-y: auto;
    transform: translateY(-16px);
    opacity: 0;
    transition:
      transform 0.24s cubic-bezier(0.34, 1.2, 0.64, 1),
      opacity 0.18s;
  }
  .tx-mobile-backdrop.is-open .tx-mobile-sheet {
    transform: translateY(0);
    opacity: 1;
  }
  .tx-mobile-sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border-color);
    margin: 0 auto 16px;
  }
  .tx-mobile-sheet .txm-date-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .tx-mobile-sheet .txm-date-row .tx-input {
    width: 100%;
    color-scheme: dark;
  }
}

@media (min-width: 761px) {
  .tx-add-inline-btn {
    display: none !important;
  }
  .tx-fab,
  .tx-mobile-sheet,
  .tx-mobile-backdrop {
    display: none !important;
  }
}

/* ── Tx row type accent ──────────────────────────────────────── */
.tx-row:has(.tx-row-amount--income) {
  border-left: 3px solid rgba(0, 255, 159, 0.45) !important;
}
.tx-row:has(.tx-row-amount--expense) {
  border-left: 3px solid rgba(255, 0, 110, 0.35) !important;
}
.tx-row:has(.tx-row-amount--income):hover {
  background: rgba(0, 255, 159, 0.04) !important;
}
.tx-row:has(.tx-row-amount--expense):hover {
  background: rgba(255, 0, 110, 0.04) !important;
}
@media (max-width: 760px) {
  .tx-row:has(.tx-row-amount--income) {
    border-left: 3px solid rgba(0, 255, 159, 0.55) !important;
    border-bottom: 1px solid var(--border-color-soft) !important;
    padding-left: 9px;
  }
  .tx-row:has(.tx-row-amount--expense) {
    border-left: 3px solid rgba(255, 0, 110, 0.45) !important;
    border-bottom: 1px solid var(--border-color-soft) !important;
    padding-left: 9px;
  }
}

/* ── Mobile modal type toggle highlight (mirrors desktop) ────── */
@media (max-width: 760px) {
  #txm-income:checked + .tx-type-income {
    background: rgba(0, 255, 159, 0.12);
    color: var(--neon-green);
    box-shadow: inset 0 0 0 1.5px var(--neon-green);
  }
  #txm-expense:checked + .tx-type-expense {
    background: rgba(255, 0, 110, 0.12);
    color: var(--neon-pink);
    box-shadow: inset 0 0 0 1.5px var(--neon-pink);
  }
  #txm-transfer:checked + .tx-type-transfer {
    background: rgba(0, 240, 255, 0.12);
    color: var(--neon-blue);
    box-shadow: inset 0 0 0 1.5px var(--neon-blue);
  }
  #txm-debt:checked + .tx-type-debt {
    background: rgba(255, 193, 7, 0.14);
    color: #ffc107;
    box-shadow: inset 0 0 0 1.5px #ffc107;
  }
}
/* ── Mobile modal form fixes ─────────────────────────────────── */
@media (max-width: 760px) {
  /* Wallet account select — full width, не зажатый */
  .tx-mobile-sheet .tx-field-group {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .tx-mobile-sheet .txm-date-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  /* Дата/время row — иконки видны */
  .tx-mobile-sheet .tx-datetime-row {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .tx-mobile-sheet .tx-icon-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .tx-mobile-sheet .tx-icon-btn svg {
    width: 17px;
    height: 17px;
    display: block;
  }
  .tx-mobile-sheet .tx-icon-btn:hover {
    border-color: var(--neon-blue);
    color: var(--neon-blue);
  }

  /* Amount wrap — нормальная высота */
  .tx-mobile-sheet .tx-amount-wrap {
    height: 44px;
  }
  .tx-mobile-sheet .tx-currency-badge {
    height: 44px;
    font-size: 0.8rem;
  }
  .tx-mobile-sheet .tx-amount-input {
    font-size: 1.1rem;
    height: 44px;
  }

  /* Select — нормальная высота */
  .tx-mobile-sheet .tx-select,
  .tx-mobile-sheet .tx-input {
    height: 44px;
    font-size: 0.9rem;
  }
}
/* ── Desktop form — standalone fields (full width) ────────────── */
.tx-form > .tx-fields > .tx-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tx-form > .tx-fields > .tx-field .tx-amount-wrap,
.tx-form > .tx-fields > .tx-field .tx-select,
.tx-form > .tx-fields > .tx-field .tx-input,
.tx-form > .tx-fields > .tx-field .tx-cat-wrap {
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════════
   TX ROW — tap-to-expand actions
   ═══════════════════════════════════════════════════════════════ */

/* Desktop: tx-row-main is just a flex wrapper */
.tx-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  cursor: default;
}

/* Expanded panel — hidden on desktop */
.tx-row-expanded {
  display: none;
}

/* ── Mobile ───────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .tx-row {
    flex-direction: column;
    gap: 0;
    cursor: pointer;
    /* override swipe transform */
    transform: none !important;
  }

  .tx-row-main {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px 10px 12px;
  }

  /* Override old grid on .tx-row itself */
  .tx-row {
    display: flex;
    padding: 0;
  }

  /* Expanded actions panel */
  .tx-row-expanded {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    width: 100%;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .tx-row.is-expanded .tx-row-expanded {
    max-height: 60px;
  }

  .tx-exp-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 0;
    border: none;
    border-top: 1px solid var(--border-color-soft);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition:
      background 0.15s,
      color 0.15s;
  }
  .tx-exp-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
  }
  .tx-exp-btn:first-child {
    border-right: 1px solid var(--border-color-soft);
    color: var(--neon-blue);
  }
  .tx-exp-btn:first-child:active {
    background: rgba(0, 240, 255, 0.1);
  }
  .tx-exp-btn.danger {
    color: var(--neon-pink);
  }
  .tx-exp-btn.danger:active {
    background: rgba(255, 0, 110, 0.1);
  }

  /* Row highlight when expanded */
  .tx-row.is-expanded {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 0;
  }
  .tx-row.is-expanded .tx-row-main {
    border-bottom: none;
  }

  /* Hide old swipe actions on mobile */
  .tx-row-actions {
    display: none !important;
  }
}
