/* MoneyTrack dashboard — minimal typographic UI.
   Everything lives in this file on purpose: the CSP in auth.php sets
   style-src 'self', so inline <style> blocks and style="" attributes are
   blocked. default-src 'self' rules out webfonts and data: background images
   too, so this leans on system fonts and CSS-drawn shapes only. */

/* ---- tokens ------------------------------------------------------------ */

:root {
    color-scheme: light dark;

    --bg: #fdfdfc;
    --text: #17171a;
    --muted: #6b6b73;
    --faint: #97979f;
    --rule: #e4e4e8;
    --field: #f4f4f3;
    --accent: #0b5cd5;
    --accent-ink: #fff;
    --danger: #c02b1d;

    --gutter: 1.25rem;
    --measure: 36rem;

    --pad-left: max(var(--gutter), env(safe-area-inset-left));
    --pad-right: max(var(--gutter), env(safe-area-inset-right));
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e0e10;
        --text: #f0f0f2;
        --muted: #9b9ba4;
        --faint: #6d6d77;
        --rule: #26262b;
        --field: #1a1a1d;
        --accent: #7aa9ff;
        --accent-ink: #0e0e10;
        --danger: #ff6f61;
    }
}

/* ---- base -------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 1.0625rem/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    -webkit-text-size-adjust: 100%;
    padding-bottom: calc(3rem + env(safe-area-inset-bottom));
}

a { color: var(--accent); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---- nav --------------------------------------------------------------- */

nav {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    padding-top: env(safe-area-inset-top);
}

.nav-inner {
    display: flex;
    gap: 1.5rem;
    max-width: var(--measure);
    margin-inline: auto;
    padding: .85rem var(--pad-right) .85rem var(--pad-left);
    overflow-x: auto;
    scrollbar-width: none;
}

.nav-inner::-webkit-scrollbar { display: none; }

nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: .9375rem;
    font-weight: 500;
    white-space: nowrap;
}

nav a:hover { color: var(--text); }

nav a[aria-current="page"] {
    color: var(--text);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: .45em;
}

/* ---- page shell -------------------------------------------------------- */

main {
    max-width: var(--measure);
    margin-inline: auto;
    padding-left: var(--pad-left);
    padding-right: var(--pad-right);
}

h1 {
    font-size: clamp(1.5rem, 1.25rem + 1.1vw, 1.9rem);
    font-weight: 600;
    letter-spacing: -.021em;
    line-height: 1.2;
    margin: 1.6rem 0 1.2rem;
}

/* Section eyebrow — carries hierarchy without boxes. */
h2 {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--faint);
    margin: 2.6rem 0 1rem;
    padding-bottom: .55rem;
    border-bottom: 1px solid var(--rule);
}

.lede { color: var(--muted); margin: -.6rem 0 1.4rem; }
.muted { color: var(--muted); }
.err { color: var(--danger); font-weight: 500; margin: 0 0 1rem; }
.empty { color: var(--faint); margin: 0; padding: 1.5rem 0; }

ul { list-style: none; margin: 0; padding: 0; }

/* ---- amounts ----------------------------------------------------------- */

.amount {
    font-variant-numeric: tabular-nums;
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -.02em;
    white-space: nowrap;
}

/* ---- balances / accounts rows ------------------------------------------ */

.rows li {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 1rem;
    row-gap: .2rem;
    padding: .85rem 0;
    border-bottom: 1px solid var(--rule);
}

.rows .who { grid-column: 1 / -1; }
.rows .who strong { font-weight: 600; }
.rows .amount { grid-column: 1; }
.rows .settle { grid-column: 2; justify-self: end; }

.settle {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--accent);
    font-size: .9375rem;
    font-weight: 500;
    text-decoration: none;
}

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

