:root {
    --color-bg: #eceeef;
    --color-surface: #fdfdfc;
    --color-border: #d2d5d6;
    --color-text: #2c2c2c;
    --color-text-secondary: #6b6b6b;
    --color-accent: #2e7d32;
    --color-accent-hover: #1b5e20;
    --color-accent-light: #e8f5e9;
    --color-accent-muted: #a5d6a7;
    --color-danger: #c62828;
    --color-danger-bg: #fdecea;
    --color-danger-border: #f5c6cb;
    --color-purple-bg: #ede7f6;
    --color-purple-text: #5e35b1;
    --color-warning-bg: #fff3e0;
    --color-warning-text: #b45309;
    --color-blue-bg: #e3f2fd;
    --color-blue-text: #1565c0;
    --color-teal-bg: #e0f2f1;
    --color-teal-text: #00695c;
    --color-ambient: #dfe1e2;
    --color-row-alt: #eef0f0;

    --radius-sm: 6px;
    --radius-md: 10px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Subtle ambient background shapes */
body::before,
body::after {
    content: "";
    position: fixed;
    border-radius: 50%;
    filter: blur(70px);
    z-index: -1;
    pointer-events: none;
}
body::before {
    width: 480px;
    height: 480px;
    top: -160px;
    right: -140px;
    background: radial-gradient(circle, var(--color-accent-light) 0%, transparent 72%);
    opacity: 0.8;
}
body::after {
    width: 420px;
    height: 420px;
    bottom: -200px;
    left: -160px;
    background: radial-gradient(circle, var(--color-ambient) 0%, transparent 72%);
    opacity: 0.7;
}

.brand-watermark {
    position: fixed;
    right: -120px;
    bottom: -120px;
    width: 640px;
    height: 640px;
    background: url('/static/logo.svg') no-repeat center / contain;
    opacity: 0.12;
    z-index: -1;
    pointer-events: none;
}

/* Icons */
.icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    vertical-align: -3px;
}
.icon-sm {
    width: 12px;
    height: 12px;
    vertical-align: -1px;
}
.icon-chevron {
    width: 12px;
    height: 12px;
    transition: transform 0.15s;
}
.dropdown:hover .icon-chevron {
    transform: rotate(180deg);
}

.icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    background: var(--color-accent-light);
    color: var(--color-accent-hover);
    flex-shrink: 0;
}
.icon-badge .icon {
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--color-text);
    margin-bottom: 0.5rem;
    line-height: 1.25;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }
h5, h6 { font-size: 0.9rem; }

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color 0.15s;
}

a:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

/* Layout */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    z-index: 10;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--color-text);
}
.navbar-brand:hover {
    text-decoration: none;
    color: var(--color-text);
}

.logo-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    background: var(--color-accent-light);
}

.logo {
    width: 20px;
    height: 20px;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Section tabs */
.nav-toggle-checkbox {
    display: none;
}

.navbar-tabs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 1.5rem;
}

.nav-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    white-space: nowrap;
    transition: background-color 0.15s, color 0.15s;
}
.nav-tab:hover {
    background-color: var(--color-row-alt);
    color: var(--color-text);
    text-decoration: none;
}
.nav-tab.active {
    background-color: var(--color-accent-light);
    color: var(--color-accent-hover);
    font-weight: 600;
}
.nav-tab.active::after {
    content: "";
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    bottom: -0.4rem;
    height: 2px;
    border-radius: 1px;
    background-color: var(--color-accent);
}

.nav-toggle-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    flex-shrink: 0;
}
.nav-toggle-btn:hover {
    background-color: var(--color-row-alt);
}
.nav-toggle-btn .icon {
    width: 20px;
    height: 20px;
    vertical-align: middle;
}

