/* ==========================================================================
   /week page
   ========================================================================== */

.week {
    --week-ok: #6096ba;
    --week-warn: #e0a100;
    --week-over: #CD0A0A;
    --week-good: #30AD23;
    --week-ink: #232f3e;
    --week-muted: #777;
    --week-line: #e6e6e6;
    --week-soft: #f6f7f9;
    color: var(--week-ink);
}

.week [hidden] {
    display: none !important;
}

.week section {
    margin-bottom: 1.5rem;
}

.link-button {
    background: none;
    border: 0;
    padding: 0;
    color: #0078e7;
    cursor: pointer;
    font: inherit;
    font-size: .875rem;
}

.link-button:hover {
    text-decoration: underline;
}

.week-section-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: .25rem .75rem;
    margin-bottom: .5rem;
}

.week-section-head h4 {
    margin: 0;
}

.week-section-head__hint {
    color: var(--week-muted);
    font-size: .8rem;
}

.week-section-head__count {
    color: var(--week-muted);
    font-weight: normal;
    font-size: .875rem;
}

/* ── Week navigation ──────────────────────────────────────────────────── */

.week-nav {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
}

.week-nav__title {
    text-align: center;
    min-width: 11rem;
}

.week-nav__title h3 {
    margin: 0;
    line-height: 1.2;
}

.week-nav__dates {
    color: var(--week-muted);
    font-size: .875rem;
}

.week-nav__today {
    margin-left: auto;
}

/* ── Progress bars ────────────────────────────────────────────────────── */

.progress {
    position: relative;
    display: block;
    height: 8px;
    background: #e9edf1;
    border-radius: 4px;
    overflow: visible;
}

.progress--lg {
    height: 12px;
    border-radius: 6px;
}

.progress__fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--week-ok);
    transition: width .3s ease;
}

/* Stacked bar: fixed segment, then variable spending */
.progress--lg {
    display: flex;
}

.progress__fixed {
    display: block;
    height: 100%;
    background: #b8c2cc;
    border-radius: 6px 0 0 6px;
}

.progress--lg .progress__fixed + .progress__fill {
    border-radius: 0 6px 6px 0;
}

.progress--lg .progress__fill:first-child {
    border-radius: 6px;
}

.progress__pace {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    margin-left: -1px;
    background: var(--week-ink);
    opacity: .45;
    border-radius: 1px;
}

/* ── Week summary ─────────────────────────────────────────────────────── */

.week-summary {
    background: var(--week-soft);
    border: 1px solid var(--week-line);
    border-radius: 8px;
    padding: 1rem 1.25rem;
}

.week-summary__top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: .5rem 1.5rem;
    margin-bottom: .75rem;
}

.week-summary__balance {
    display: flex;
    align-items: baseline;
    gap: .5rem;
}

.week-summary__amount {
    font-size: 2.25rem;
    font-weight: 300;
    line-height: 1;
}

.week-summary__amount sup {
    font-size: .5em;
}

.week-summary__label {
    color: var(--week-muted);
}

.week-summary__meta {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1rem;
    color: var(--week-muted);
    font-size: .875rem;
}

.week-summary__meta strong {
    color: var(--week-ink);
    font-weight: 600;
}

.week-summary__legend {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1rem;
    margin-top: .5rem;
    font-size: .75rem;
    color: var(--week-muted);
}

.swatch {
    display: inline-block;
    width: .7rem;
    height: .7rem;
    margin-right: .3rem;
    border-radius: 2px;
    vertical-align: -1px;
}

.swatch--fixed { background: #b8c2cc; }
.swatch--variable { background: var(--week-ok); }
.swatch--pace { width: 2px; background: var(--week-ink); opacity: .45; }
.week-summary--warn .swatch--variable { background: var(--week-warn); }
.week-summary--over .swatch--variable { background: var(--week-over); }

.week-summary__hint {
    margin: .6rem 0 0;
    font-size: .875rem;
    color: #8a6500;
}

.week-summary--warn .progress__fill { background: var(--week-warn); }
.week-summary--over .progress__fill { background: var(--week-over); }
.week-summary--over .week-summary__amount,
.week-summary--over .week-summary__label { color: var(--week-over); }
.week-summary--over { border-color: #f1c4c4; background: #fdf5f5; }

/* ── Categories ───────────────────────────────────────────────────────── */

.cat-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: .25rem 1.5rem;
}

@media screen and (min-width: 48em) {
    .cat-list {
        grid-template-columns: 1fr 1fr;
    }
}

.cat {
    display: flex;
    align-items: stretch;
    border-radius: 6px;
    transition: opacity .15s ease, background-color .15s ease;
}

.cat:hover {
    background: var(--week-soft);
}

.cat__button {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "name reserve"
        "bar  bar"
        "spent spent";
    gap: .3rem .5rem;
    padding: .5rem .5rem .5rem .6rem;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.cat__button:focus-visible {
    outline: 2px solid #0078e7;
    outline-offset: 1px;
}

.cat__name {
    grid-area: name;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cat__reserve {
    grid-area: reserve;
    font-size: .875rem;
    white-space: nowrap;
}

.cat__bar {
    grid-area: bar;
}

.cat__spent {
    grid-area: spent;
    font-size: .75rem;
    color: var(--week-muted);
}

.cat__link {
    display: flex;
    align-items: center;
    padding: 0 .5rem;
    color: #aaa;
    font-size: 1.1rem;
    text-decoration: none;
}

.cat__link:hover {
    color: var(--week-ink);
}

.cat--warn .progress__fill { background: var(--week-warn); }
.cat--over .progress__fill { background: var(--week-over); }
.cat--over .cat__reserve { color: var(--week-over); font-weight: 600; }

.cat.is-active .cat__button {
    border-color: var(--week-ok);
    background: #eef4f9;
}

.cat.is-dimmed {
    opacity: .5;
}

.cat.is-dimmed:hover {
    opacity: .85;
}

.cat-list__more {
    display: none;
    margin: .5rem 0 0 .6rem;
}

@media screen and (max-width: 48em) {
    .cat-list:not(.is-expanded) > li:nth-child(n+5) {
        display: none;
    }

    .cat-list__more {
        display: inline-block;
    }
}

.cat-fixed {
    margin-top: .75rem;
    padding: 0 .6rem;
    font-size: .875rem;
    color: var(--week-muted);
}

.cat-fixed summary {
    cursor: pointer;
    padding: .25rem 0;
}

.cat-fixed__total {
    margin-left: .5rem;
    color: var(--week-ink);
}

.cat-fixed ul {
    list-style: none;
    margin: .25rem 0 0;
    padding: 0;
    max-width: 24rem;
}

.cat-fixed li {
    display: flex;
    justify-content: space-between;
    padding: .2rem 0;
    border-bottom: 1px dotted var(--week-line);
}

/* ── Quick add form ───────────────────────────────────────────────────── */

.quick-add {
    background: #fff;
    border: 1px solid var(--week-line);
    border-radius: 8px;
    padding: .75rem 1rem;
}

.quick-add__fields {
    display: grid;
    grid-template-columns: 11rem minmax(9rem, 2fr) 7rem minmax(8rem, 1.2fr) minmax(7rem, 1fr) auto;
    gap: .5rem;
    align-items: end;
}

/* No method field: drop a column */
.quick-add__fields:not(:has(.qa-field--method)) {
    grid-template-columns: 11rem minmax(9rem, 2fr) 7rem minmax(8rem, 1.2fr) auto;
}

.qa-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.qa-field label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--week-muted);
    margin-bottom: .2rem;
}

.quick-add input,
.quick-add select {
    width: 100%;
    box-sizing: border-box;
}

.quick-add .awesomplete {
    width: 100%;
}

.qa-field--amount input {
    text-align: right;
}

.qa-field--submit .pure-button {
    white-space: nowrap;
}

.quick-add__more {
    margin-top: .5rem;
}

.quick-add__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: .5rem;
    font-size: .8rem;
}

