/* Page-specific layout: accounts ledger, insights, crypto, sign-in. */

/* ==========================================================================
   Accounts (/bank)
   ========================================================================== */

.bank-summary > * + * { margin-top: 18px; }
.bank-layout > * + * { margin-top: 24px; }


.hero .figure { margin: 4px 0 10px; }

.hero-spark {
    width: calc(100% + 12px);
    height: 84px;
    margin: 16px -6px 0;
}

.hero-axis {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--ink-3);
}

.month-note { margin: 10px 4px 0; }

/* ---------- Search and filters ---------- */

.search-row {
    display: flex;
    gap: 8px;
}

.search-row .field { flex: 1; }
.filter-toggle[aria-expanded="true"] { background: var(--accent); }

.filter-direction .form-label { margin-top: 14px; }

@media (min-width: 760px) {
    .sheet { display: none; }
    .sheet[data-open] { display: block; }

    .filter-panel {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px 12px;
        margin-top: 10px;
        padding: 18px;
        border-radius: var(--r-tile);
        background: var(--surface);
        animation: pop 0.18s var(--ease);
    }

    .filter-panel .form-label { margin: 0 0 6px; }
    .filter-direction,
    .filter-period { grid-column: 1 / -1; }
    .filter-period .form-row { max-width: 420px; }
    .filter-direction .seg { max-width: 360px; }
    .filter-panel .sheet-actions { grid-column: 1 / -1; }
    .filter-apply { display: none; }
    .filter-reset { height: 38px; padding: 0 16px; font-size: 14px; }
}

/* ---------- Ledger ---------- */

.tx-scroll:empty { display: none; }
#tx-search-results:not(:empty) ~ #tx-scroll { display: none; }

.tx-month-head {
    position: sticky;
    z-index: 5;
    top: 0;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 4px 6px;
    background: var(--bg);
}

.tx-month-head::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 10px;
    background: linear-gradient(var(--bg), transparent);
    pointer-events: none;
}

.tx-month-head h3 {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.tx-month-net {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink-2);
}

.tx-month-placeholder {
    border-radius: var(--r-tile);
    background: rgba(255, 255, 255, 0.45);
}

.tx-day {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin: 14px 6px 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-2);
}

.tx-month-body > .tx-day:first-child { margin-top: 4px; }

.tx-row > summary {
    list-style: none;
    cursor: pointer;
}

.tx-row > summary::-webkit-details-marker { display: none; }
.tx-row[open] .row-title,
.tx-row[open] .row-sub { white-space: normal; }

.tx-detail { padding: 2px 0 16px; }

.tx-detail-loading {
    font-size: 13px;
    color: var(--ink-2);
}

#tx-search-results > .empty { margin-top: 8px; }

.facts {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 7px 16px;
    font-size: 13px;
}

.facts dt { color: var(--ink-2); }

.facts dd {
    font-weight: 500;
    overflow-wrap: anywhere;
}

.tx-cat-form {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.choices {
    display: grid;
    gap: 6px;
}

.choice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: var(--r-input);
    background: var(--surface-2);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.choice input {
    flex: none;
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--accent);
}

.choice span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.choice:has(input:checked) {
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.tx-search-summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin: 18px 6px 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
}

.tx-search-summary > span:last-child {
    display: flex;
    gap: 10px;
    white-space: nowrap;
}

/* ---------- Year scrubber: wide screens only ---------- */

.tx-scrubber { display: none; }

