/*
 * The pieces this app is built from: the chrome, cards, stat tiles, bucket
 * rows, the trend bars, and forms.
 *
 * Tokens, the reset and .page come from base.css, which is the shared look for
 * the whole super app. Nothing here redefines a colour; it maps the existing
 * ones onto what this app means by them.
 */

:root {
    /* Money moving the right way and the wrong way. Always written alongside a
       sign or a word, so colour is never the only thing carrying the meaning. */
    --gain: var(--state-on-track);
    --drop: var(--state-overspent);

    /* One per movement, taken from the shared categorical slots. */
    --kind-deposit: var(--series-1);
    --kind-withdrawal: var(--series-7);
    --kind-profit: var(--state-on-track);
    --kind-loss: var(--state-overspent);
}

/* --- The sign-in page ---------------------------------------------------- */

.login__mark {
    display: block;
    width: 72px;
    height: 72px;
    margin: 0 auto 12px;
    /* Rounded like an app icon, since that is what it is. */
    border-radius: 22%;
}

.login__title {
    margin: 0 0 6px;
    font-size: 22px;
}

/* --- Chrome ------------------------------------------------------------- */

.appbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(var(--safe-top) + 10px) var(--pad) 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--hairline);
}

.appbar__back {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-left: -6px;
    border-radius: 50%;
    color: var(--ink);
    background: var(--ghost);
    flex: none;
}

.appbar__titles {
    min-width: 0;
    flex: 1;
}

.appbar__title {
    font-size: 19px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.appbar__subtitle {
    margin: 1px 0 0;
    color: var(--ink-muted);
    font-size: 13px;
}

.appbar__action {
    flex: none;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--ghost);
    color: var(--link);
    font-size: 14px;
    font-weight: 600;
}

.tabbar {
    position: fixed;
    left: 50%;
    bottom: calc(var(--safe-bottom) + var(--tabbar-inset));
    z-index: 6;
    display: flex;
    width: min(420px, calc(100% - 2 * var(--pad)));
    transform: translateX(-50%);
    padding: 6px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--hairline);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
}

.tabbar__item {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 2px;
    border-radius: 999px;
    color: var(--ink-muted);
    font-size: 11px;
    font-weight: 600;
}

.tabbar__item svg {
    width: 21px;
    height: 21px;
}

.tabbar__item[aria-current="page"] {
    color: var(--accent);
    background: var(--ghost);
}

.fab {
    position: fixed;
    right: var(--pad);
    bottom: calc(var(--safe-bottom) + var(--tabbar-inset) + var(--tabbar-height) + 12px);
    z-index: 6;
    display: grid;
    place-items: center;
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
}

.fab svg {
    width: 26px;
    height: 26px;
}

.toasts {
    position: fixed;
    left: 50%;
    top: calc(var(--safe-top) + 62px);
    z-index: 10;
    width: min(420px, calc(100% - 2 * var(--pad)));
    transform: translateX(-50%);
}

.toast {
    margin: 0 0 8px;
    padding: 11px 14px;
    border-radius: var(--radius-small);
    background: var(--surface);
    border: 1px solid var(--hairline);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
    font-size: 14px;
}

.toast--error {
    color: var(--danger);
}

/* --- Cards and sections -------------------------------------------------- */

.card {
    padding: var(--pad);
    border-radius: var(--radius);
    background: var(--surface);
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-top: 6px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.empty {
    padding: 28px var(--pad);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
    color: var(--ink-soft);
}

.empty h2 {
    margin-bottom: 6px;
    font-size: 17px;
    color: var(--ink);
}

.empty p {
    margin: 0 0 14px;
    font-size: 14px;
}

/* --- The headline figure ------------------------------------------------- */

.headline {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--pad);
    border-radius: var(--radius);
    background: var(--surface);
}

.headline__label {
    color: var(--ink-muted);
    font-size: 13px;
}

.headline__value {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.headline__change {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 14px;
    font-weight: 600;
}

.headline__note {
    margin: 6px 0 0;
    color: var(--ink-muted);
    font-size: 12.5px;
}

.gain {
    color: var(--gain);
}

.drop {
    color: var(--drop);
}

.flat {
    color: var(--ink-muted);
}

/* --- Stat tiles ---------------------------------------------------------- */

.stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--hairline);
}