@media (max-width: 880px) {
    .navbar-tabs {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        margin-left: 0;
        gap: 0.15rem;
        padding: 0.5rem;
        background-color: var(--color-surface);
        border-bottom: 1px solid var(--color-border);
        box-shadow: var(--shadow-lg);
        z-index: 9;
    }
    .nav-tab {
        padding: 0.65rem 0.85rem;
    }
    .nav-toggle-checkbox:checked ~ .navbar-tabs {
        display: flex;
    }
    .nav-toggle-btn {
        display: inline-flex;
    }
}

.user-name {
    font-weight: 500;
    color: var(--color-text-secondary);
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: calc(56px + 2rem) 1rem 2rem 1rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h2,
.dashboard-page > h2 {
    position: relative;
    padding-left: 0.9rem;
}
.page-header h2::before,
.dashboard-page > h2::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.15em;
    bottom: 0.15em;
    width: 4px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--color-accent), var(--color-accent-muted));
}

/* Section titles (e.g. "Accounts", "Funds") */
.section-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.75rem;
}
.section-title .icon {
    color: var(--color-accent);
}
.section-title h3 { margin-bottom: 0; }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* Typography & Utilities */
.text-right { text-align: right; }
.text-secondary { color: var(--color-text-secondary); }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.exchange-rate-hint { margin-top: 0.35rem; font-size: 0.8rem; }
.balance-preview {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}
.balance-preview-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.15rem 0;
}
.flex-1 { flex: 1; min-width: 0; }
.w-100 { width: 100%; }

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: var(--color-surface);
    min-width: 160px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    z-index: 1;
    margin-top: 0.5rem;
}

.dropdown-content a {
    color: var(--color-text);
    padding: 0.75rem 1rem;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
}

.dropdown-content a:hover {
    background-color: var(--color-row-alt);
    color: var(--color-accent);
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    font-family: inherit;
    border: 1px solid transparent;
    transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    text-decoration: none;
    line-height: 1.5;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn:hover { text-decoration: none; }
.btn .icon { vertical-align: -2px; }

.btn-primary {
    background: var(--color-accent);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
    background: var(--color-accent-hover);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: transparent;
    border-color: var(--color-border);
    color: var(--color-text);
}
.btn-secondary:hover {
    background-color: var(--color-row-alt);
    border-color: var(--color-text-secondary);
    color: var(--color-text);
}

.btn-danger {
    background-color: var(--color-danger);
    color: #fff;
}

/* Tables */
.table-container {
    position: relative;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(min-content, 1fr);
}
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}
.table-container > * {
    grid-area: 1 / 1;
}
.table-container::before {
    content: "";
    grid-area: 1 / 1;
    align-self: start;
    z-index: 1;
    height: 3px;
    background: linear-gradient(90deg, var(--color-accent), var(--color-accent-muted));
}

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

.table th, .table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.table td.text-right {
    font-variant-numeric: tabular-nums;
}

.table th {
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    background-color: var(--color-bg);
}

.comments-cell {
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table tbody tr:nth-child(even) {
    background-color: var(--color-row-alt);
}
.table tbody tr:last-child td {
    border-bottom: none;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem;
    color: var(--color-text-secondary);
}
.empty-state .icon {
    width: 24px;
    height: 24px;
    opacity: 0.4;
}

.detail-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.6rem 1.25rem;
    margin: 1.25rem 0;
}
.detail-list dt {
    color: var(--color-text-secondary);
    font-weight: 500;
}
.detail-list dd {
    margin: 0;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.checkbox-row label {
    margin-bottom: 0;
}

label {
    font-weight: 500;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    background-color: var(--color-surface);
    color: var(--color-text);
}

/* iOS Safari draws date inputs natively (different height, centred text,
   its own chrome) unless appearance is reset; min-height keeps an empty one
   from collapsing. */
input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    min-height: 2.5rem;
    text-align: left;
}
input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px var(--color-accent-light);
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.card {
    position: relative;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: block;
    color: inherit;
    overflow: hidden;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.card::after {
    content: "";
    position: absolute;
    width: 120px;
    height: 120px;
    top: -60px;
    right: -60px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--color-accent-light) 0%, transparent 72%);
    pointer-events: none;
}