@media (min-width: 1024px) {
    .bank-layout {
        display: grid;
        grid-template-columns: 372px minmax(0, 1fr);
        gap: 36px;
        align-items: start;
    }

    .bank-layout > * + * { margin-top: 0; }

    .bank-summary {
        position: sticky;
        top: 20px;
    }

    html.tx-scrub-page {
        scrollbar-width: none;
        scrollbar-gutter: auto;
    }

    html.tx-scrub-page::-webkit-scrollbar { display: none; }

    .tx-scrubber {
        display: block;
        position: fixed;
        z-index: 30;
        top: 92px;
        bottom: 24px;
        right: 0;
        width: 72px;
        cursor: ns-resize;
        user-select: none;
    }

    body:has(#tx-search-results:not(:empty)) .tx-scrubber { display: none; }

    .tx-scrubber-track {
        position: absolute;
        top: 0;
        bottom: 0;
        right: 18px;
        width: 2px;
        border-radius: var(--r-pill);
        background: var(--line-strong);
    }

    .tx-scrubber-tick {
        position: absolute;
        right: 28px;
        transform: translateY(-50%);
        font-size: 11px;
        font-weight: 600;
        color: var(--ink-3);
    }

    .tx-scrubber-thumb {
        position: absolute;
        right: 14px;
        width: 10px;
        height: 36px;
        border-radius: var(--r-pill);
        background: var(--ink);
    }

    .tx-scrubber-bubble {
        position: absolute;
        right: 64px;
        padding: 5px 11px;
        border-radius: var(--r-pill);
        background: var(--surface);
        box-shadow: var(--shadow-float);
        font-size: 12px;
        font-weight: 600;
        white-space: nowrap;
        transform: translateY(5px);
        opacity: 0;
        transition: opacity 0.25s;
    }

    .tx-scrubber-bubble.active,
    .tx-scrubber:hover .tx-scrubber-bubble { opacity: 1; }
}

/* ==========================================================================
   Insights (/bank/dashboard)
   ========================================================================== */

.insights-top > * + * { margin-top: 14px; }

.pills {
    display: flex;
    gap: 6px;
    margin-inline: calc(-1 * var(--gutter));
    padding-inline: var(--gutter);
    overflow-x: auto;
    scrollbar-width: none;
}

.pills::-webkit-scrollbar { display: none; }

.pill {
    flex: none;
    padding: 8px 15px;
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, 0.6);
    color: var(--ink-2);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.pill.is-active { background: var(--ink); color: #fff; }

.insights-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

@media (min-width: 900px) {
    .insights-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 20px;
    }

    .span-2 { grid-column: 1 / -1; }

    /* Pair cards of similar height: the two long lists, then the two short blocks. */
    #cashflow { order: 1; }
    #spending { order: 2; }
    #fixed-charges { order: 3; }
    #merchants { order: 4; }
    #heatmap { order: 5; }
    #accounts { order: 6; }
    #connections { order: 7; }
}

.legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    margin-top: 14px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink-2);
}

.legend > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ---------- Cash flow ---------- */

.cf {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 4px;
}

.cf-col { text-align: center; }

.cf-bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    height: 132px;
    border-bottom: 1px solid var(--line);
}

.cf-bar {
    width: clamp(10px, 26%, 22px);
    min-height: 3px;
    border-radius: 7px 7px 0 0;
}

.cf-none { visibility: hidden; }
.cf-in { background: var(--accent); }
.cf-out { background: var(--warm); }

.cf-net {
    margin-top: 8px;
    font-size: clamp(10.5px, 3.1vw, 12.5px);
    font-weight: 700;
    font-variant-numeric: proportional-nums;
    letter-spacing: -0.03em;
    white-space: nowrap;
}

.cf-month {
    margin-top: 1px;
    font-size: 12px;
    color: var(--ink-2);
}

@media (min-width: 760px) {
    .cf-bars { height: 168px; gap: 6px; }
    .cf-net { font-size: 14px; }
}

/* ---------- Categories ---------- */

.donut-wrap {
    position: relative;
    width: min(208px, 62%);
    margin: 6px auto 18px;
}

