:root {
    --bg: #f3f2ed;
    --surface: #ffffff;
    --surface-soft: #faf9f5;
    --ink: #18212f;
    --ink-soft: #354052;
    --muted: #667080;
    --muted-dark: #5e687a;
    --line: #e7e4dc;
    --line-strong: #d9d5ca;
    --lime: #dceb8b;
    --lime-deep: #c9dc6a;
    --green: #2e7d63;
    --red: #c45349;
    --amber: #e8a33d;
    --blue: #5c7cfa;
    --purple: #9b6bcf;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 12px;
    --shadow-sm: 0 2px 8px rgba(24, 33, 47, 0.04);
    --shadow-md: 0 18px 50px rgba(24, 33, 47, 0.08);
    --shadow-lg: 0 30px 80px rgba(10, 17, 29, 0.22);
    --container: 1280px;
    --header-height: 78px;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 88% 0%, rgba(220, 235, 139, 0.25), transparent 28rem),
        radial-gradient(circle at 0% 18%, rgba(232, 163, 61, 0.07), transparent 24rem),
        var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", "Aptos", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
}

svg {
    display: block;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.container {
    width: min(var(--container), calc(100% - 48px));
    margin-inline: auto;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.muted {
    color: #9aa1ac;
}

body.modal-open {
    overflow: hidden;
}

/* Header */

.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    border-bottom: 1px solid rgba(217, 213, 202, 0.72);
    background: rgba(247, 246, 241, 0.86);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.header-inner {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 32px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    text-decoration: none;
    flex-shrink: 0;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: var(--ink);
    color: var(--lime);
    box-shadow: 0 8px 20px rgba(24, 33, 47, 0.16);
}

.brand-mark svg {
    width: 25px;
    height: 25px;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.12;
}

.brand-copy strong {
    font-size: 17px;
    letter-spacing: -0.025em;
}

.brand-copy small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.64);
}

.main-nav a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 13px;
    border-radius: 10px;
    color: var(--muted-dark);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.main-nav a:hover {
    background: #f2f1ec;
    color: var(--ink);
}

.main-nav a.is-active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 2px 7px rgba(24, 33, 47, 0.08);
}

.main-nav svg {
    width: 17px;
    height: 17px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.header-user {
    max-width: 170px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.64);
    color: var(--muted-dark);
    text-decoration: none;
    font-size: 12px;
    font-weight: 650;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.header-user:hover,
.header-user.is-active {
    border-color: var(--line-strong);
    background: var(--surface);
    color: var(--ink);
}

.header-user-mark {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #e9f4ef;
    color: var(--green);
}

.header-user-mark svg {
    width: 14px;
    height: 14px;
}

.header-username {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-logout {
    margin: 0;
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 17px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--ink);
    text-decoration: none;
    font-size: 13px;
    font-weight: 650;
    line-height: 1;
    cursor: pointer;
    transition:
        background-color 160ms ease,
        border-color 160ms ease,
        color 160ms ease,
        transform 120ms ease,
        box-shadow 160ms ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn svg {
    width: 17px;
    height: 17px;
}

.btn-primary {
    background: var(--ink);
    color: #fff;
    box-shadow: 0 8px 18px rgba(24, 33, 47, 0.14);
}

.btn-primary:hover {
    background: #0f1724;
    box-shadow: 0 10px 24px rgba(24, 33, 47, 0.19);
}

.btn-secondary {
    border-color: var(--line-strong);
    background: var(--surface);
    color: var(--ink);
}

.btn-secondary:hover {
    border-color: #c5c0b4;
    background: #fff;
}

.btn-ghost {
    color: var(--muted-dark);
}

.btn-ghost:hover {
    background: #f3f2ed;
    color: var(--ink);
}

.btn-small {
    min-height: 36px;
    padding: 8px 13px;
    font-size: 12px;
    border-radius: 10px;
}

.btn-small svg {
    width: 15px;
    height: 15px;
}

.icon-button {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.icon-button svg {
    width: 18px;
    height: 18px;
}

.icon-button:hover {
    border-color: var(--line);
    background: var(--surface);
    color: var(--ink);
}

.icon-button-danger:hover {
    border-color: #f0d8d5;
    background: #fff5f4;
    color: var(--red);
}

.text-link {
    color: var(--green);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

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

/* Page layout */

.page {
    padding-top: 45px;
    padding-bottom: 76px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 30px;
}

.eyebrow {
    margin-bottom: 8px;
    color: var(--green);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.15em;
    line-height: 1.2;
    text-transform: uppercase;
}

.page-heading h1 {
    margin-bottom: 8px;
    font-size: clamp(34px, 4vw, 48px);
    font-weight: 700;
    letter-spacing: -0.05em;
    line-height: 1.02;
}

.page-subtitle {
    margin-bottom: 0;
    color: var(--muted-dark);
    font-size: 15px;
}

.heading-side {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.today-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--muted-dark);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.today-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(46, 125, 99, 0.12);
}

.heading-add {
    display: none;
}

/* Flash messages */

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 22px;
}

.flash {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 13px 15px;
    border: 1px solid;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 550;
    box-shadow: var(--shadow-sm);
    animation: flash-in 220ms ease both;
}

.flash-success {
    border-color: #cfe5da;
    background: #f2faf6;
    color: #205f4b;
}

.flash-error {
    border-color: #f1d3cf;
    background: #fff6f5;
    color: #963e37;
}

.flash-icon {
    width: 25px;
    height: 25px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.7);
}

.flash-icon svg {
    width: 16px;
    height: 16px;
}

.flash-close {
    width: 28px;
    height: 28px;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: currentColor;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.6;
}

.flash-close:hover {
    background: rgba(255, 255, 255, 0.7);
    opacity: 1;
}

@keyframes flash-in {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stats */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    position: relative;
    min-width: 0;
    padding: 22px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow-sm);
}