.quick-add__full {
    color: var(--week-muted);
    margin-left: auto;
}

@media screen and (max-width: 64em) {
    .quick-add__fields,
    .quick-add__fields:not(:has(.qa-field--method)) {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .qa-field--vendor {
        grid-column: span 2;
    }
}

@media screen and (max-width: 35.5em) {
    .quick-add__fields,
    .quick-add__fields:not(:has(.qa-field--method)) {
        grid-template-columns: 1fr 1fr;
    }

    .qa-field--vendor,
    .qa-field--submit {
        grid-column: 1 / -1;
    }

    .qa-field--submit .pure-button {
        width: 100%;
        padding: .6em;
    }
}

/* ── Expenses ─────────────────────────────────────────────────────────── */

.week-expenses .week-section-head {
    justify-content: space-between;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .2rem .3rem .2rem .7rem;
    background: #eef4f9;
    border: 1px solid var(--week-ok);
    border-radius: 999px;
    font-size: .8rem;
}

.filter-chip__clear {
    background: none;
    border: 0;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 .3rem;
    color: var(--week-muted);
}

.filter-chip__clear:hover {
    color: var(--week-ink);
}

.day {
    margin-bottom: .75rem;
}

.day__head {
    display: flex;
    justify-content: space-between;
    padding: .35rem .5rem;
    border-bottom: 2px solid var(--week-line);
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--week-muted);
}

.expense-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.expense {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) 6.5rem auto;
    align-items: center;
    gap: .5rem;
    padding: .55rem .5rem;
    border-bottom: 1px solid var(--week-line);
    cursor: pointer;
}

.expense:hover {
    background: var(--week-soft);
}

.expense.expense-highlight {
    background-color: #cce5ff;
}

.expense.new-expense {
    animation: greenfade 8s ease-in;
}

.expense__main {
    min-width: 0;
}

.expense__vendor {
    font-weight: 600;
    color: inherit;
    text-decoration: none;
}

.expense__vendor:hover {
    text-decoration: underline;
}

.expense__desc {
    display: block;
    font-size: .8rem;
    color: var(--week-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.expense__meta {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem .5rem;
    align-items: center;
    min-width: 0;
    font-size: .8rem;
}

.expense__cat {
    padding: .1rem .5rem;
    background: #eef1f4;
    border-radius: 999px;
    color: var(--week-ink);
    text-decoration: none;
    white-space: nowrap;
}

.expense__cat:hover {
    background: #e0e5ea;
}

.expense__method {
    color: var(--week-muted);
    white-space: nowrap;
}

.expense__amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.expense__amount.green {
    color: var(--week-good);
}

.expense__actions {
    display: flex;
    align-items: center;
    gap: .15rem;
}

.expense-menu__button {
    background: none;
    border: 0;
    padding: .25rem .5rem;
    color: #888;
    cursor: pointer;
    border-radius: 4px;
}

.expense-menu__button:hover {
    background: #e6e6e6;
    color: var(--week-ink);
}

/* Mobile: two-line rows — vendor + amount, then category/method/description */
@media screen and (max-width: 35.5em) {
    .expense {
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-areas:
            "main   amount actions"
            "meta   meta   actions";
        row-gap: .2rem;
    }

    .expense__main    { grid-area: main; }
    .expense__meta    { grid-area: meta; }
    .expense__amount  { grid-area: amount; }
    .expense__actions { grid-area: actions; }
}

.week-empty {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--week-muted);
}

.week-empty h3 {
    color: var(--week-ink);
    margin-top: 0;
}
