/* styles/widgets/money.css
 *
 * Extracted from styles/main.css during T4#20 (the May-2026
 * CSS-split refactor). Originally lived at lines 7029-7462
 * of main.css. Cascade order is preserved: main.css loads first
 * (themes + base + modal/tab/layout infra), then per-widget
 * files in alphabetical order via <link> tags in index.html.
 */

/* ── MONEY WIDGET (Phase 2.12) ─────────────────────────────────
 * One widget, five tabs (Cash Flow / Subscriptions / Budget /
 * Net Worth / Goals). Closes seven feature_requests in the Money
 * cluster. Editor modals piggy-back on shared .modal styles; the
 * money-specific selectors below cover the in-widget layout.
 */

.money-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 4px 0 10px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}
.money-tab {
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.money-tab:hover { color: var(--text); background: var(--surface2); }
.money-tab-active {
    color: var(--text);
    background: color-mix(in oklab, var(--accent) 18%, var(--surface2));
    border-color: color-mix(in oklab, var(--accent) 40%, var(--border));
}

.money-stage {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.money-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.money-summary-single { grid-template-columns: 1fr; }
.money-summary-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    background: var(--surface2);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.money-summary-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.money-summary-value { font-size: 16px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

.money-summary-expense {
    border-color: color-mix(in oklab, var(--red) 35%, var(--border));
    background: color-mix(in oklab, var(--red) 8%, var(--surface2));
}
.money-summary-income {
    border-color: color-mix(in oklab, #43d9a2 35%, var(--border));
    background: color-mix(in oklab, #43d9a2 8%, var(--surface2));
}
.money-summary-net {
    border-color: color-mix(in oklab, var(--accent) 35%, var(--border));
    background: color-mix(in oklab, var(--accent) 8%, var(--surface2));
}
.money-summary-sub {
    border-color: color-mix(in oklab, #a78bfa 35%, var(--border));
    background: color-mix(in oklab, #a78bfa 8%, var(--surface2));
}

/* Cash Flow toggle pill */
.money-cashflow-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px;
    background: var(--surface2);
}
.money-pill {
    background: transparent;
    border: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    cursor: pointer;
}
.money-pill-active {
    background: var(--accent);
    color: var(--accent-on);
}

/* Quick-add row */
.money-quickadd {
    display: grid;
    grid-template-columns: auto 100px 1fr 1fr auto;
    gap: 6px;
    align-items: center;
    padding: 6px 0;
    border-top: 1px dashed var(--border);
    border-bottom: 1px dashed var(--border);
}
.money-input {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 12px;
    min-width: 0;
}
.money-input-amt { font-variant-numeric: tabular-nums; }
.money-add-btn {
    background: var(--accent);
    color: var(--accent-on);
    border: 0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    cursor: pointer;
    white-space: nowrap;
}
.money-add-btn:hover { filter: brightness(1.1); }

.money-add-btn-block {
    background: transparent;
    color: var(--muted);
    border: 1px dashed var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    padding: 8px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.money-add-btn-block:hover {
    color: var(--text);
    border-color: var(--accent);
    background: color-mix(in oklab, var(--accent) 5%, var(--surface2));
}

/* Cash Flow recent list */
.money-tx-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 320px;
    overflow-y: auto;
}
.money-tx-row {
    display: grid;
    grid-template-columns: 76px 100px 1fr auto auto;
    gap: 8px;
    align-items: center;
    padding: 4px 6px;
    border-radius: 6px;
    background: var(--surface2);
    border: 1px solid var(--border);
    font-size: 12px;
}
.money-tx-date  { color: var(--muted); font-variant-numeric: tabular-nums; }
.money-tx-cat   { color: var(--text); font-weight: 600; }
.money-tx-note  { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.money-tx-amt   { font-weight: 700; font-variant-numeric: tabular-nums; }
.money-tx-amt-expense { color: var(--red); }
.money-tx-amt-income  { color: #43d9a2; }

.money-icon-btn {
    background: transparent;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}
.money-icon-btn:hover { color: var(--text); background: var(--surface); }
.money-icon-btn-del:hover { color: var(--red); }

/* Cash Flow categories chart */
.money-cats {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    background: var(--surface2);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.money-cats-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.money-cat-bar {
    display: grid;
    grid-template-columns: 90px 1fr 80px;
    gap: 8px;
    align-items: center;
    font-size: 11px;
}
.money-cat-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.money-cat-track {
    height: 8px;
    background: var(--surface);
    border-radius: 999px;
    overflow: hidden;
}
.money-cat-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), color-mix(in oklab, var(--accent) 60%, #43d9a2));
    transition: width 0.2s ease;
}
.money-cat-amt { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }

/* Subscriptions */
.money-sub-list { display: flex; flex-direction: column; gap: 4px; }
.money-sub-row {
    display: grid;
    grid-template-columns: 1fr 70px 100px 80px 100px auto;
    gap: 8px;
    align-items: center;
    padding: 4px 6px;
    border-radius: 6px;
    background: var(--surface2);
    border: 1px solid var(--border);
    font-size: 12px;
}
.money-sub-name { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.money-sub-freq { color: var(--muted); text-transform: capitalize; }
.money-sub-cat  { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.money-sub-amt  { color: var(--text); font-variant-numeric: tabular-nums; text-align: right; }
.money-sub-monthly { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; font-size: 11px; }

/* Budget */
.money-budget-help {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
}
.money-budget-list { display: flex; flex-direction: column; gap: 6px; }
.money-budget-row {
    display: grid;
    grid-template-columns: 130px 90px 1fr 130px;
    gap: 8px;
    align-items: center;
    padding: 4px 6px;
    border-radius: 6px;
    background: var(--surface2);
    border: 1px solid var(--border);
    font-size: 12px;
}
.money-budget-row-over {
    border-color: color-mix(in oklab, var(--red) 50%, var(--border));
    background: color-mix(in oklab, var(--red) 8%, var(--surface2));
}
.money-budget-cat { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.money-budget-target { padding: 4px 6px; }
.money-budget-track {
    height: 8px;
    background: var(--surface);
    border-radius: 999px;
    overflow: hidden;
}
.money-budget-fill {
    height: 100%;
    background: linear-gradient(90deg, #43d9a2, var(--accent));
    transition: width 0.2s ease;
}
.money-budget-row-over .money-budget-fill {
    background: linear-gradient(90deg, #fb923c, var(--red));
}
.money-budget-spent { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }

/* Net Worth ledger */
.money-ledger-block {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.money-ledger-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--muted);
    margin-bottom: 4px;
}
.money-acct-row {
    display: grid;
    grid-template-columns: 1fr 100px 100px auto auto;
    gap: 8px;
    align-items: center;
    padding: 4px 6px;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 12px;
}
.money-acct-name { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.money-acct-type { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.money-acct-bal { font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }
.money-acct-bal-asset     { color: #43d9a2; }
.money-acct-bal-liability { color: var(--red); }

/* Goals */
.money-goal-block {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.money-goal-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--muted);
}
.money-goal-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
}
.money-goal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}
.money-goal-name { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.money-goal-amt  { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-goal-track {
    height: 8px;
    background: var(--surface2);
    border-radius: 999px;
    overflow: hidden;
}
.money-goal-fill {
    height: 100%;
    transition: width 0.2s ease;
}
.money-goal-track-savings .money-goal-fill {
    background: linear-gradient(90deg, #43d9a2, var(--accent));
}
.money-goal-track-debt .money-goal-fill {
    background: linear-gradient(90deg, #fb923c, var(--red));
}
.money-goal-meta { color: var(--muted); font-size: 11px; }
.money-goal-proj { color: var(--accent); font-size: 11px; font-weight: 600; }
.money-goal-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.money-empty {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    padding: 12px 8px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 6px;
}

/* Editor modal kind toggle (asset/liability, savings/debt) */
.money-kind-row {
    display: flex;
    gap: 8px;
}
.money-kind-opt {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface2);
    cursor: pointer;
    font-size: 12px;
    color: var(--text);
}
.money-kind-opt:has(input:checked) {
    border-color: var(--accent);
    background: color-mix(in oklab, var(--accent) 10%, var(--surface2));
}
.money-kind-opt input { accent-color: var(--accent); }

/* Mobile: collapse multi-column rows */
@media (max-width: 600px) {
    .money-summary { grid-template-columns: 1fr; }
    .money-quickadd {
        grid-template-columns: 1fr 1fr;
        grid-auto-flow: row;
    }
    .money-quickadd .money-cashflow-toggle { grid-column: 1 / -1; }
    .money-quickadd .money-add-btn          { grid-column: 1 / -1; }
    .money-tx-row {
        grid-template-columns: 1fr auto auto;
    }
    .money-tx-row .money-tx-date { grid-column: 1; }
    .money-tx-row .money-tx-cat  { grid-column: 1; font-size: 11px; }
    .money-tx-row .money-tx-note { grid-column: 1; font-size: 11px; }
    .money-sub-row {
        grid-template-columns: 1fr auto auto;
    }
    .money-sub-row .money-sub-name { grid-column: 1 / -1; }
    .money-sub-row .money-sub-freq,
    .money-sub-row .money-sub-cat { display: none; }
    .money-budget-row {
        grid-template-columns: 1fr 90px;
    }
    .money-budget-row .money-budget-track { grid-column: 1 / -1; }
    .money-budget-row .money-budget-spent { grid-column: 1 / -1; text-align: left; }
    .money-acct-row {
        grid-template-columns: 1fr auto auto auto;
    }
    .money-acct-row .money-acct-type { display: none; }
}