.stat-card-dark {
    border-color: var(--ink);
    background:
        radial-gradient(circle at 98% 0%, rgba(220, 235, 139, 0.19), transparent 10rem),
        var(--ink);
    color: #fff;
    box-shadow: 0 18px 38px rgba(24, 33, 47, 0.16);
}

.stat-card-dark::after {
    content: "";
    position: absolute;
    right: -34px;
    bottom: -58px;
    width: 150px;
    height: 150px;
    border: 1px solid rgba(220, 235, 139, 0.12);
    border-radius: 50%;
}

.stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.stat-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.stat-card-dark .stat-label {
    color: #aab3c1;
}

.stat-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: #f1f2ec;
    color: var(--ink-soft);
}

.stat-icon svg {
    width: 19px;
    height: 19px;
}

.stat-card-dark .stat-icon {
    background: rgba(255, 255, 255, 0.09);
    color: var(--lime);
}

.stat-icon-green {
    background: #e9f4ef;
    color: var(--green);
}

.stat-icon-blue {
    background: #edf0ff;
    color: #506fdb;
}

.stat-icon-amber {
    background: #fbf3e6;
    color: #c98420;
}

.stat-value {
    display: block;
    overflow: hidden;
    margin-bottom: 7px;
    font-size: clamp(25px, 2.3vw, 32px);
    font-weight: 700;
    letter-spacing: -0.045em;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-value small {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--muted);
}

.stat-card-dark .stat-value small {
    color: #aab3c1;
}

.stat-meta {
    color: var(--muted);
    font-size: 11.5px;
}

.stat-card-dark .stat-meta {
    color: #aab3c1;
}

/* Dashboard panels */

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 342px;
    gap: 24px;
    align-items: start;
}

.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.expenses-panel {
    min-width: 0;
    overflow: hidden;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 23px 25px 0;
}

.panel-heading h2 {
    margin-bottom: 3px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.panel-heading p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 12px;
}

.side-stack {
    display: grid;
    gap: 18px;
}

.side-stack .panel-heading {
    padding: 21px 21px 0;
}

