.variable-expense-form-field.payment-method-field {
  grid-column: auto;
}

.payment-method-select {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: rgba(5, 16, 29, 0.92);
}

.payment-select-shell {
  position: relative;
  width: 100%;
  min-width: 0;
}

.payment-method-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.payment-select-button {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 0 38px 0 13px;
  border: 1px solid rgba(113, 201, 255, 0.24);
  border-radius: 13px;
  outline: 0;
  color: var(--text);
  background: rgba(5, 16, 29, 0.92);
  cursor: pointer;
  font: inherit;
  text-align: right;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.payment-select-button::after {
  content: "⌄";
  position: absolute;
  top: 50%;
  right: 13px;
  color: #9de3ff;
  font-size: 1rem;
  transform: translateY(-56%);
}

.payment-select-button:focus-visible,
.payment-select-shell.is-open .payment-select-button {
  border-color: rgba(113, 201, 255, 0.78);
  box-shadow: 0 0 0 3px rgba(113, 201, 255, 0.13);
}

.payment-select-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 7px);
  right: 0;
  left: 0;
  display: none;
  gap: 4px;
  max-height: 250px;
  padding: 7px;
  overflow-y: auto;
  border: 1px solid rgba(113, 201, 255, 0.25);
  border-radius: 14px;
  background: #0b1b2d;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.5);
}

.payment-select-shell.is-open .payment-select-menu {
  display: grid;
}

.mobile-row-payment-cell:has(.payment-select-shell.is-open) {
  position: relative;
  z-index: 50;
  overflow: visible;
}

.payment-select-menu button {
  min-height: 39px;
  padding: 7px 11px;
  border: 0;
  border-radius: 9px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: right;
}

.payment-select-menu button:hover,
.payment-select-menu button:focus-visible,
.payment-select-menu button.is-selected {
  outline: 0;
  color: #eafaff;
  background: rgba(113, 201, 255, 0.16);
}

.mobile-payment-method-field {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(113, 201, 255, 0.18);
  border-radius: 14px;
  background: rgba(113, 201, 255, 0.055);
}

.mobile-payment-method-field > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.mobile-payment-method-field .payment-method-select {
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(113, 201, 255, 0.24);
  border-radius: 11px;
  font: inherit;
}

.payment-choice-overlay {
  position: fixed;
  z-index: 10020;
  inset: 0;
  display: grid;
  padding: 18px;
  place-items: center;
  background: rgba(2, 8, 15, 0.78);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.payment-choice-dialog {
  display: grid;
  width: min(100%, 440px);
  gap: 16px;
  padding: 24px;
  border: 1px solid rgba(113, 201, 255, 0.25);
  border-radius: 22px;
  color: var(--text);
  background: linear-gradient(180deg, #14283f, #0d1b2c);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.58);
}

.payment-choice-dialog h3,
.payment-choice-dialog p {
  margin: 0;
}

.payment-choice-dialog p {
  color: var(--muted);
  line-height: 1.6;
}

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

.payment-choice-dialog button {
  min-height: 46px;
  padding: 9px 14px;
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
  font-weight: 850;
}

.payment-choice-primary {
  border: 1px solid rgba(71, 230, 166, 0.7);
  color: #07131d;
  background: #47e6a6;
}

.payment-choice-secondary {
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.payment-warning-preference {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 750;
}

.payment-warning-preference input {
  width: 19px;
  height: 19px;
  accent-color: #47e6a6;
}

.checking-history-section {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.checking-history-section[hidden] {
  display: none !important;
}

.checking-history-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.checking-history-toggle,
.checking-history-clear {
  border: 0;
  color: #9de3ff;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
}

.checking-history-clear {
  color: #ff9ba6;
}

.checking-history-clear:disabled {
  cursor: default;
  opacity: 0.38;
}

.checking-history-list {
  display: grid;
  gap: 7px;
}

.checking-history-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.checking-history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 30px;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
}

.checking-history-row > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.checking-history-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.83rem;
}

.checking-history-row span {
  color: var(--muted);
  font-size: 0.7rem;
}

.checking-history-row.is-debit > b { color: #ff8b98; }
.checking-history-row.is-credit > b { color: #75e6b1; }

.checking-history-delete {
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 117, 133, 0.38);
  border-radius: 8px;
  color: #ff9ba6;
  background: rgba(255, 80, 103, 0.09);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

@media (min-width: 641px) {
  :is(.fixed-card, .variable-card) .variable-transaction-row {
    grid-template-columns:
      minmax(150px, 1.28fr) minmax(90px, 0.66fr)
      minmax(150px, 1fr) minmax(145px, 1fr) minmax(68px, auto);
    column-gap: 18px;
  }

  .variable-transaction-payment {
    color: #c8d8e8;
    text-align: center;
  }

  .variable-transactions-breakdown:has(.payment-select-shell.is-open),
  .variable-details-panel:has(.payment-select-shell.is-open) {
    position: relative;
    z-index: 30;
    overflow: visible;
  }

  .variable-transaction-row:has(.payment-select-shell.is-open) {
    position: relative;
    z-index: 35;
  }

  :is(.fixed-card, .variable-card) .variable-transaction-header > span:nth-child(3),
  :is(.fixed-card, .variable-card) .variable-transaction-header > span:nth-child(4) {
    text-align: center;
  }

  .all-table-add-modal .variable-expense-form-grid:has(.installment-count-field) {
    grid-template-areas:
      "date date"
      "description subcategory"
      "amount payment"
      "amount installments";
  }

  .all-table-add-modal .payment-method-field {
    grid-area: payment;
    align-self: start;
  }

  .all-table-add-modal .installment-count-field {
    grid-area: installments;
    align-self: start;
  }
}

@media (max-width: 640px) {
  .checking-history-controls {
    align-items: flex-start;
    flex-direction: column;
  }

  .variable-expense-form-field .payment-select-button,
  .variable-expense-form-field .payment-select-shell {
    height: 50px;
    min-height: 50px;
  }

  .mobile-row-editing-ready
    :is(.fixed-card, .variable-card)
    tbody tr:not(.is-mobile-row-open)
    .mobile-row-payment-cell {
    display: none;
  }

  .mobile-row-editing-ready
    :is(.fixed-card, .variable-card)
    tbody tr.is-mobile-row-open
    .mobile-row-payment-cell {
    grid-area: payment;
    display: grid;
    width: 100%;
    min-width: 0;
    gap: 7px;
    padding: 0;
  }

  .mobile-row-editing-ready
    :is(.fixed-card, .variable-card)
    tbody tr.is-mobile-row-open
    .mobile-row-payment-cell::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
  }

  .mobile-row-editing-ready .fixed-card tbody tr.is-mobile-row-open {
    grid-template-areas:
      "description description"
      "payment payment"
      "amount amount"
      "pin pin";
  }

  .mobile-row-editing-ready .variable-card tbody tr.is-mobile-row-open {
    grid-template-areas:
      "description"
      "payment"
      "amount"
      "budget"
      "liquidity";
  }

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

.variable-expense-modal:not(.all-table-add-modal) .payment-method-field {
  grid-column: 1 / -1;
}

.variable-expense-modal:not(.all-table-add-modal) .payment-method-field .payment-select-shell,
.variable-expense-modal:not(.all-table-add-modal) .payment-method-field .payment-select-button {
  width: 100%;
}
