/* =========================================
   FIN-DASH
   Banknote paper, engraved ink, quiet UI.
========================================= */

@font-face {
    font-family: "Gendy";
    src: url("Gendy.otf") format("opentype");
    font-display: swap;
}

:root {
    --paper: #E8EDE9;
    --sheet: #F7F9F6;
    --ink: #10302E;
    --ink-2: #4C6360;
    --ink-3: #7F918D;
    --line: #D3DDD7;
    --in: #1E7B52;
    --out: #B2382C;
    --accent: #2C5F8A;

    --note: #12392F;
    --note-ink: #EAF2EC;
    --note-line: rgba(214, 236, 222, 0.16);

    --c-transfers: #2C5F8A;
    --c-bills: #7A5BA6;
    --c-food: #C98A1E;
    --c-shopping: #B04B7E;
    --c-transport: #3E8A57;
    --c-entertainment: #D0612E;
    --c-other: #8A9692;

    --display: "Gendy", "Instrument Sans", system-ui, sans-serif;
    --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    --radius-lg: 22px;
    --radius-md: 14px;
    --radius-sm: 9px;

    color-scheme: light;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #0D1A19;
        --sheet: #132523;
        --ink: #E4ECE8;
        --ink-2: #A3B6B1;
        --ink-3: #6F8580;
        --line: #24403C;
        --in: #55C390;
        --out: #EB7A66;
        --accent: #79A9D6;

        --note: #0F3A2D;
        --note-ink: #EAF2EC;
        --note-line: rgba(214, 236, 222, 0.13);

        --c-transfers: #5D93C6;
        --c-bills: #A386CF;
        --c-food: #E0A43C;
        --c-shopping: #D46FA2;
        --c-transport: #5DB177;
        --c-entertainment: #EC8350;
        --c-other: #8EA09B;

        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --paper: #0D1A19;
    --sheet: #132523;
    --ink: #E4ECE8;
    --ink-2: #A3B6B1;
    --ink-3: #6F8580;
    --line: #24403C;
    --in: #55C390;
    --out: #EB7A66;
    --accent: #79A9D6;
    --note: #0F3A2D;
    color-scheme: dark;
}

*,
*::before,
*::after {
    box-sizing: inherit;
    margin: 0;
    padding: 0;
}

html {
    scroll-padding-top: env(safe-area-inset-top, 0px);
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100%;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--body);
    font-size: 15px;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
    color: inherit;
}

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

[hidden] {
    display: none !important;
}

/* =========================================
   TOP BAR
========================================= */

.topbar {
    max-width: 1180px;
    margin: 0 auto;
    padding: 22px 20px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.wordmark {
    font-family: var(--display);
    font-size: 30px;
    letter-spacing: -0.5px;
    color: var(--ink);
    text-decoration: none;
    line-height: 1;
}

.topbar-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

@media (max-width: 520px) {
    .topbar-actions {
        width: 100%;
        flex-wrap: nowrap;
    }

    .topbar-actions .btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .topbar-actions .btn-solid {
        order: -1;
        flex: 1;
    }
}

/* =========================================
   BUTTONS
========================================= */

.btn {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .15s, border-color .15s;
}

.btn-solid {
    background: var(--ink);
    color: var(--paper);
}

.btn-solid:hover {
    background: var(--accent);
}

.btn-quiet {
    background: transparent;
    border-color: var(--line);
    color: var(--ink);
}

.btn-quiet:hover {
    border-color: var(--ink-3);
}

.btn-big {
    padding: 14px 26px;
    font-size: 16px;
}

.btn-wide {
    width: 100%;
    margin-top: 12px;
}

.link {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
}

/* =========================================
   EMPTY STATE
========================================= */

.empty {
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px;
}

.drop {
    background: var(--sheet);
    border: 1.5px dashed var(--line);
    border-radius: var(--radius-lg);
    padding: clamp(36px, 8vw, 80px) 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: border-color .15s, background-color .15s;
}

.drop.is-over {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 7%, var(--sheet));
}

.drop-art {
    margin-bottom: 26px;
}

.drop-note {
    width: 120px;
    height: 80px;
    fill: none;
    stroke: var(--ink-3);
    stroke-width: 2;
    stroke-linecap: round;
}