/* One line once there's room for it. */
@media (min-width: 34rem) {
    .rows li { grid-template-columns: 1fr auto auto; row-gap: 0; }
    .rows .who { grid-column: 1; }
    .rows .amount { grid-column: 2; }
    .rows .settle { grid-column: 3; margin-left: .75rem; }
}

/* ---- transaction history ----------------------------------------------- */

.txs li { border-bottom: 1px solid var(--rule); }

.txs summary {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 1rem;
    row-gap: .15rem;
    padding: .85rem 0;
    cursor: pointer;
    list-style: none;
}

.txs summary::-webkit-details-marker { display: none; }
.txs summary::marker { content: ""; }

.txs .tx-who { grid-column: 1; }
.txs .tx-who em { color: var(--muted); font-style: normal; }
.txs .amount { grid-column: 2; justify-self: end; }
.txs .date { grid-column: 1; color: var(--faint); font-size: .85rem; }

/* Disclosure chevron, drawn from borders (no image budget under this CSP). */
.txs summary::after {
    content: "";
    grid-column: 2;
    justify-self: end;
    width: .45rem;
    height: .45rem;
    border-right: 1.5px solid var(--faint);
    border-bottom: 1.5px solid var(--faint);
    transform: translateY(-2px) rotate(45deg);
    transition: transform .15s ease;
}

.txs details[open] summary::after { transform: translateY(1px) rotate(-135deg); }

.tag {
    display: inline-block;
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    border: 1px solid var(--rule);
    border-radius: 999px;
    padding: .05rem .45rem;
    white-space: nowrap;
}

.tx-detail {
    display: grid;
    gap: .45rem;
    padding: .8rem 0 1.1rem;
    font-size: .9375rem;
    color: var(--muted);
    border-top: 1px dashed var(--rule);
}

.tx-detail strong { color: var(--text); font-weight: 600; }
.tx-detail .raw { font-style: italic; }

.tx-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-top: .35rem;
}

.tx-actions form { margin: 0; }

/* ---- forms ------------------------------------------------------------- */

.card {
    display: grid;
    gap: 1.05rem;
    margin: 0 0 1rem;
}

label {
    display: grid;
    gap: .4rem;
    font-size: .8125rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--muted);
}

input, select {
    font: inherit;
    font-size: 1rem; /* ≥16px keeps iOS from zooming the page on focus */
    color: var(--text);
    background: var(--field);
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: .7rem .8rem;
    min-height: 44px;
    width: 100%;
}

input::placeholder { color: var(--faint); }

button {
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-ink);
    background: var(--accent);
    border: 0;
    border-radius: 10px;
    padding: .75rem 1.3rem;
    min-height: 44px;
    cursor: pointer;
}

button:hover { filter: brightness(1.1); }
button:active { transform: translateY(1px); }

.card > button { width: 100%; }

@media (min-width: 34rem) {
    .card > button { width: auto; justify-self: start; }
}

button.link {
    background: none;
    color: var(--danger);
    font-weight: 500;
    font-size: .9375rem;
    padding: 0;
    width: auto;
    min-height: 44px;
    border-radius: 0;
}

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

.search {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin-bottom: .6rem;
}

.search input { flex: 1 1 12rem; min-width: 0; width: auto; }
.search button { flex: 0 0 auto; }

/* Parsed-transaction confirmation block on the Add page. */
.preview {
    display: grid;
    gap: 1rem;
    background: var(--field);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 1.1rem;
}

.preview p { margin: 0; }
.preview .card { margin: 0; }

.cancel {
    justify-self: start;
    font-size: .9375rem;
    color: var(--muted);
}

/* ---- login ------------------------------------------------------------- */

.login-wrap {
    min-height: 100svh;
    display: grid;
    place-items: center;
    padding: 2rem var(--pad-right) 2rem var(--pad-left);
}

.login { width: 100%; max-width: 21rem; }
.login h1 { margin: 0; }
.login .lede { margin: -.5rem 0 .4rem; }
.login button { width: 100%; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}