.card:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    position: relative;
}

.card-header h3 { margin-bottom: 0; }

.card-header-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

/* Cycle a small accent palette across group cards so the dashboard isn't
   a wall of identical icons */
.group-card:nth-of-type(4n+2) .icon-badge {
    background: var(--color-blue-bg);
    color: var(--color-blue-text);
}
.group-card:nth-of-type(4n+3) .icon-badge {
    background: var(--color-purple-bg);
    color: var(--color-purple-text);
}
.group-card:nth-of-type(4n+4) .icon-badge {
    background: var(--color-teal-bg);
    color: var(--color-teal-text);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
}
.badge-write {
    background-color: var(--color-accent-light);
    color: var(--color-accent-hover);
}
.badge-readonly {
    background-color: var(--color-border);
    color: var(--color-text-secondary);
}
.badge-admin {
    background-color: var(--color-purple-bg);
    color: var(--color-purple-text);
}
.badge-inactive {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
}
.badge-voided {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
}
.badge-warning {
    background-color: var(--color-warning-bg);
    color: var(--color-warning-text);
}
.badge-info {
    background-color: var(--color-blue-bg);
    color: var(--color-blue-text);
}
.row-voided td {
    opacity: 0.55;
    font-style: italic;
}

/* Signed amounts */
.amount-positive {
    color: var(--color-accent-hover);
}
.amount-negative {
    color: var(--color-danger);
}
.attachment-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}
.alert-error {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
    border: 1px solid var(--color-danger-border);
}
.alert-warning {
    background-color: var(--color-warning-bg);
    color: var(--color-warning-text);
    border: 1px solid var(--color-warning-text);
}
.alert-info {
    background-color: var(--color-accent-light);
    border: 1px solid var(--color-border);
}
.alert-info p + p {
    margin-top: 0.5rem;
}
.alert-list {
    list-style: none;
    margin: 0.5rem 0;
    padding: 0;
}

.error-toast {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    margin-bottom: 0;
}
.error-toast-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.alert-list li {
    padding: 0.15rem 0;
}

.btn.is-loading {
    pointer-events: none;
    opacity: 0.7;
}
.btn.is-loading::after {
    content: "";
    display: inline-block;
    width: 0.8em;
    height: 0.8em;
    margin-left: 0.5em;
    vertical-align: -0.15em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spinner 0.6s linear infinite;
}
@keyframes btn-spinner {
    to { transform: rotate(360deg); }
}

/* Auth pages (login, forced password change) */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.auth-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
}
.auth-card-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.75rem;
    text-align: center;
}
.auth-card-header .logo-wrap {
    width: 48px;
    height: 48px;
}
.auth-card-header .logo {
    width: 28px;
    height: 28px;
}
.auth-card-header h2 {
    margin-bottom: 0;
}

/* One-time credential reveal */
.credential-box {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-accent-light);
    border: 1px dashed var(--color-accent);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin: 1.25rem 0;
    font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--color-accent-hover);
    word-break: break-all;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.2s;
}

/* A modal taller than the window (a long form, or the details of a
   withdrawal with returns, on a phone) must scroll inside itself: the
   overlay is fixed, so without a height limit the page behind can't scroll
   it into view and both ends are simply cut off. */
