:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --bg: #090d18;
    --surface: rgba(20, 27, 45, .72);
    --border: rgba(255, 255, 255, .09);
    --text: #f4f7fb;
    --muted: #98a4ba;
    --mint: #72f1c2;
    --violet: #9d8cff;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 8%, rgba(114, 241, 194, .11), transparent 30rem),
        radial-gradient(circle at 88% 20%, rgba(157, 140, 255, .14), transparent 32rem),
        var(--bg);
}
a { color: inherit; }
button, .button { font: inherit; }
button {
    padding: .7rem 1rem;
    border: 1px solid var(--border);
    border-radius: .75rem;
    color: var(--text);
    background: rgba(255, 255, 255, .035);
    cursor: pointer;
    transition: transform .18s, background .18s;
}
button:hover:not(:disabled) { transform: translateY(-1px); background: rgba(255, 255, 255, .08); }
button:disabled { cursor: wait; opacity: .6; }
.container { width: min(1240px, calc(100% - 2.5rem)); margin: 0 auto; }
.nav { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding: 1.25rem 0; }
.brand { display: flex; align-items: center; gap: .7rem; font-weight: 750; letter-spacing: -.02em; text-decoration: none; }
.brand-mark {
    display: grid;
    width: 2.25rem;
    height: 2.25rem;
    place-items: center;
    border: 1px solid rgba(114, 241, 194, .3);
    border-radius: .75rem;
    color: var(--mint);
    background: rgba(114, 241, 194, .09);
}
.account { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.account > span { max-width: 240px; overflow: hidden; color: var(--muted); font-size: .85rem; text-overflow: ellipsis; white-space: nowrap; }
.account form { margin: 0; }
.nav-link { color: var(--text); font-size: .85rem; font-weight: 650; text-decoration: none; }
.nav-link:hover { color: var(--mint); }
.language-form { display: flex; align-items: center; gap: .3rem; }
.language-select { padding: .45rem .55rem; border: 1px solid var(--border); border-radius: .55rem; color: var(--text); background: #141b2d; font: inherit; font-size: .75rem; cursor: pointer; }
.ghost-button { padding: .55rem .9rem; border-radius: .65rem; }
.primary { border-color: var(--mint); color: #07130f; background: var(--mint); font-weight: 750; box-shadow: 0 10px 35px rgba(114, 241, 194, .12); }
.primary:hover:not(:disabled) { background: #8cf5ce; }
.eyebrow { color: var(--mint); font-size: .75rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.5rem 0 2rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .8rem; }

/* Landing page */
.hero { display: grid; grid-template-columns: 1.08fr .92fr; gap: 5rem; align-items: center; padding: 6rem 0 7rem; }
.hero .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    padding: .45rem .75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: #c5cede;
    background: rgba(255, 255, 255, .035);
    font-size: .78rem;
    letter-spacing: .04em;
}
.hero .eyebrow::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: var(--mint); box-shadow: 0 0 14px var(--mint); }
.hero h1 { margin: 1.5rem 0; font-size: clamp(2.8rem, 6vw, 5rem); line-height: 1.02; letter-spacing: -.055em; }
.hero h1 span { color: var(--mint); }
.hero-copy > p { max-width: 590px; margin: 0; color: var(--muted); font-size: 1.1rem; line-height: 1.75; }
.actions { display: flex; flex-wrap: wrap; gap: .85rem; margin-top: 2rem; }
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    padding: .85rem 1.2rem;
    border: 1px solid var(--border);
    border-radius: .8rem;
    font-weight: 700;
    text-decoration: none;
    transition: transform .18s, background .18s;
}
.button:hover { transform: translateY(-2px); }
.secondary { background: rgba(255, 255, 255, .035); }
.note { margin-top: 1.25rem; color: var(--muted); font-size: .8rem; }
.preview-wrap { position: relative; }
.preview-wrap::before { content: ""; position: absolute; inset: 12% 8%; border-radius: 50%; background: rgba(157, 140, 255, .24); filter: blur(70px); }
.preview {
    position: relative;
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: 1.5rem;
    background: linear-gradient(145deg, rgba(29, 38, 61, .94), rgba(14, 20, 35, .9));
    box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
    transform: rotate(2deg);
}
.preview-header { display: flex; align-items: center; justify-content: space-between; padding: .25rem .25rem 1.25rem; }
.preview-title { font-size: .9rem; font-weight: 700; }
.status { padding: .35rem .6rem; border-radius: 999px; color: var(--mint); background: rgba(114, 241, 194, .09); font-size: .7rem; }
.receipt-total { padding: 1.25rem; border: 1px solid var(--border); border-radius: 1rem; background: rgba(255, 255, 255, .035); }
.receipt-total span { color: var(--muted); font-size: .75rem; }
.receipt-total strong { display: block; margin-top: .35rem; font-size: 2rem; letter-spacing: -.04em; }
.receipt-row { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: .8rem; align-items: center; padding: 1rem .25rem; border-bottom: 1px solid var(--border); }
.receipt-row:last-child { border-bottom: 0; }
.item-icon { display: grid; width: 2.2rem; height: 2.2rem; place-items: center; border-radius: .65rem; background: rgba(157, 140, 255, .1); }
.item-name { font-size: .85rem; font-weight: 650; }
.item-category { margin-top: .2rem; color: var(--muted); font-size: .7rem; }
.item-price { font-size: .85rem; font-weight: 700; }
.features { padding: 0 0 6rem; }
.section-heading { max-width: 550px; margin-bottom: 2rem; }
.section-heading h2 { margin: 0 0 .7rem; font-size: 2rem; letter-spacing: -.035em; }
.section-heading p { margin: 0; color: var(--muted); line-height: 1.6; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.feature { padding: 1.5rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--surface); backdrop-filter: blur(16px); }
.feature-number { color: var(--mint); font-size: .75rem; font-weight: 800; letter-spacing: .1em; }
.feature h3 { margin: 1.25rem 0 .65rem; font-size: 1.05rem; }
.feature p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.65; }