.panel-badge {
    padding: 6px 9px;
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

/* Filters */

.filters {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 9px;
    padding: 19px 25px 18px;
}

.filter-field {
    position: relative;
    min-width: 0;
}

.filter-field label {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 750;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.filter-search {
    flex: 1 1 170px;
}

.filter-search label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.filter-search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    width: 16px;
    height: 16px;
    color: #697383;
    transform: translateY(-50%);
    pointer-events: none;
}

.filter-search input {
    padding-left: 36px;
}

.filter-field select {
    min-width: 148px;
}

.filters input,
.filters select {
    width: 100%;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    background: var(--surface-soft);
    color: var(--ink);
    font-size: 12px;
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.filters input {
    padding: 0 11px;
}

.filters select {
    padding: 0 30px 0 10px;
    cursor: pointer;
}

.filters input:focus,
.filters select:focus {
    border-color: #a4b279;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(201, 220, 106, 0.2);
}

.filter-dates {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.filter-dates .filter-field {
    flex: 1 1 116px;
}

.filter-dash {
    padding-bottom: 10px;
    color: #697383;
    font-size: 11px;
}

.filter-actions {
    display: flex;
    gap: 2px;
    margin-left: auto;
}

.filter-actions .btn {
    white-space: nowrap;
}

/* Expense table */

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.expense-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.expense-table th {
    padding: 10px 16px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: #fbfaf7;
    color: #5e6878;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.expense-table th:first-child,
.expense-table td:first-child {
    padding-left: 25px;
}

.expense-table th:last-child,
.expense-table td:last-child {
    padding-right: 25px;
}

.expense-table td {
    padding: 15px 16px;
    border-bottom: 1px solid #efede7;
    vertical-align: middle;
}

.expense-table tbody tr {
    transition: background-color 140ms ease;
}

.expense-table tbody tr:hover {
    background: #fcfbf8;
}

.expense-table tbody tr:last-child td {
    border-bottom: 0;
}

.align-right {
    text-align: right !important;
}

.table-date {
    color: var(--muted-dark);
    font-size: 12px;
    font-weight: 550;
    white-space: nowrap;
}

.expense-description {
    display: block;
    max-width: 380px;
    margin-bottom: 5px;
    overflow: hidden;
    color: var(--ink);
    font-size: 13px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.plate-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: #fbfaf7;
    color: var(--ink-soft);
    font-family: Consolas, "SFMono-Regular", monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.category-dot {
    width: 7px;
    height: 7px;
    display: inline-block;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--category-color, #8b929d);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--category-color, #8b929d) 16%, white);
}

.distance-value {
    color: var(--muted-dark);
    font-size: 12px;
    white-space: nowrap;
}

.amount {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.015em;
    white-space: nowrap;
}

.actions-cell {
    width: 84px;
}

.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1px;
    opacity: 0.6;
    transition: opacity 150ms ease;
}

.expense-table tr:hover .row-actions,
.row-actions:focus-within {
    opacity: 1;
}

.row-actions form {
    margin: 0;
}

.table-note {
    padding: 12px 25px 18px;
    margin: 0;
    color: var(--muted);
    font-size: 11px;
}

/* Empty states */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 56px 24px 60px;
    text-align: center;
}

.empty-icon {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    margin-bottom: 17px;
    border-radius: 18px;
    background: #f2f1eb;
    color: #7c8575;
}

.empty-icon svg {
    width: 29px;
    height: 29px;
}

.empty-state h3,
.empty-state h2 {
    margin-bottom: 6px;
    font-size: 18px;
    letter-spacing: -0.02em;
}

.empty-state p {
    max-width: 340px;
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 13px;
}

.empty-state-page {
    padding-block: 75px;
}

/* Monthly chart */

.chart-panel,
.breakdown-panel {
    overflow: hidden;
}

.bar-chart {
    height: 190px;
    display: flex;
    align-items: stretch;
    gap: 7px;
    padding: 14px 20px 18px;
}

.chart-column {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
}

.chart-amount {
    max-width: 100%;
    overflow: hidden;
    color: var(--muted);
    font-size: 9px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-track {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: flex-end;
    padding-inline: 3px;
    border-radius: 7px;
    background:
        linear-gradient(to top, rgba(24, 33, 47, 0.025), transparent),
        repeating-linear-gradient(to top, transparent 0, transparent 37px, rgba(24, 33, 47, 0.045) 38px);
}

.chart-bar {
    width: 100%;
    min-height: 0;
    border-radius: 7px 7px 4px 4px;
    background: var(--lime);
    transition: height 300ms ease, background-color 160ms ease;
}

.chart-column:hover .chart-bar {
    background: var(--lime-deep);
}

.chart-column.is-current .chart-bar {
    background: var(--ink);
}

.chart-column.is-current .chart-amount {
    color: var(--ink);
    font-weight: 750;
}

.chart-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 650;
}

.chart-column.is-current .chart-label {
    color: var(--ink);
    font-weight: 750;
}

.chart-empty {
    padding: 0 22px 20px;
    margin: -6px 0 0;
    color: var(--muted);
    font-size: 11px;
}

/* Category breakdown */

.breakdown-list {
    display: grid;
    gap: 15px;
    padding: 20px 21px 23px;
}

.breakdown-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 7px;
}

.breakdown-name {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    overflow: hidden;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.breakdown-value {
    color: var(--ink);
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

.progress-track {
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #f0eee8;
}

.progress-bar {
    display: block;
    height: 100%;
    min-width: 2px;
    border-radius: inherit;
    background: var(--category-color, var(--green));
}

.mini-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    padding: 38px 20px 42px;
    color: var(--muted);
    text-align: center;
}

.mini-empty-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--surface-soft);
    color: #919a87;
}

.mini-empty-icon svg {
    width: 21px;
    height: 21px;
}

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

/* Modal */

.modal {
    width: min(650px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100vh - 32px);
    padding: 0;
    border: 0;
    border-radius: 26px;
    background: transparent;
    color: var(--ink);
    overflow: visible;
}

.modal::backdrop {
    background: rgba(12, 19, 31, 0.52);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

.modal[open] {
    animation: modal-in 180ms cubic-bezier(0.2, 0.85, 0.3, 1) both;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-card {
    max-height: calc(100vh - 32px);
    padding: 30px;
    overflow-y: auto;
    border-radius: 26px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.modal-card-small {
    max-width: 540px;
    margin-inline: auto;
}

.modal-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.modal-heading h2 {
    margin-bottom: 6px;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.15;
}

.modal-heading p:last-child {
    max-width: 430px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 12.5px;
}

.modal-close {
    margin: -4px -5px 0 0;
}

.form-alert {
    padding: 13px 15px;
    margin-bottom: 20px;
    border: 1px solid #f1d3cf;
    border-radius: 12px;
    background: #fff6f5;
    color: #963e37;
    font-size: 12px;
}

.form-alert strong {
    display: block;
    margin-bottom: 5px;
}

.form-alert ul {
    padding-left: 17px;
    margin: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 17px;
}

.field {
    min-width: 0;
}

.field-full {
    grid-column: 1 / -1;
}

.field label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.field label span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
}

.field input,
.field select {
    width: 100%;
    height: 46px;
    padding: 0 13px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    outline: none;
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field select {
    padding-right: 32px;
    cursor: pointer;
}

.field input::placeholder {
    color: #a7adb6;
}

.field input:focus,
.field select:focus {
    border-color: #9caf5d;
    box-shadow: 0 0 0 3px rgba(201, 220, 106, 0.24);
}

.input-prefix,
.input-suffix {
    position: relative;
}

.input-prefix span,
.input-suffix span {
    position: absolute;
    top: 50%;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    transform: translateY(-50%);
    pointer-events: none;
}

.input-prefix span {
    left: 14px;
}

.input-prefix input {
    padding-left: 32px;
}

.input-suffix span {
    right: 14px;
}

.input-suffix input {
    padding-right: 42px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding-top: 24px;
    margin-top: 25px;
    border-top: 1px solid var(--line);
}

.form-note {
    max-width: 280px;
    margin: 0;
    color: var(--muted);
    font-size: 10.5px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

/* Color field */

.color-field {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 6px 12px 6px 6px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    background: var(--surface);
}

.color-field input[type="color"] {
    width: 42px;
    height: 34px;
    flex: 0 0 auto;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

.color-field input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-field input[type="color"]::-webkit-color-swatch {
    border: 0;
    border-radius: 7px;
}

.color-value {
    color: var(--ink-soft);
    font-family: Consolas, "SFMono-Regular", monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.field-hint {
    margin-left: auto;
    color: var(--muted);
    font-size: 10px;
}

/* Categories page */

.category-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    padding: 26px 29px;
    margin-bottom: 24px;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 82% 40%, rgba(220, 235, 139, 0.13), transparent 14rem),
        var(--ink);
    color: #fff;
    box-shadow: 0 20px 42px rgba(24, 33, 47, 0.14);
}

.category-summary-intro {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    max-width: 520px;
}

.summary-mark {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--lime);
}

.summary-mark svg {
    width: 25px;
    height: 25px;
}

.category-summary-intro strong {
    display: block;
    margin-bottom: 3px;
    font-size: 15px;
    letter-spacing: -0.015em;
}

.category-summary-intro p {
    margin: 0;
    color: #aeb7c4;
    font-size: 11.5px;
    line-height: 1.55;
}

.category-summary-stats {
    display: flex;
    flex: 0 0 auto;
}

.category-summary-stats > div {
    min-width: 102px;
    padding-inline: 23px;
    border-left: 1px solid rgba(255, 255, 255, 0.11);
}

.category-summary-stats > div:first-child {
    border-left: 0;
}

.category-summary-stats strong {
    display: block;
    margin-bottom: 2px;
    overflow: hidden;
    color: var(--lime);
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.04em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-summary-stats span {
    color: #9ca7b6;
    font-size: 9.5px;
    font-weight: 650;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    white-space: nowrap;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.category-card {
    position: relative;
    padding: 21px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-top: 3px solid var(--category-color);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.category-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.category-card-head {
    display: flex;
    align-items: flex-start;
    gap: 11px;
}

.category-color-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 12px;
    background: color-mix(in srgb, var(--category-color) 14%, white);
}

.category-color-mark::after {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--category-color);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--category-color) 12%, white);
}

.category-card-title {
    min-width: 0;
    flex: 1;
    padding-top: 1px;
}

.category-card-title h2 {
    margin-bottom: 1px;
    overflow: hidden;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-card-title p {
    margin: 0;
    color: var(--muted);
    font-size: 10.5px;
}

.category-card-actions {
    display: flex;
    gap: 0;
    margin: -5px -6px 0 0;
    opacity: 0.65;
    transition: opacity 150ms ease;
}

.category-card:hover .category-card-actions,
.category-card-actions:focus-within {
    opacity: 1;
}

.category-card-actions form {
    margin: 0;
}

.icon-button {
    text-decoration: none;
}

.category-card-spend {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-top: 22px;
}

.category-card-spend strong {
    overflow: hidden;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.04em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-card-spend span {
    color: var(--muted);
    font-size: 9.5px;
    white-space: nowrap;
}

.category-share {
    height: 5px;
    margin-top: 11px;
    overflow: hidden;
    border-radius: 999px;
    background: #f0eee8;
}

.category-share span {
    display: block;
    height: 100%;
    min-width: 2px;
    border-radius: inherit;
    background: var(--category-color);
}

.category-add-card {
    min-height: 174px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 24px;
    border: 1px dashed #cfcbc0;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.45);
    color: var(--muted-dark);
    text-align: center;
    cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.category-add-card:hover {
    border-color: #aeb97a;
    background: rgba(220, 235, 139, 0.12);
    color: var(--ink);
}

.category-add-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    margin-bottom: 7px;
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.category-add-icon svg {
    width: 19px;
    height: 19px;
}

.category-add-card strong {
    font-size: 13px;
}

.category-add-card > span:last-child {
    max-width: 200px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.5;
}

/* Sign-in pages */

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.auth-shell {
    width: min(460px, 100%);
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
    color: var(--ink);
    text-decoration: none;
}

.auth-brand .brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 15px;
}

.auth-brand .brand-copy strong {
    font-size: 18px;
}

.auth-card {
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.auth-card h1 {
    margin-bottom: 8px;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.045em;
    line-height: 1.08;
}

.auth-subtitle {
    margin-bottom: 24px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.auth-form {
    display: grid;
    gap: 16px;
}

.auth-submit {
    width: 100%;
    min-height: 46px;
    margin-top: 5px;
}

.auth-card .flash-stack {
    margin-bottom: 20px;
}

.auth-card .flash {
    font-size: 12px;
}

.auth-hint {
    padding-top: 18px;
    margin: 22px 0 0;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 10.5px;
    line-height: 1.6;
}

.auth-note {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 10.5px;
    text-align: center;
}

/* Account page */

.account-panel {
    max-width: 720px;
}

.account-form {
    padding: 22px 25px 25px;
}

.account-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding-top: 22px;
    margin-top: 24px;
    border-top: 1px solid var(--line);
}

/* Footer */

.app-footer {
    padding: 23px 0;
    border-top: 1px solid rgba(217, 213, 202, 0.7);
}

.footer-inner {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-size: 10.5px;
}

.footer-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #b3b7bd;
}

/* Focus */

:focus-visible {
    outline: 2px solid #92aa42;
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
    outline: none;
}

/* Responsive */

@media (max-width: 1120px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .side-stack {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .category-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .category-summary-stats > div {
        min-width: 92px;
        padding-inline: 18px;
    }
}

@media (max-width: 900px) {
    .header-inner {
        gap: 20px;
    }

    .brand-copy small {
        display: none;
    }

    .category-summary {
        align-items: flex-start;
        flex-direction: column;
        gap: 22px;
    }

    .category-summary-stats {
        width: 100%;
    }

    .category-summary-stats > div {
        flex: 1;
        min-width: 0;
    }

    .category-summary-stats > div:first-child {
        padding-left: 0;
    }

    .page-heading {
        align-items: flex-start;
    }
}

@media (max-width: 780px) {
    :root {
        --header-height: 70px;
    }

    .container {
        width: min(var(--container), calc(100% - 32px));
    }

    .page {
        padding-top: 32px;
        padding-bottom: 56px;
    }

    .heading-side .today-pill {
        display: none;
    }

    .heading-add {
        display: inline-flex;
    }

    .header-actions {
        gap: 5px;
    }

    .header-actions .btn-header {
        display: none;
    }

    .account-form {
        padding-inline: 20px;
    }

    .page-heading {
        margin-bottom: 24px;
    }

    .page-heading h1 {
        font-size: 37px;
    }

    .filters {
        padding-inline: 20px;
    }

    .filter-actions {
        margin-left: 0;
    }

    .panel-heading {
        padding-inline: 20px;
    }

    .expense-table th:first-child,
    .expense-table td:first-child {
        padding-left: 20px;
    }

    .expense-table th:last-child,
    .expense-table td:last-child {
        padding-right: 20px;
    }

    .expense-table thead {
        display: none;
    }

    .expense-table,
    .expense-table tbody,
    .expense-table tr,
    .expense-table td {
        display: block;
        width: 100%;
    }

    .expense-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 6px 16px;
        padding: 17px 20px;
        border-bottom: 1px solid #efede7;
    }

    .expense-table tbody tr:hover {
        background: #fcfbf8;
    }

    .expense-table td {
        padding: 0;
        border: 0;
    }

    .expense-table td[data-label="Date"] {
        grid-column: 1;
        grid-row: 1;
    }

    .expense-table td[data-label="Expense"] {
        grid-column: 1;
        grid-row: 2;
    }

    .expense-table td[data-label="Distance"] {
        grid-column: 1;
        grid-row: 3;
    }

    .expense-table td[data-label="Distance"]::before {
        content: "Distance ";
        color: var(--muted);
        font-size: 9px;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    .expense-table td[data-label="Cost"] {
        grid-column: 2;
        grid-row: 1 / 3;
        align-self: center;
        padding-left: 12px;
    }

    .expense-table td.actions-cell {
        grid-column: 2;
        grid-row: 3;
        width: auto;
    }

    .maintenance-table td[data-label="Vehicle"] {
        grid-column: 1;
        grid-row: 2;
    }

    .maintenance-table td[data-label="Action"] {
        grid-column: 1;
        grid-row: 3;
    }

    .maintenance-table td[data-label="Odometer"] {
        grid-column: 1;
        grid-row: 4;
    }

    .maintenance-table td[data-label="Odometer"]::before {
        content: "Odometer ";
        color: var(--muted);
        font-size: 9px;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    .maintenance-table td[data-label="Cost"] {
        grid-column: 2;
        grid-row: 1 / 3;
        align-self: center;
        padding-left: 12px;
    }

    .maintenance-table td.actions-cell {
        grid-column: 2;
        grid-row: 4;
        width: auto;
    }

    .expense-table .row-actions {
        justify-content: flex-end;
        opacity: 1;
    }

    .expense-description {
        max-width: 48vw;
        font-size: 14px;
        white-space: normal;
    }

    .amount {
        font-size: 14px;
    }

    .table-date {
        font-size: 11px;
    }

    .expense-table tbody tr:last-child {
        border-bottom: 0;
    }

    .table-note {
        padding-inline: 20px;
    }

    .side-stack {
        grid-template-columns: minmax(0, 1fr);
    }

    .modal-card {
        padding: 24px;
    }

    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .field-full {
        grid-column: 1;
    }

    .modal-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .form-note {
        max-width: none;
    }

    .modal-actions {
        justify-content: flex-end;
    }

    .category-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 600px) {
    .brand-copy {
        display: none;
    }

    .header-inner {
        gap: 12px;
    }

    .main-nav {
        margin-left: 2px;
    }

    .main-nav a {
        padding: 8px 10px;
    }

    .main-nav a span {
        display: none;
    }

    .main-nav svg {
        width: 18px;
        height: 18px;
    }

    .header-username {
        display: none;
    }

    .header-user {
        width: 34px;
        height: 34px;
        max-width: none;
        justify-content: center;
        padding: 0;
    }

    .stats-grid {
        gap: 12px;
    }

    .stat-card {
        padding: 18px;
    }

    .stat-top {
        margin-bottom: 14px;
    }

    .stat-icon {
        width: 30px;
        height: 30px;
    }

    .stat-value {
        font-size: 24px;
    }

    .filters {
        gap: 8px;
    }

    .filter-search {
        flex-basis: 100%;
    }

    .filter-field {
        flex: 1 1 130px;
    }

    .filter-field select {
        min-width: 0;
    }

    .filter-dates {
        flex: 1 1 100%;
    }

    .filter-actions {
        flex: 1 1 100%;
    }

    .filter-actions .btn {
        flex: 1;
    }

    .category-summary {
        padding: 22px;
    }

    .category-summary-stats {
        flex-wrap: wrap;
        gap: 16px 0;
    }

    .category-summary-stats > div {
        flex: 1 1 33%;
        min-width: 88px;
        padding-inline: 13px;
    }

    .category-summary-stats > div:nth-child(3) {
        flex-basis: 100%;
        padding-left: 0;
        border-left: 0;
    }

    .category-summary-intro {
        align-items: flex-start;
    }

    .footer-inner {
        flex-wrap: wrap;
    }
}

@media (max-width: 440px) {
    .container {
        width: calc(100% - 24px);
    }

    .page-heading h1 {
        font-size: 32px;
    }

    .page-subtitle {
        font-size: 13px;
    }

    .stat-value {
        font-size: 24px;
    }

    .stat-card {
        padding: 20px;
    }

    .main-nav a {
        padding: 8px 9px;
    }

    .modal {
        width: calc(100vw - 20px);
    }

    .modal-card {
        padding: 21px;
        border-radius: 22px;
    }

    .modal-heading h2 {
        font-size: 23px;
    }

    .category-card-spend {
        flex-direction: column;
        gap: 2px;
    }

    .field-hint {
        display: none;
    }

    .auth-body {
        padding: 26px 14px;
    }

    .auth-card {
        padding: 26px 22px;
    }

    .auth-card h1 {
        font-size: 28px;
    }
}

@media (max-width: 360px) {
    .stats-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .stat-value {
        font-size: 28px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
