:root{
    --txn-gap:12px;
    --txn-right-max:260px;
    --txn-right-max-mobile:188px;
}
/* Canonical txn-card: 2-row grid layout */
.txn-card, .txn-card.txn-compact{
    display:grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(132px, var(--txn-right-max)) !important;
    grid-auto-rows: auto !important;
    gap: 6px 12px !important;
    align-items: start !important;
}
.txn-card .txn-left{ grid-column:1/2; grid-row:1/3; min-width:0; overflow:hidden; }
.txn-card .txn-right{
    grid-column:2/3;
    grid-row:1/3;
    min-width:0;
    justify-self:stretch;
    align-self:stretch;
    display:grid;
    grid-template-columns:minmax(0, 1fr) auto;
    grid-template-areas:
        "amount amount"
        "balance actions";
    row-gap:6px;
    column-gap:8px;
    align-items:center;
}
.txn-card .txn-meta{ grid-column:1/2; grid-row:2/3; display:flex; gap:6px; flex-wrap:wrap; }
.txn-card .meta-pill{ max-width:160px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.txn-card .txn-head > div{ min-width:0; }
.txn-card .txn-title{
    display:block;
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
}
.txn-card .txn-right .txn-amount,
.txn-card .txn-right .txn-balance{
    max-width:100%;
    min-width:0;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}
.txn-card .txn-amount{ grid-area:amount; justify-self:end; text-align:right; font-weight:800; }
.txn-card .txn-balance{ grid-area:balance; justify-self:end; text-align:right; }
.txn-card .txn-actions{ grid-area:actions; justify-self:end; display:flex; gap:8px; align-items:center; }
.txn-card .txn-open{ display:inline-flex; align-items:center; gap:6px; }
.txn-card .txn-open .btn-icon{ width:14px; height:14px; display:block; }
@media (max-width:420px){
    .txn-card .meta-pill{ max-width:120px; }
}

/* Helper selectors for transaction UI (icons, pills, meta, etc.) */
.txn-head { display: flex; align-items: center; gap: 10px; }
.txn-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: var(--panel-muted); border: 1px solid var(--line); flex-shrink: 0; }
.txn-icon svg { width: 18px; height: 18px; display: block; color: var(--muted); fill: currentColor; stroke: currentColor; }
.txn-type-icon.income { color: var(--success); }
.txn-type-icon.expense { color: var(--danger); }
.meta-icon { display: inline-flex; width: 14px; height: 14px; margin-right: 6px; align-items: center; justify-content: center; color: var(--muted); }
.meta-pill, .type-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 10px; background: var(--panel-muted); border: 1px solid var(--line); }
.type-pill { font-weight: 800; font-size: 11px; }
.txn-note { margin-top: 10px; padding: 10px 12px; border-radius: 14px; background: var(--panel-muted); color: var(--text); }
.txn-footer { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.balance-block { font-size: 12px; }
.balance-value { display: block; margin-top: 4px; color: var(--accent); font-weight: 800; font-size: 14px; }
.txn-actions { gap: 8px; }
.inline-link { color: var(--accent); text-decoration: none; font-weight: 700; }
.empty-card { padding: 18px 14px; text-align: center; color: var(--muted); }

/* Compact-mode adjustments for txn cards (moved from app.css) */
body.compact-mode .txn-card,
body.compact-mode .txn-card.txn-compact {
    padding: 8px;
}
body.compact-mode .txn-title { font-size: 13px; }
body.compact-mode .txn-amount { font-size: 13px; }
body.compact-mode .balance-value { font-size: 13px; }

/* Compact-specific txn-compact tweaks (moved from app.css) */
.txn-card.txn-compact .txn-open {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 9px;
    white-space: nowrap;
}

.txn-card.txn-compact .txn-balance {
    color: var(--muted);
    font-size: 13px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
}

.txn-card.txn-compact .balance-value {
    margin-top: 0;
    display: inline-block;
    font-size: 13px;
    color: var(--accent);
    font-weight: 800;
}

.txn-card.txn-compact .txn-actions .btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

/* Keep transaction feeds as a vertical list across the app. */
#recentTransactions.card-list,
#transactionsList.card-list {
    grid-template-columns: 1fr;
}

/* Mobile-only compaction to preserve name width without changing desktop layout. */
@media (max-width:600px){
    .txn-card,
    .txn-card.txn-compact{
        grid-template-columns: minmax(0, 1fr) minmax(88px, var(--txn-right-max-mobile)) !important;
    }

    .txn-card .txn-right{
        grid-template-columns:minmax(0, 1fr) auto;
        grid-template-areas:
            "amount actions"
            "balance actions";
        column-gap:6px;
    }

    .txn-card .txn-amount,
    .txn-card .txn-balance{
        font-size:12px;
    }

    .txn-card .txn-head{ gap:8px; }
    .txn-card .txn-icon{ width:28px; height:28px; border-radius:8px; }

    .txn-card .txn-actions .btn,
    .txn-card .txn-open{
        min-width:32px;
        height:30px;
        padding:0 7px;
        justify-content:center;
        gap:0;
        font-size:0;
    }

    .txn-card .txn-open .btn-icon{ width:14px; height:14px; }
}