/* Workspace layout */
.dashboard { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 1.5rem; padding: 2rem 0 4rem; }
.sidebar { align-self: start; padding: .75rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--surface); backdrop-filter: blur(16px); }
.sidebar-label { padding: .65rem .75rem; color: var(--muted); font-size: .68rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.sidebar-nav { display: grid; gap: .35rem; }
.sidebar-link { display: flex; align-items: center; gap: .75rem; padding: .8rem .85rem; border-radius: .7rem; color: var(--muted); font-size: .9rem; font-weight: 600; text-decoration: none; }
.sidebar-link:hover { color: var(--text); background: rgba(255, 255, 255, .045); }
.sidebar-link.active { color: var(--mint); background: rgba(114, 241, 194, .09); }
.sidebar-icon { width: 1.25rem; text-align: center; }
.content { min-width: 0; }
.content-header { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: end; justify-content: space-between; margin-bottom: 2rem; }
.content-header h1 { margin: .65rem 0 0; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.045em; }
.content-header .button { border-color: var(--mint); color: #07130f; background: var(--mint); box-shadow: 0 10px 35px rgba(114, 241, 194, .12); font-weight: 750; }

/* Receipt scanner */
.page-heading { max-width: 690px; padding: 0 0 2rem; }
.page-heading h1 { margin: .8rem 0 1rem; font-size: clamp(2.25rem, 5vw, 3.75rem); line-height: 1.08; letter-spacing: -.05em; }
.page-heading p { margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.7; }
.upload-panel { padding: 1.5rem; border: 1px solid var(--border); border-radius: 1.25rem; background: var(--surface); box-shadow: 0 20px 60px rgba(0, 0, 0, .18); backdrop-filter: blur(16px); }
.upload-label { display: block; flex: 0 0 100%; margin-bottom: 0; font-size: .85rem; font-weight: 700; }
#upload-form { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; }
input[type="file"] { flex: 1 1 300px; min-width: 0; padding: .55rem; border: 1px dashed rgba(255, 255, 255, .18); border-radius: .75rem; color: var(--muted); background: rgba(255, 255, 255, .025); font: inherit; font-size: .85rem; }
input[type="file"]::file-selector-button { margin-right: .8rem; padding: .55rem .75rem; border: 0; border-radius: .5rem; color: var(--text); background: rgba(255, 255, 255, .08); cursor: pointer; font: inherit; font-weight: 650; }
.upload-footer { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; margin-top: 1rem; }
.upload-hint { color: var(--muted); font-size: .75rem; }
.test-data button { padding: .45rem .65rem; border: 0; color: var(--muted); background: transparent; font-size: .8rem; text-decoration: underline; text-underline-offset: .2rem; }
#loading { margin-top: 1rem; color: var(--mint); font-size: .85rem; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
#result { margin: 1.5rem 0 4rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 1.25rem; background: var(--surface); box-shadow: 0 20px 60px rgba(0, 0, 0, .16); backdrop-filter: blur(16px); }
table { width: 100%; min-width: 900px; border-collapse: collapse; }
th, td { padding: 1rem; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); background: rgba(255, 255, 255, .025); font-size: .72rem; letter-spacing: .045em; text-transform: uppercase; }
td { font-size: .88rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, .018); }
th:nth-child(n+5), td:nth-child(n+5) { text-align: right; }
input[type="checkbox"] { width: 1rem; height: 1rem; margin: 0; accent-color: var(--mint); cursor: pointer; }
.item-input { width: 100%; min-width: 9rem; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: .55rem; color: var(--text); background: rgba(255, 255, 255, .045); font: inherit; font-size: .85rem; }
.item-input:hover { border-color: rgba(255, 255, 255, .2); }
.item-input:focus { border-color: var(--mint); outline: 2px solid rgba(114, 241, 194, .12); }
.item-number { min-width: 7rem; text-align: right; }
.total { margin: 1.25rem 0; font-size: 1.2rem; font-weight: 750; letter-spacing: -.02em; text-align: right; }
.save-controls { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-top: 1.25rem; }
#save-receipt { padding: .8rem 1.15rem; }
#save-result { flex: 1 1 300px; font-size: .85rem; }
.success { color: var(--mint); }
.usage { margin-top: 1.25rem; color: var(--muted); font-size: .75rem; line-height: 1.6; }
.error { padding: 1rem; border: 1px solid rgba(255, 113, 132, .35); border-radius: .75rem; color: #ff9dab; background: rgba(255, 113, 132, .07); }
.message { padding: 1.5rem; border: 1px solid var(--border); border-radius: 1rem; color: var(--muted); background: var(--surface); }

/* Dashboard statistics */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-card, .panel { border: 1px solid var(--border); background: var(--surface); backdrop-filter: blur(16px); }
.stat-card { padding: 1.25rem; border-radius: 1rem; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: var(--muted); font-size: .75rem; }
.stat-icon { display: grid; width: 2rem; height: 2rem; place-items: center; border-radius: .6rem; color: var(--mint); background: rgba(114, 241, 194, .08); }
.stat-value { display: block; margin: 1rem 0 .5rem; font-size: clamp(1.45rem, 3vw, 2rem); letter-spacing: -.04em; }
.stat-change { color: var(--mint); font-size: .72rem; }
.stat-change.neutral { color: var(--muted); }
.analytics-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(260px, .75fr); gap: 1rem; }
.panel { min-width: 0; padding: 1.5rem; border-radius: 1.25rem; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.panel-header h2 { margin: 0; font-size: 1rem; }
.panel-header p { margin: .35rem 0 0; color: var(--muted); font-size: .75rem; }
.panel-header > span { color: var(--muted); font-size: .75rem; }
.analytics-grid .panel-header { align-items: start; margin-bottom: 2rem; padding-bottom: 0; border-bottom: 0; }
.period { padding: .35rem .55rem; border: 1px solid var(--border); border-radius: .5rem; color: var(--muted); font-size: .7rem; white-space: nowrap; }
.chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1rem; align-items: end; height: 230px; padding-top: 1rem; }
.bar-group { display: grid; grid-template-rows: 1fr auto; gap: .75rem; align-items: end; height: 100%; text-align: center; }
.bar-track { display: flex; align-items: end; justify-content: center; height: 100%; border-bottom: 1px solid var(--border); }
.bar { width: min(32px, 70%); min-height: 8px; border-radius: .45rem .45rem 0 0; background: linear-gradient(180deg, var(--mint), rgba(114, 241, 194, .25)); }
.bar-label { color: var(--muted); font-size: .7rem; }
.bar-height-53 { height: 53%; }
.bar-height-58 { height: 58%; }
.bar-height-67 { height: 67%; }
.bar-height-72 { height: 72%; }
.bar-height-86 { height: 86%; }
.bar-height-100 { height: 100%; }
.category-list { display: grid; gap: 1.35rem; }
.category-top { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .55rem; font-size: .8rem; }
.category-top span:last-child { font-weight: 700; }
.category-meta { display: flex; justify-content: space-between; margin-bottom: .45rem; color: var(--muted); font-size: .7rem; }
.progress { height: 6px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, .06); }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--mint); }
.category:nth-child(2) .progress span { background: var(--violet); }
.category:nth-child(3) .progress span { background: #73b9ff; }
.category:nth-child(4) .progress span { background: #ffb870; }
.progress-width-32 { width: 32%; }
.progress-width-45 { width: 45%; }
.progress-width-58 { width: 58%; }
.progress-width-82 { width: 82%; }
.mock-note { margin-top: 1rem; color: var(--muted); font-size: .7rem; text-align: right; }

/* Saved receipts */
.receipt-row-clickable { cursor: pointer; }
.receipt-row-clickable:focus { outline: 2px solid var(--mint); outline-offset: -2px; }
.receipt-table-wrap { overflow-x: auto; }
.receipt-table { width: 100%; min-width: 0; border-collapse: collapse; }
.receipt-table th, .receipt-table td { padding: 1rem .5rem; border-bottom: 1px solid var(--border); text-align: left; }
.receipt-table th { color: var(--muted); font-size: .72rem; letter-spacing: .045em; text-transform: uppercase; }
.receipt-table th:nth-child(2), .receipt-table td:nth-child(2) { text-align: right; }
.receipt-table td { font-size: .9rem; }
.receipt-table td:nth-child(2) { font-weight: 700; }
.receipt-table td:last-child { color: var(--muted); font-size: .8rem; }
.receipt-table tbody tr:last-child td { border-bottom: 0; }
.receipt-table .receipt-day-heading th { padding-top: 1.25rem; color: var(--text); background: rgba(255, 255, 255, .04); }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .75rem; padding-top: 1.25rem; }
.pagination-status { margin-right: auto; color: var(--muted); font-size: .8rem; }
.pagination .button { padding: .55rem .85rem; font-size: .8rem; }
.empty-state { padding: 4rem 1rem; text-align: center; }
.empty-icon { display: grid; width: 3.5rem; height: 3.5rem; margin: 0 auto 1.25rem; place-items: center; border: 1px solid var(--border); border-radius: 1rem; color: var(--mint); background: rgba(114, 241, 194, .06); font-size: 1.4rem; }
.empty-state h3 { margin: 0 0 .65rem; font-size: 1.1rem; }
.empty-state p { max-width: 390px; margin: 0 auto; color: var(--muted); font-size: .9rem; line-height: 1.65; }
.receipt-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.receipt-meta > div { padding: 1.25rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--surface); }
.receipt-meta span { display: block; margin-bottom: .6rem; color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.receipt-meta strong { overflow-wrap: anywhere; font-size: 1.1rem; }
.receipt-items-wrap { margin-top: 1.25rem; box-shadow: none; }
.receipt-items-table th:nth-child(n+3), .receipt-items-table td:nth-child(n+3) { text-align: right; }

/* Recurrent payments */
.recurrent-table-wrap { margin-top: 1.25rem; box-shadow: none; }
.recurrent-table { min-width: 720px; }
.recurrent-table th:last-child, .recurrent-table td:last-child { color: var(--muted); white-space: nowrap; }
.recurrent-table .money-cell { text-align: right; white-space: nowrap; }
.empty-action { margin-top: 1.25rem; }
.recurrent-form-panel { max-width: 760px; }
.recurrent-form-panel h2 { margin: 0; font-size: 1.1rem; }
.recurrent-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.recurrent-form-error, .recurrent-form-actions { grid-column: 1 / -1; }
.recurrent-form-error:empty { display: none; }
.recurrent-form-actions { display: flex; justify-content: flex-start; }

/* Settings */
.settings-panel { max-width: 560px; }
.settings-panel h2 { margin: 0; font-size: 1.1rem; }
.settings-description { max-width: 480px; margin: .6rem 0 0; color: var(--muted); font-size: .9rem; line-height: 1.65; }
.form-grid { display: grid; gap: 1rem; }
.password-form, .recurrent-form { margin-top: 1.5rem; }
.form-field { display: grid; gap: .45rem; color: var(--muted); font-size: .8rem; font-weight: 650; }
.form-field input, .form-field select { width: 100%; min-height: 44px; padding: .75rem .85rem; border: 1px solid var(--border); border-radius: .65rem; color: var(--text); background: #141b2d; font: inherit; font-size: .95rem; }
.form-field input:hover, .form-field select:hover { border-color: rgba(255, 255, 255, .2); }
.form-field input:focus, .form-field select:focus { border-color: var(--mint); outline: 2px solid rgba(114, 241, 194, .12); }
.password-form .button { justify-self: start; }
.password-result:empty { display: none; }
.password-result .success { display: block; padding: 1rem; border: 1px solid rgba(114, 241, 194, .3); border-radius: .75rem; background: rgba(114, 241, 194, .07); }

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .analytics-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
    .hero { grid-template-columns: 1fr; gap: 3rem; padding: 4rem 0; }
    .preview { max-width: 440px; margin: 0 auto; transform: none; }
    .feature-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .nav { flex-wrap: wrap; gap: .75rem; }
    .account { margin-left: auto; }
    .nav-link { display: inline-flex; align-items: center; }
    button, .button, .nav-link, .sidebar-link, .language-select { min-height: 44px; }
    .dashboard { grid-template-columns: 1fr; padding-top: 1rem; }
    .sidebar { padding: .5rem; }
    .sidebar-label { display: none; }
    .sidebar-nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .sidebar-link { flex-direction: column; justify-content: center; gap: .35rem; padding: .65rem .35rem; text-align: center; line-height: 1.25; }
    .sidebar-icon { width: auto; }
    .panel-header { flex-wrap: wrap; }
    .table-wrap, .receipt-table-wrap { max-width: 100%; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
}
@media (max-width: 560px) {
    .container { width: min(1240px, calc(100% - 1.5rem)); }
    .brand { font-size: .9rem; }
    .account { width: 100%; justify-content: flex-end; gap: .55rem; }
    .account .language-form { margin-right: auto; }
    .account > span { display: none; }
    .language-select, input[type="file"], .item-input, .form-field input, .form-field select { font-size: 1rem; }
    .hero { gap: 2rem; padding: 3rem 0; }
    .hero h1 { font-size: clamp(2.35rem, 13vw, 2.8rem); }
    .hero-copy > p { font-size: 1rem; }
    .actions .button { width: 100%; }
    .preview { padding: .9rem; border-radius: 1rem; }
    .receipt-total { padding: 1rem; }
    .receipt-row { gap: .55rem; }
    .features { padding-bottom: 3rem; }
    .content-header { align-items: start; }
    .content-header .button { width: 100%; justify-content: center; }
    .page-heading { padding-top: 1rem; }
    .sidebar-link { font-size: .75rem; }
    .upload-panel { padding: 1rem; }
    #upload-form { align-items: stretch; }
    #upload-form input, #upload-form button { width: 100%; }
    .upload-footer { align-items: flex-start; }
    #save-receipt { width: 100%; }
    .total { text-align: left; }
    .stats-grid { grid-template-columns: 1fr; }
    .chart { gap: .45rem; height: 190px; }
    .panel { padding: 1rem; }
    .panel-header { gap: .65rem; }
    .empty-state { padding: 3rem .5rem; }
    .receipt-meta { grid-template-columns: 1fr; }
    .receipt-meta > div { padding: 1rem; }
    .receipt-items-table { min-width: 560px; }
    .recurrent-form { grid-template-columns: 1fr; }
    .recurrent-form-actions .button { width: 100%; }
    .password-form .button { width: 100%; }
    .pagination-status { width: 100%; margin-right: 0; text-align: center; }
    .pagination .button { flex: 1; }
    footer { flex-direction: column; }
}