.modal-content {
    background-color: var(--color-surface);
    width: 100%;
    max-width: 500px;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.confirm-dialog-content {
    max-width: 400px;
}

.confirm-dialog-content p {
    margin: 0;
    color: var(--color-text-secondary);
}

/* Nav divider and group-switch links (shown only inside mobile hamburger) */
.nav-divider {
    display: none;
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 0.25rem 0.85rem;
}

.nav-tab-switch {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: calc(56px + 1.5rem) 1rem 1.5rem 1rem;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .table-container {
        overflow-x: auto;
    }
    .navbar {
        padding: 0 1rem;
    }
}

/* Hamburger breakpoint: show group-switch links inside the dropdown */
@media (max-width: 880px) {
    .nav-divider {
        display: block;
    }
    .nav-tab-switch {
        display: flex;
    }
}

/* Mobile: fix navbar overflow, widgets, table padding */
@media (max-width: 600px) {
    /* Tighten navbar-right so it fits narrow screens */
    .navbar-right {
        gap: 0.5rem;
    }
    .navbar-nav {
        gap: 0.5rem;
    }

    /* Username is decorative here — hide it to save space */
    .user-name {
        display: none;
    }

    /* On group pages the hamburger gives access to group switching,
       so remove the dropdown from the main bar */
    .nav-toggle-checkbox ~ .navbar-right .group-switcher {
        display: none;
    }

    /* Slightly more compact nav buttons */
    .navbar-nav .btn {
        padding: 0.4rem 0.65rem;
        font-size: 0.85rem;
    }

    /* Cards: less padding so they feel lighter on a small screen */
    .card {
        padding: 1rem;
    }

    /* Table last column: extra right padding so content isn't flush
       with the container border when scrolled all the way right */
    .table th:last-child,
    .table td:last-child {
        padding-right: 1.5rem;
    }

    /* Form rows: stack fields vertically instead of side by side */
    .form-row {
        flex-direction: column;
    }

    /* Modal: less padding inside, to leave more room for content */
    .modal-content {
        padding: 1.25rem;
    }
}

/* List filter bar (M3): collapsed by default, because most visits just want
   the latest rows. The Export link sits level with the toggle so it is
   reachable without opening the filters. */
.filter-wrap {
    position: relative;
    margin-bottom: 1rem;
}
.filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    list-style: none;
}
.filter-toggle::-webkit-details-marker {
    display: none;
}
.filter-wrap .filter-export {
    position: absolute;
    top: 0;
    right: 0;
}
.filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0.6rem 0.75rem;
    margin-top: 0.6rem;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background-color: var(--color-surface);
}
.filter-form .form-group {
    margin: 0;
    min-width: 0;
}
.filter-form label {
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
}
.filter-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}
@media (max-width: 640px) {
    /* Two columns: Person alone on top, then Account/Fund, From/To, and the
       buttons across the full width. Six stacked full-width rows would be
       most of a phone screen. */
    .filter-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .filter-form .filter-person,
    .filter-actions {
        grid-column: 1 / -1;
    }
    .filter-actions .btn {
        flex: 1;
        justify-content: center;
        text-align: center;
    }
}

/* A date input with a clear button inside it. The iOS date picker's own
   Reset leaves the value in place, so the field needs one of these to be
   emptied at all. */
.date-field {
    position: relative;
}
.date-field input {
    padding-left: 0.6rem;
    padding-right: 2.2rem;
    font-size: 0.9rem;
}
.date-field .date-clear {
    position: absolute;
    right: 0.2rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.9rem;
    height: 1.9rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--color-text-secondary, #6b7280);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

/* Attachments: the optimised-picture preview in the forms, and thumbnails
   in the details views. */
.attachment-preview {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}
.attachment-preview-img,
.attachment-thumb {
    display: block;
    max-width: 100%;
    max-height: 220px;
    object-fit: contain;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
}
.attachment-preview .alert {
    margin-bottom: 0;
}
.attachment-preview .btn {
    align-self: flex-start;
}
.attachment-name {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 500;
    word-break: break-all;
}
.attachment-hint,
.attachment-busy {
    font-size: 0.8rem;
    margin-top: 0.25rem;
}
.attachment-busy {
    display: none;
}
.attachment-field.htmx-request .attachment-busy {
    display: block;
}
.attachment-item {
    margin-bottom: 0.6rem;
}
.attachment-item .attachment-thumb {
    margin-bottom: 0.25rem;
}