.donut path {
    fill: color-mix(in srgb, var(--c) 78%, #fff);
    stroke: var(--surface);
    stroke-width: 2.5;
    stroke-linejoin: round;
}

.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.donut-center b {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.cat-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    font-size: 14.5px;
}

.cat-list li + li { border-top: 1px solid var(--line); }

.cat-name {
    flex: 1;
    min-width: 0;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cat-share {
    width: 44px;
    font-size: 13px;
    color: var(--ink-2);
    text-align: right;
}

.cat-amount {
    width: 72px;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

/* ---------- Merchants ---------- */

.rank-list li + li { margin-top: 2px; }
.rank-list .row { padding-bottom: 8px; }

.share-bar {
    height: 6px;
    margin-left: 48px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    overflow: hidden;
}

.share-bar > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: color-mix(in srgb, var(--c) 70%, #fff);
}

/* ---------- Fixed charges ---------- */

.figure-md {
    font-size: 34px;
    margin-top: 2px;
}

.figure-md small {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--ink-2);
}

.plain-list { margin-top: 12px; }
.plain-list .row { padding: 9px 0; }
.plain-list .row + .row { border-top: 1px solid var(--line); }

/* ---------- Heatmap ---------- */

.hm-grid,
.hm-axis {
    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    gap: 4px;
}

.hm { max-width: 460px; }
.hm-grid { grid-template-rows: repeat(7, auto); }

.hm-cell {
    aspect-ratio: 1;
    border-radius: 6px;
    background: var(--accent);
    opacity: calc(0.14 + var(--i) * 0.86);
}

.hm-zero {
    background: var(--surface-2);
    opacity: 1;
}

.hm-axis {
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--ink-3);
}

.hm-axis span { white-space: nowrap; }
.hm-legend { justify-content: flex-end; gap: 4px; }
.hm-legend .hm-cell { width: 12px; border-radius: 4px; }
.hm-legend > span:first-child { margin-right: 4px; }
.hm-legend > span:last-child { margin-left: 4px; }

/* ---------- Accounts and connections ---------- */

.disc {
    flex: none;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
}

.disc-mint { background: var(--accent-soft); color: var(--accent-ink); }
.disc-peach { background: var(--peach); color: var(--peach-ink); }
.disc-lilac { background: var(--lilac); color: var(--lilac-ink); }
.disc-sky { background: var(--sky); color: var(--sky-ink); }
.disc-rose { background: var(--rose); color: var(--rose-ink); }
.disc-butter { background: var(--butter); color: var(--butter-ink); }

.conn .row-sub { white-space: normal; }

.conn-error {
    margin: -2px 0 12px;
    padding: 10px 12px;
    border-radius: var(--r-input);
    background: var(--down-soft);
    color: var(--down-ink);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.conn-error code {
    display: block;
    margin-top: 6px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
}

/* ==========================================================================
   Crypto (/)
   ========================================================================== */

.crypto-top > * + *,
.crypto-main > * + * { margin-top: 16px; }

.hero-delta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

.chart {
    height: 220px;
    margin: 10px -6px 12px;
}

.chart-hero { height: 190px; }

.chart-legend {
    margin: -4px 0 12px;
    justify-content: center;
}

.swatch-line,
.swatch-dashed {
    width: 16px;
    height: 0;
    border-radius: 0;
    background: none;
    border-top: 2px solid var(--accent);
}

.swatch-dashed { border-top: 2px dashed var(--ink-3); }

.figure-missing { color: var(--ink-3); }
.chart-empty { margin-top: 12px; }

#performance .section-head { align-items: center; }

@media (min-width: 900px) {
    .crypto-top {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 20px;
    }

    .crypto-top > * + * { margin-top: 0; }

    #performance {
        display: flex;
        flex-direction: column;
    }

    #pnl-block {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    #performance .chart { flex: 1; min-height: 240px; }
    .chart-hero { height: 240px; }
}

/* ---------- Holdings ---------- */

.asset-icon { font-size: 15px; }

.spark {
    flex: none;
    width: 64px;
    height: 24px;
}

.holding-cost { display: none; }
.holding-value { min-width: 78px; }

.fold { margin-top: 10px; }

.fold > summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, 0.6);
    color: var(--ink-2);
    font-size: 13.5px;
    font-weight: 600;
    list-style: none;
    cursor: pointer;
}

.fold > summary::-webkit-details-marker { display: none; }
.fold > summary .chevron { transition: transform 0.2s var(--ease); }
.fold[open] > summary .chevron { transform: rotate(90deg); }
.fold > .list { margin-top: 10px; }

@media (min-width: 760px) {
    .spark { width: 120px; margin-inline: 12px; }
    .holding-cost { display: block; min-width: 110px; }
    .holding-value { min-width: 110px; }
}

/* ---------- Prices ---------- */

.slots {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

.slot-b { display: none; }

.slot-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.select-inline {
    width: auto;
    height: 40px;
    border-radius: var(--r-pill);
    font-size: 15px;
    font-weight: 600;
}

@media (min-width: 900px) {
    .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
    .slot-b { display: block; }
}

/* ---------- Assistant ---------- */

.budget-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
    color: var(--ink-2);
}

.budget-line b {
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
}

.assistant-budget .progress { margin-top: 10px; }
.assistant-empty { margin-top: 14px; }

/* ==========================================================================
   Sign-in
   ========================================================================== */

.bare .page {
    display: grid;
    place-items: center;
    min-height: 100dvh;
    padding-block: 32px;
}

.login {
    width: 100%;
    max-width: 380px;
}

.login .wordmark {
    display: block;
    margin: 0 0 22px;
    font-size: 28px;
    text-align: center;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-sub {
    margin-top: 4px;
    color: var(--ink-2);
}

.login form {
    display: grid;
    gap: 10px;
    margin-top: 20px;
}

.login-error {
    margin-top: 14px;
    white-space: normal;
}

.login-lang {
    display: flex;
    justify-content: center;
    margin-top: 18px;
}