.stat {
    padding: 13px var(--pad);
    background: var(--surface);
}

.stat__label {
    display: block;
    color: var(--ink-muted);
    font-size: 12.5px;
}

.stat__value {
    display: block;
    margin-top: 2px;
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.stat__hint {
    display: block;
    margin-top: 1px;
    color: var(--ink-muted);
    font-size: 11.5px;
}

/* --- Bucket rows --------------------------------------------------------- */

.rows {
    display: flex;
    flex-direction: column;
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px var(--pad);
    color: inherit;
    border-top: 1px solid var(--hairline);
}

.row:first-child {
    border-top: 0;
}

.row--sub {
    padding-left: calc(var(--pad) + 22px);
    background: var(--ghost);
}

.row__icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 50%;
    background: var(--ghost);
    font-size: 19px;
}

.row--sub .row__icon {
    width: 30px;
    height: 30px;
    font-size: 15px;
}

.row__body {
    min-width: 0;
    flex: 1;
}

.row__name {
    display: block;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row__meta {
    display: block;
    margin-top: 1px;
    color: var(--ink-muted);
    font-size: 12.5px;
}

.row__figures {
    flex: none;
    text-align: right;
}

.row__amount {
    display: block;
    font-weight: 650;
    white-space: nowrap;
}

.row__change {
    display: block;
    margin-top: 1px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

/* --- Transaction kinds --------------------------------------------------- */

.kind-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 6px;
    border-radius: 50%;
    vertical-align: 1px;
}

.kind-deposit { background: var(--kind-deposit); }
.kind-withdrawal { background: var(--kind-withdrawal); }
.kind-profit { background: var(--kind-profit); }
.kind-loss { background: var(--kind-loss); }

/* The tag on a transaction row. Quiet by design: it labels the movement, it is
   not the movement. */
.tag-chip {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--ghost);
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 600;
    vertical-align: 1px;
}

/* --- Filter chips -------------------------------------------------------- */

.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

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

.chip {
    flex: none;
    padding: 7px 13px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--hairline);
    color: var(--ink-soft);
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
}

.chip[aria-current="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

/* --- The monthly trend --------------------------------------------------- */

.trend {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 132px;
    padding-top: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

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

.trend__month {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    width: 34px;
    height: 100%;
}

.trend__bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    width: 100%;
    height: 100%;
}

.trend__bar {
    flex: 1;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    background: var(--series-neutral);
}

.trend__bar--profit { background: var(--kind-profit); }
.trend__bar--loss { background: var(--kind-loss); }

.trend__label {
    color: var(--ink-muted);
    font-size: 10.5px;
    white-space: nowrap;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
    color: var(--ink-muted);
    font-size: 12.5px;
}

/* --- Forms --------------------------------------------------------------- */

.form {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.field > label {
    color: var(--ink-soft);
    font-size: 13.5px;
    font-weight: 600;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-small);
    border: 1px solid var(--hairline);
    background: var(--surface);
    font-size: 16px; /* Anything smaller makes iOS zoom on focus. */
}

.field textarea {
    min-height: 74px;
    resize: vertical;
}

.field__error {
    color: var(--danger);
    font-size: 13px;
}

.field__hint {
    color: var(--ink-muted);
    font-size: 12.5px;
}

.field--invalid input,
.field--invalid select {
    border-color: var(--danger);
}

/* A radio group that reads as a row of buttons. */
.choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.choice {
    position: relative;
}

.choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice span {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    border-radius: var(--radius-small);
    border: 1px solid var(--hairline);
    background: var(--surface);
    font-size: 14.5px;
    font-weight: 600;
}

.choice input:checked + span {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
    color: var(--accent);
}

.choice input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.button {
    display: block;
    width: 100%;
    padding: 14px;
    border: 0;
    border-radius: var(--radius-small);
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 16px;
    font-weight: 650;
    text-align: center;
    cursor: pointer;
}

.button--quiet {
    background: var(--ghost);
    color: var(--ink);
}

.button--danger {
    background: transparent;
    color: var(--danger);
    box-shadow: inset 0 0 0 1px var(--danger);
}

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

.form-error {
    padding: 11px 14px;
    border-radius: var(--radius-small);
    background: var(--surface);
    color: var(--danger);
    font-size: 14px;
}