.drop h1 {
    font-family: var(--display);
    font-weight: 400;
    font-size: clamp(30px, 6vw, 52px);
    line-height: 1.05;
    letter-spacing: -0.5px;
    max-width: 14ch;
    margin-bottom: 16px;
}

.drop > p {
    max-width: 44ch;
    color: var(--ink-2);
}

.drop .btn-big {
    margin: 26px 0 18px;
}

.drop-hint {
    font-size: 13px;
}

.drop-privacy {
    margin-top: 14px;
    font-size: 13px;
    color: var(--in) !important;
    font-weight: 600;
}

/* =========================================
   LOADING
========================================= */

.loading {
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px;
}

.loading-card {
    background: var(--sheet);
    border-radius: var(--radius-lg);
    padding: 60px 24px;
    text-align: center;
}

.loading-bar {
    height: 6px;
    max-width: 320px;
    margin: 0 auto 16px;
    border-radius: 99px;
    background: var(--line);
    overflow: hidden;
}

.loading-bar span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--ink);
    border-radius: inherit;
    transition: width .3s ease;
}

.loading-card p {
    color: var(--ink-2);
}

/* =========================================
   DASHBOARD GRID
========================================= */

.dash {
    max-width: 1180px;
    margin: 0 auto;
    padding: 10px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Phones: one column, interleaved so the useful bits come first */
.col {
    display: contents;
}

.note { order: 0; }
.area-flow { order: 1; }
.area-budget { order: 2; }
.area-chart { order: 3; }
.area-insights { order: 4; }
.area-people { order: 5; }
.area-tx { order: 6; }
.area-goal { order: 7; }
.area-files { order: 8; }

/* Desktop: two independent columns, no gaps between panels */
@media (min-width: 900px) {
    .dash {
        display: grid;
        grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
        align-items: start;
    }

    .note {
        grid-column: 1 / -1;
    }

    .col {
        display: flex;
        flex-direction: column;
        gap: 16px;
        min-width: 0;
    }
}

/* =========================================
   PANELS
========================================= */

.panel {
    background: var(--sheet);
    border-radius: var(--radius-lg);
    padding: 20px;
    min-width: 0;
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.panel h2 {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.panel-meta {
    font-size: 13px;
    color: var(--ink-3);
    text-align: right;
}

/* =========================================
   BALANCE NOTE (the one bold thing)
========================================= */

.note {
    position: relative;
    overflow: hidden;
    border-radius: 28px;
    background: var(--note);
    color: var(--note-ink);
    padding: clamp(24px, 4vw, 40px);
    isolation: isolate;
}

.guilloche {
    position: absolute;
    right: -8%;
    top: 50%;
    width: min(620px, 120%);
    height: min(620px, 120%);
    transform: translateY(-50%);
    z-index: -1;
    stroke: var(--note-line);
    fill: none;
    stroke-width: .8;
    opacity: .85;
}

.note-label {
    font-size: 14px;
    opacity: .78;
}

.note-figure {
    font-family: var(--display);
    font-size: clamp(42px, 9vw, 84px);
    line-height: 1.02;
    letter-spacing: -1px;
    margin: 6px 0 6px;
    overflow-wrap: anywhere;
}

.note-period {
    font-size: 14px;
    opacity: .72;
    margin-bottom: 26px;
}

.note-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 34px;
    border-top: 1px solid rgba(234, 242, 236, .18);
    padding-top: 18px;
}

.note-stats dt {
    font-size: 13px;
    opacity: .72;
}

.note-stats dd {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.note-stats .is-in { color: #8FE0B5; }
.note-stats .is-out { color: #FFB3A3; }

/* =========================================
   WHERE IT WENT
========================================= */

.flow-strip {
    display: flex;
    height: 54px;
    border-radius: var(--radius-md);
    overflow: hidden;
    gap: 3px;
    margin-bottom: 18px;
    background: var(--line);
}

.flow-strip span {
    display: block;
    height: 100%;
    min-width: 4px;
}

.flow-legend {
    list-style: none;
    display: grid;
    gap: 10px;
}

.flow-legend li {
    display: grid;
    grid-template-columns: 12px 1fr auto auto;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.swatch {
    width: 12px;
    height: 12px;
    border-radius: 4px;
}

.flow-legend .pct {
    color: var(--ink-3);
    font-size: 13px;
    min-width: 3.5ch;
    text-align: right;
}

.flow-legend .amt {
    font-weight: 600;
    text-align: right;
}

/* =========================================
   CHART
========================================= */

.chart-key {
    display: flex;
    gap: 14px;
    font-size: 13px;
    color: var(--ink-2);
}

.key::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: -1px;
}

.key-in::before { background: var(--in); }
.key-out::before { background: var(--out); }

.chart {
    overflow-x: auto;
    padding-bottom: 4px;
}

.chart svg {
    display: block;
    min-width: 100%;
}

.chart .bar {
    cursor: pointer;
}

.chart .day:hover .hit,
.chart .day.is-picked .hit {
    fill: var(--line);
}

.chart-tip {
    font-size: 13px;
    color: var(--ink-2);
    margin-top: 10px;
    min-height: 1.5em;
}

/* =========================================
   BUDGET + GOAL
========================================= */

.meter {
    height: 12px;
    border-radius: 99px;
    background: var(--line);
    overflow: hidden;
    margin: 12px 0 10px;
}

.meter span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--in);
    transition: width .5s ease;
}

.meter.is-warn span { background: var(--c-food); }
.meter.is-over span { background: var(--out); }

.big-line {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.4px;
}

.big-line small {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-2);
    letter-spacing: 0;
}

.muted {
    color: var(--ink-2);
    font-size: 14px;
}

.inline-form {
    display: grid;
    gap: 6px;
    margin-top: 14px;
}

.inline-form label {
    font-size: 13px;
    color: var(--ink-2);
    margin-top: 6px;
}

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

.inline-form input,
.tx-tools input {
    width: 100%;
    min-width: 0;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 16px;
}

/* =========================================
   INSIGHTS
========================================= */

.insights {
    list-style: none;
    display: grid;
    gap: 14px;
}

.insights li {
    padding-left: 14px;
    border-left: 3px solid var(--line);
    font-size: 14px;
    color: var(--ink-2);
}

.insights strong {
    display: block;
    color: var(--ink);
    font-size: 15px;
}

/* =========================================
   PEOPLE
========================================= */

.people {
    list-style: none;
    display: grid;
    gap: 12px;
}

.people li {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 700;
    background: color-mix(in srgb, var(--accent) 16%, var(--sheet));
    color: var(--accent);
}

.people .who {
    min-width: 0;
}

.people .who strong,
.tx .tx-name {
    display: block;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.people .who span {
    font-size: 13px;
    color: var(--ink-3);
}

.people .amt {
    font-weight: 600;
}

/* =========================================
   TRANSACTIONS
========================================= */

.tx-tools {
    display: grid;
    gap: 10px;
    margin-bottom: 8px;
}

.segmented {
    display: flex;
    gap: 4px;
    background: var(--paper);
    border-radius: 999px;
    padding: 4px;
    overflow-x: auto;
}

.segmented button {
    flex: 1 0 auto;
    border: none;
    background: transparent;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
}

.segmented button.is-active {
    background: var(--sheet);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(16, 48, 46, .12);
}

.tx-day {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-3);
    padding: 16px 0 6px;
    display: flex;
    justify-content: space-between;
}

.tx {
    display: grid;
    grid-template-columns: 10px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--line);
}

.tx-day + .tx {
    border-top: none;
}

.tx .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.tx-info {
    min-width: 0;
}

.tx-sub {
    font-size: 13px;
    color: var(--ink-3);
}

.tx-amt {
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.tx-amt.is-in { color: var(--in); }
.tx-amt.is-internal { color: var(--ink-3); font-weight: 500; }

.tx-empty {
    padding: 24px 0;
    color: var(--ink-2);
    text-align: center;
}

/* =========================================
   STATEMENTS LIST
========================================= */

.files {
    list-style: none;
    display: grid;
    gap: 10px;
}

.files li {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
}

.files strong {
    display: block;
    font-weight: 600;
}

.files span {
    font-size: 13px;
    color: var(--ink-3);
    overflow-wrap: anywhere;
}

.files button {
    background: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
    color: var(--ink-2);
}

/* =========================================
   TOAST + FOOTER
========================================= */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    width: min(520px, calc(100% - 32px));
    background: var(--ink);
    color: var(--paper);
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    z-index: 10;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

.foot {
    max-width: 1180px;
    margin: 10px auto 0;
    padding: 10px 20px 36px;
    font-size: 13px;
    color: var(--ink-3);
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}
