:root {
    --bg-primary: #f4f7fb;
    --bg-secondary: #e9eef6;
    --bg-surface: #ffffff;
    --bg-subtle: #f8fafc;
    --border-soft: #d9e1ec;
    --border-strong: #b8c4d6;
    --text-primary: #172033;
    --text-secondary: #4b5870;
    --text-muted: #728099;
    --brand: #0f766e;
    --brand-hover: #0b5f59;
    --brand-soft: #e6f5f3;
    --brand-border: #a6d8d2;
    --success: #047857;
    --success-soft: #ecfdf5;
    --danger: #b42318;
    --danger-soft: #fef3f2;
    --warning: #b54708;
    --warning-soft: #fffaeb;
    --info: #175cd3;
    --info-soft: #eff8ff;
    --shadow-sm: 0 1px 2px rgb(20 32 50 / 0.06);
    --shadow-md: 0 12px 28px rgb(20 32 50 / 0.08);
    --shadow-lg: 0 24px 60px rgb(20 32 50 / 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
}

[data-theme="dark"] {
    --bg-primary: #0d1420;
    --bg-secondary: #121d2d;
    --bg-surface: #172235;
    --bg-subtle: #101827;
    --border-soft: #26364f;
    --border-strong: #3b4d68;
    --text-primary: #f6f8fb;
    --text-secondary: #c8d1df;
    --text-muted: #93a4ba;
    --brand: #2dd4bf;
    --brand-hover: #5eead4;
    --brand-soft: #123d3a;
    --brand-border: #1d6b62;
    --success-soft: #0f2f28;
    --danger-soft: #3a1714;
    --warning-soft: #37240d;
    --info-soft: #102946;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg-primary);
}

body {
    background:
        radial-gradient(circle at top left, rgb(15 118 110 / 0.08), transparent 32rem),
        linear-gradient(180deg, var(--bg-primary), var(--bg-secondary));
    color: var(--text-primary);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
    min-height: 100vh;
}

a,
button,
input,
select,
textarea {
    outline-color: var(--brand);
}

a {
    color: inherit;
}

.app-shell {
    min-height: 100vh;
}

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

.app-header {
    background: rgb(255 255 255 / 0.92);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

[data-theme="dark"] .app-header {
    background: rgb(23 34 53 / 0.92);
}

.app-container {
    margin: 0 auto;
    max-width: 1280px;
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 768px) {
    .app-container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

.app-main {
    padding-bottom: 3rem;
    padding-top: 2rem;
}

.brand-mark {
    align-items: center;
    display: inline-flex;
    gap: 0.75rem;
    min-width: 0;
}

.brand-icon {
    align-items: center;
    background: var(--brand);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 20px rgb(15 118 110 / 0.2);
    color: #ffffff;
    display: inline-flex;
    font-weight: 800;
    height: 2.5rem;
    justify-content: center;
    width: 2.5rem;
}

.brand-title {
    color: var(--text-primary);
    display: block;
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.1;
}

.brand-subtitle {
    color: var(--text-muted);
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.nav-link {
    align-items: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    display: inline-flex;
    font-size: 0.9rem;
    font-weight: 700;
    gap: 0.45rem;
    min-height: 2.5rem;
    padding: 0.65rem 0.8rem;
    transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.nav-link:hover,
.nav-link:focus-visible {
    background: var(--brand-soft);
    color: var(--brand);
}

.nav-link-active {
    background: var(--brand-soft);
    box-shadow: inset 0 0 0 1px var(--brand-border);
    color: var(--brand);
}

.mobile-nav {
    border-top: 1px solid var(--border-soft);
    margin-top: 0.9rem;
    padding-top: 0.9rem;
}

.user-pill {
    align-items: center;
    background: var(--bg-subtle);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    display: flex;
    gap: 0.75rem;
    padding: 0.45rem 0.75rem 0.45rem 0.45rem;
}

.avatar {
    align-items: center;
    background: var(--brand);
    border-radius: 999px;
    color: #ffffff;
    display: inline-flex;
    font-size: 0.9rem;
    font-weight: 800;
    height: 2.15rem;
    justify-content: center;
    width: 2.15rem;
}

.btn {
    align-items: center;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    font-size: 0.9rem;
    font-weight: 800;
    gap: 0.45rem;
    justify-content: center;
    line-height: 1.2;
    min-height: 2.65rem;
    padding: 0.72rem 1rem;
    text-align: center;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.btn:hover,
.btn:focus-visible {
    box-shadow: 0 10px 20px rgb(20 32 50 / 0.08);
}

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

.btn-primary {
    background: var(--brand);
    color: #ffffff;
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background: var(--brand-hover);
    color: #ffffff;
}

.btn-secondary {
    background: var(--bg-surface);
    border-color: var(--border-soft);
    color: var(--text-secondary);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
    background: var(--bg-subtle);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

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

.btn-danger:hover,
.btn-danger:focus-visible {
    background: #912018;
    color: #ffffff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover,
.btn-ghost:focus-visible {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.btn-sm {
    font-size: 0.8rem;
    min-height: 2.2rem;
    padding: 0.52rem 0.75rem;
}

.btn-block {
    width: 100%;
}

.page-header {
    align-items: flex-start;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .page-header {
        align-items: center;
        flex-direction: row;
        justify-content: space-between;
    }
}

.eyebrow {
    color: var(--brand);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
}

.page-title {
    color: var(--text-primary);
    font-size: clamp(1.65rem, 3vw, 2.35rem);
    font-weight: 850;
    line-height: 1.12;
}

.page-description {
    color: var(--text-secondary);
    margin-top: 0.45rem;
    max-width: 48rem;
}

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

.card-pad {
    padding: 1.1rem;
}

@media (min-width: 768px) {
    .card-pad {
        padding: 1.4rem;
    }
}

.section-title {
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 800;
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-top: 0.25rem;
}

.metric-card {
    overflow: hidden;
    padding: 1.25rem 1.3rem 1.35rem;
    position: relative;
    transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

/* Clean colour accent bar instead of a decorative blob. The colour is set per
   KPI by the modifier classes below; defaults to the brand colour. */
.metric-card::before {
    background: var(--brand);
    content: "";
    height: 3px;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
}

.metric-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.metric-card--income::before {
    background: var(--success);
}

.metric-card--expense::before {
    background: var(--danger);
}

.metric-card--balance::before {
    background: var(--info);
}

.metric-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.metric-value {
    color: var(--text-primary);
    font-size: clamp(1.75rem, 4vw, 2.35rem);
    font-weight: 900;
    line-height: 1.1;
    margin-top: 0.55rem;
}

.metric-note {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.55rem;
}

.text-positive {
    color: var(--success);
}

.text-negative {
    color: var(--danger);
}

.badge {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    font-size: 0.75rem;
    font-weight: 800;
    gap: 0.35rem;
    line-height: 1;
    padding: 0.4rem 0.65rem;
}

.badge-income,
.badge-success {
    background: var(--success-soft);
    color: var(--success);
}

.badge-expense,
.badge-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge-neutral {
    background: var(--bg-subtle);
    border: 1px solid var(--border-soft);
    color: var(--text-secondary);
}

.form-grid {
    display: grid;
    gap: 1rem;
}

.filter-grid {
    align-items: end;
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1120px) {
    .filter-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
    }
}

.form-label {
    color: var(--text-secondary);
    display: block;
    font-size: 0.86rem;
    font-weight: 800;
    margin-bottom: 0.4rem;
}

.form-control,
.form-input,
.form-select,
.form-textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    min-height: 2.75rem;
    padding: 0.72rem 0.85rem;
    width: 100%;
}

input[type="file"] {
    padding: 0.55rem;
}

.form-control:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus,
input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgb(15 118 110 / 0.12);
    outline: none;
}

.help-text {
    color: var(--text-muted);
    font-size: 0.84rem;
    margin-top: 0.4rem;
}

.field-error,
.errorlist {
    color: var(--danger);
    font-size: 0.84rem;
    margin-top: 0.4rem;
}

.errorlist {
    list-style: none;
    padding-left: 0;
}

.choice-card {
    align-items: flex-start;
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    gap: 0.75rem;
    padding: 0.9rem;
    transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.choice-card:hover,
.choice-card:focus-within {
    background: var(--brand-soft);
    border-color: var(--brand-border);
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    border-collapse: separate;
    border-spacing: 0;
    min-width: 720px;
    width: 100%;
}

.data-table th {
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.05em;
    padding: 0.85rem 1rem;
    text-align: left;
    text-transform: uppercase;
}

.data-table td {
    border-top: 1px solid var(--border-soft);
    color: var(--text-secondary);
    padding: 0.95rem 1rem;
    vertical-align: middle;
}

.data-table tr:hover td {
    background: var(--bg-subtle);
}

.amount-cell {
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    font-weight: 850;
    white-space: nowrap;
}

.empty-state {
    align-items: center;
    background: var(--bg-subtle);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    justify-content: center;
    min-height: 12rem;
    padding: 2rem;
    text-align: center;
}

.empty-state-title {
    color: var(--text-primary);
    font-weight: 850;
}

.empty-state-compact {
    min-height: 0;
    padding: 1.25rem;
}

.category-card {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: 1rem;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

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

.category-image {
    align-items: center;
    background: var(--bg-subtle);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    display: flex;
    height: 5rem;
    justify-content: center;
    margin-bottom: 1rem;
    width: 5rem;
}

.category-image img {
    height: 3.5rem;
    object-fit: contain;
    width: 3.5rem;
}

.category-image-sm {
    height: 2.5rem;
    margin-bottom: 0;
    width: 2.5rem;
}

.category-image-md {
    height: 3rem;
    margin-bottom: 0;
    width: 3rem;
}

.category-image-sm img,
.category-image-md img {
    height: 70%;
    width: 70%;
}

.category-placeholder {
    color: var(--brand);
    font-size: 1.35rem;
    font-weight: 900;
}

.category-image-sm .category-placeholder,
.category-image-md .category-placeholder {
    font-size: 1rem;
}

.side-nav {
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 0.8rem;
}

.side-nav-link {
    align-items: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    display: flex;
    gap: 0.7rem;
    padding: 0.7rem;
}

.side-nav-link:hover {
    background: var(--bg-subtle);
}

.side-nav-link-active {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 850;
}

.recent-entry {
    align-items: center;
    background: var(--bg-subtle);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    padding: 0.65rem 0.75rem;
}

.modal-backdrop {
    background: rgb(15 23 42 / 0.55);
    inset: 0;
    overflow-y: auto;
    padding: 1rem;
    position: fixed;
    z-index: 70;
}

.modal-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin: 8vh auto 0;
    max-width: 28rem;
    padding: 1.5rem;
}

.auth-wrap {
    align-items: stretch;
    display: grid;
    gap: 1.25rem;
    margin: 0 auto;
    max-width: 980px;
}

@media (min-width: 900px) {
    .auth-wrap {
        grid-template-columns: 0.95fr 1.05fr;
    }
}

.auth-panel {
    background:
        linear-gradient(150deg, rgb(15 118 110 / 0.96), rgb(20 32 50 / 0.98)),
        var(--brand);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    color: #ffffff;
    min-height: 100%;
    padding: 1.5rem;
}

.auth-card {
    padding: 1.35rem;
}

.alert {
    align-items: flex-start;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    display: flex;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
}

.alert-success {
    background: var(--success-soft);
    border-color: rgb(4 120 87 / 0.2);
    color: var(--success);
}

.alert-error {
    background: var(--danger-soft);
    border-color: rgb(180 35 24 / 0.2);
    color: var(--danger);
}

.alert-warning {
    background: var(--warning-soft);
    border-color: rgb(181 71 8 / 0.2);
    color: var(--warning);
}

.alert-info {
    background: var(--info-soft);
    border-color: rgb(23 92 211 / 0.2);
    color: var(--info);
}

.spinner {
    animation: spin 0.8s linear infinite;
    border: 4px solid var(--brand-border);
    border-radius: 9999px;
    border-top-color: var(--brand);
    height: 3rem;
    width: 3rem;
}

.page-loader {
    align-items: center;
    background: var(--bg-primary);
    display: flex;
    inset: 0;
    justify-content: center;
    position: fixed;
    transition: opacity 0.2s ease;
    z-index: 99999;
}

.page-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.theme-toggle,
.back-to-top {
    align-items: center;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    box-shadow: var(--shadow-md);
    display: flex;
    height: 2.8rem;
    justify-content: center;
    position: fixed;
    right: 1.25rem;
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
    width: 2.8rem;
    z-index: 55;
}

.theme-toggle {
    background: var(--brand);
    bottom: 1.25rem;
    color: #ffffff;
}

.back-to-top {
    background: var(--bg-surface);
    bottom: 4.55rem;
    color: var(--text-primary);
}

.theme-toggle:hover,
.back-to-top:hover {
    transform: translateY(-1px);
}

.app-footer {
    background: rgb(255 255 255 / 0.8);
    border-top: 1px solid var(--border-soft);
    color: var(--text-muted);
}

[data-theme="dark"] .app-footer {
    background: rgb(23 34 53 / 0.8);
}

[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-gray-50,
[data-theme="dark"] .bg-gray-100,
[data-theme="dark"] .bg-gray-200 {
    background-color: var(--bg-surface);
}

[data-theme="dark"] .text-gray-900,
[data-theme="dark"] .text-gray-800,
[data-theme="dark"] .text-gray-700 {
    color: var(--text-primary);
}

[data-theme="dark"] .text-gray-600,
[data-theme="dark"] .text-gray-500,
[data-theme="dark"] .text-gray-400 {
    color: var(--text-muted);
}

[data-theme="dark"] .border,
[data-theme="dark"] .border-t,
[data-theme="dark"] .border-b,
[data-theme="dark"] .border-r,
[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-300 {
    border-color: var(--border-soft);
}

[data-theme="dark"] .divide-gray-200 > :not([hidden]) ~ :not([hidden]) {
    border-color: var(--border-soft);
}

@media (max-width: 767px) {
    .mobile-stack {
        align-items: stretch;
        flex-direction: column;
    }

    .mobile-stack > * {
        width: 100%;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================
   Targeted polish refinements
   Visual + accessibility improvements only. These rules rely on
   existing class names and add no markup or text dependencies,
   so the UI-translation middleware and tests are unaffected.
   ============================================================ */

/* Consistent keyboard focus ring across interactive elements. */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.nav-link:focus-visible,
.side-nav-link:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* Inputs already show a ring via box-shadow; avoid a doubled outline. */
input:focus,
select:focus,
textarea:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
}

/* Calmer placeholders and an unmistakable disabled state. */
::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

input:disabled,
select:disabled,
textarea:disabled {
    background: var(--bg-subtle);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Premium thin scrollbars (desktop webview / Blink + Firefox). */
* {
    scrollbar-color: var(--border-strong) transparent;
    scrollbar-width: thin;
}

::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    background-clip: padding-box;
    border: 2px solid transparent;
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
    background-clip: padding-box;
}

::selection {
    background: rgb(15 118 110 / 0.18);
    color: var(--text-primary);
}

/* Tighter heading rhythm and aligned numerals for financial figures. */
.page-title {
    letter-spacing: -0.01em;
}

.metric-value {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* Smooth elevation for cards; opt-in hover for otherwise static cards. */
.card {
    transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.card-hover:hover {
    border-color: var(--brand-border);
    box-shadow: var(--shadow-md);
}

/* Buttons: a touch more depth and a proper disabled state. */
.btn-primary {
    box-shadow: 0 1px 2px rgb(15 118 110 / 0.25);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

/* Status dot inside badges for a calmer, more deliberate read. */
.badge::before {
    border-radius: 999px;
    content: "";
    flex: none;
    height: 0.45rem;
    width: 0.45rem;
}

.badge-income::before,
.badge-success::before {
    background: var(--success);
}

.badge-expense::before,
.badge-danger::before {
    background: var(--danger);
}

.badge-neutral::before {
    background: var(--text-muted);
}

/* Tables: zebra-striped rows with a clear hover. The wrapper frame is
   provided by the surrounding card, so no extra border is added here. */
.data-table tbody tr:nth-child(even) td {
    background: var(--bg-subtle);
}

.data-table tbody tr:hover td {
    background: var(--brand-soft);
}

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

/* Recent-entry rows: gentle interactive feedback. */
.recent-entry {
    transition: background-color 0.16s ease, border-color 0.16s ease;
}

.recent-entry:hover {
    border-color: var(--brand-border);
}

/* Skeleton loading utility, available for future async/empty states. */
.skeleton {
    animation: skeleton-shimmer 1.4s ease infinite;
    background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border-soft) 37%, var(--bg-subtle) 63%);
    background-size: 400% 100%;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 100% 0;
    }
    100% {
        background-position: 0 0;
    }
}

/* Header user dropdown menu. */
.user-menu {
    position: relative;
}

.user-pill {
    color: inherit;
    cursor: pointer;
    font: inherit;
}

.user-menu-caret {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-left: 0.1rem;
}

.user-menu-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 13rem;
    padding: 0.4rem;
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    z-index: 60;
}

.user-menu-head {
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 0.35rem;
    padding: 0.5rem 0.6rem 0.6rem;
}

.user-menu-item {
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    padding: 0.6rem 0.65rem;
    text-align: left;
    width: 100%;
}

.user-menu-item:hover,
.user-menu-item:focus-visible {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.user-menu-item-danger {
    color: var(--danger);
}

.user-menu-item-danger:hover,
.user-menu-item-danger:focus-visible {
    background: var(--danger-soft);
    color: var(--danger);
}

/* Built-in category icon picker. */
.preset-grid {
    display: grid;
    gap: 0.6rem;
    grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
    margin-top: 0.5rem;
}

.preset-option {
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    justify-content: center;
    min-height: 5.75rem;
    padding: 0.6rem 0.4rem;
    text-align: center;
    transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.preset-option:hover {
    background: var(--brand-soft);
    border-color: var(--brand-border);
}

.preset-option img {
    height: 2.75rem;
    object-fit: contain;
    width: 2.75rem;
}

.preset-caption {
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.preset-option-none {
    border-style: dashed;
}

.preset-none {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.2;
}

/* Selected / keyboard-focused state (radio itself is visually hidden). */
.preset-option:has(input:checked) {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgb(15 118 110 / 0.15);
}

.preset-option:has(input:focus-visible) {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

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