/* MoneyApp - Estils personalitzats */

html {
    font-size: 16px;
}

html[data-mida-font="petita"] {
    font-size: 14px;
}

html[data-mida-font="normal"] {
    font-size: 16px;
}

html[data-mida-font="gran"] {
    font-size: 18px;
}

:root {
    --sidebar-width: 320px;
    --app-header-height: 3.5rem;
    --app-content-max: 1200px;
    --color-primary: #0d6efd;
    --color-success: #198754;
    --color-danger:  #dc3545;
    --color-warning: #ffc107;
    --color-bg:      #f8f9fa;
    --app-surface:       #fff;
    --app-surface-muted: #f8f9fa;
    --app-surface-soft:  #fafbfc;
    --app-border:        rgba(0, 0, 0, 0.06);
    --app-border-strong: #dee2e6;
    --app-topbar-border: #dee2e6;
    --app-text:          #212529;
    --app-text-muted:    #6c757d;
    --app-shadow:        rgba(15, 23, 42, 0.06);
    --sidebar-bg:              #ffffff;
    --sidebar-text:            #212529;
    --sidebar-text-muted:      #6c757d;
    --sidebar-border:          #dee2e6;
    --sidebar-hover:           rgba(0, 0, 0, 0.05);
    --sidebar-hover-strong:    rgba(0, 0, 0, 0.08);
    --sidebar-submenu-border:  rgba(0, 0, 0, 0.1);
    --sidebar-bloc-border:     rgba(0, 0, 0, 0.08);
    --sidebar-grup-bg:         #f8f9fa;
    --sidebar-grup-border:     #e9ecef;
    --sidebar-grup-cap-bg:     #f1f3f5;
    --sidebar-grup-cap-hover:  #e9ecef;
    --sidebar-grup-shadow:     0 4px 12px rgba(15, 23, 42, 0.06);
    --sidebar-grup-cap-border: rgba(0, 0, 0, 0.06);
    --sidebar-compte-nom:      #212529;
    --sidebar-fletxa:          #6c757d;
    --sidebar-logout:          #6c757d;
    --sidebar-scrollbar:       rgba(0, 0, 0, 0.15);
    --sidebar-active-compte:   rgba(13, 110, 253, 0.1);
}

[data-bs-theme="dark"] {
    --color-bg:          #1a1d20;
    --app-surface:       #212529;
    --app-surface-muted: #2b3035;
    --app-surface-soft:  #343a40;
    --app-border:        rgba(255, 255, 255, 0.08);
    --app-border-strong: rgba(255, 255, 255, 0.15);
    --app-topbar-border: rgba(255, 255, 255, 0.15);
    --app-text:          #dee2e6;
    --app-text-muted:    #adb5bd;
    --app-shadow:        rgba(0, 0, 0, 0.35);
    --sidebar-bg:              #212529;
    --sidebar-text:            #dee2e6;
    --sidebar-text-muted:      #adb5bd;
    --sidebar-border:          rgba(255, 255, 255, 0.12);
    --sidebar-hover:           rgba(255, 255, 255, 0.1);
    --sidebar-hover-strong:    rgba(255, 255, 255, 0.12);
    --sidebar-submenu-border:  rgba(255, 255, 255, 0.15);
    --sidebar-bloc-border:     rgba(255, 255, 255, 0.12);
    --sidebar-grup-bg:         rgba(255, 255, 255, 0.05);
    --sidebar-grup-border:     rgba(255, 255, 255, 0.1);
    --sidebar-grup-cap-bg:     rgba(0, 0, 0, 0.12);
    --sidebar-grup-cap-hover:  rgba(255, 255, 255, 0.04);
    --sidebar-grup-shadow:     0 4px 12px rgba(0, 0, 0, 0.18);
    --sidebar-grup-cap-border: rgba(255, 255, 255, 0.07);
    --sidebar-compte-nom:      rgba(255, 255, 255, 0.92);
    --sidebar-fletxa:          rgba(255, 255, 255, 0.45);
    --sidebar-logout:          rgba(255, 255, 255, 0.5);
    --sidebar-scrollbar:       rgba(255, 255, 255, 0.2);
    --sidebar-active-compte:   rgba(255, 255, 255, 0.12);
}

/* Layout principal */
body {
    background-color: var(--color-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.875rem;
}

#wrapper {
    min-height: 100vh;
}

#sidebar {
    --sidebar-padding-x: 1rem;
    --sidebar-item-padding-x: 0.85rem;
    --sidebar-widget-padding-x: 0.6rem;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    transition: all 0.25s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    padding-left: var(--sidebar-padding-x);
    padding-right: var(--sidebar-padding-x);
    scrollbar-gutter: stable;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-nav {
    min-height: 100vh;
}

#sidebar.collapsed {
    width: 0;
    min-width: 0;
    max-width: 0;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
    scrollbar-gutter: auto;
}

/* Capçalera del sidebar (alineada amb el topbar) */
#sidebar .sidebar-brand {
    height: var(--app-header-height);
    min-height: var(--app-header-height);
    padding: 0;
    margin-left: calc(-1 * var(--sidebar-padding-x));
    margin-right: calc(-1 * var(--sidebar-padding-x));
    padding-left: var(--sidebar-padding-x);
    padding-right: var(--sidebar-padding-x);
    flex-shrink: 0;
    color: var(--sidebar-text);
    border-bottom: 1px solid var(--app-topbar-border) !important;
    gap: 0.15rem;
}

#sidebar .sidebar-brand-stack {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.15;
    min-width: 0;
}

#sidebar .sidebar-brand-name {
    color: var(--sidebar-text);
    font-weight: 700;
    font-size: 1.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#sidebar .sidebar-brand-name:hover {
    color: var(--bs-primary);
}

#sidebar .sidebar-brand-version {
    color: var(--sidebar-text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    width: fit-content;
    max-width: 100%;
    line-height: 1.2;
}

#sidebar .sidebar-brand-version:hover,
#sidebar .sidebar-brand-version.active {
    color: var(--bs-primary);
}

/* Botons d'app al principi del sidebar */
#sidebar .sidebar-apps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.35rem;
    padding: 0.75rem 0 0.55rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

#sidebar .sidebar-app-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.3rem;
    padding: 0.45rem 0.2rem 0.4rem;
    border-radius: 10px;
    text-decoration: none;
    color: var(--sidebar-text-muted);
    min-width: 0;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

#sidebar .sidebar-app-btn:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
}

#sidebar .sidebar-app-btn.is-active {
    background: var(--sidebar-active-compte);
    color: var(--bs-primary);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bs-primary) 28%, transparent);
}

#sidebar .sidebar-app-btn-icon {
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 0.7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    background: var(--sidebar-grup-bg);
    border: 1px solid var(--sidebar-grup-border);
    color: inherit;
    flex-shrink: 0;
}

#sidebar .sidebar-app-btn.is-active .sidebar-app-btn-icon {
    background: color-mix(in srgb, var(--bs-primary) 14%, transparent);
    border-color: color-mix(in srgb, var(--bs-primary) 35%, transparent);
}

#sidebar .sidebar-app-btn-label {
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#sidebar .sidebar-nav-bloc--primer {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* Filtres de tipus de programats: mateix format de menú que Informes */
#sidebar .sidebar-resum-filtres-item {
    list-style: none;
}

#sidebar .sidebar-filtre-nav {
    display: flex;
    align-items: center;
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

#sidebar .sidebar-filtre-nav-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#sidebar .sidebar-filtre-nav .badge {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

#sidebar .sidebar-filtre-badge--tots,
#sidebar .sidebar-filtre-badge--tots-actiu {
    background: var(--sidebar-grup-border);
    color: var(--sidebar-text);
}

/* Actiu: colors específics (com abans als botons) */
#sidebar .sidebar-filtre-nav.active[data-classe="secondary"] {
    background: var(--sidebar-grup-cap-bg);
    color: var(--sidebar-text) !important;
    box-shadow: inset 0 0 0 1px var(--sidebar-grup-border);
}

#sidebar .sidebar-filtre-nav.active[data-classe="danger"] {
    background-color: var(--bs-danger, #dc3545);
    color: #fff !important;
}

#sidebar .sidebar-filtre-nav.active[data-classe="success"] {
    background-color: var(--bs-success, #198754);
    color: #fff !important;
}

#sidebar .sidebar-filtre-nav.active[data-classe="primary"] {
    background-color: var(--bs-primary, #0d6efd);
    color: #fff !important;
}

#sidebar .sidebar-filtre-nav.active[data-classe="danger"] .badge,
#sidebar .sidebar-filtre-nav.active[data-classe="success"] .badge,
#sidebar .sidebar-filtre-nav.active[data-classe="primary"] .badge {
    background: #fff !important;
}

#sidebar .sidebar-filtre-nav.active[data-classe="danger"] .badge {
    color: var(--bs-danger, #dc3545) !important;
}

#sidebar .sidebar-filtre-nav.active[data-classe="success"] .badge {
    color: var(--bs-success, #198754) !important;
}

#sidebar .sidebar-filtre-nav.active[data-classe="primary"] .badge {
    color: var(--bs-primary, #0d6efd) !important;
}

#sidebar .sidebar-filtre-nav.active[data-classe="secondary"] .badge {
    background: var(--sidebar-hover-strong) !important;
    color: var(--sidebar-text) !important;
}

/* Widgets de resum de programats (despeses / ingressos) */
#sidebar .sidebar-resum-programats-item {
    list-style: none;
    margin-top: 0.75rem;
}

#sidebar .sidebar-resum-programats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#sidebar .sidebar-resum-widget {
    background: var(--sidebar-grup-bg);
    border: 1px solid var(--sidebar-grup-border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--sidebar-grup-shadow);
}

#sidebar .sidebar-resum-widget-cap {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem var(--sidebar-widget-padding-x, 0.6rem);
    border-bottom: 1px solid var(--sidebar-grup-cap-border);
    background: var(--sidebar-grup-cap-bg);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--sidebar-text);
}

#sidebar .sidebar-resum-widget-cap .bi {
    font-size: 0.9rem;
    flex-shrink: 0;
}

#sidebar .sidebar-resum-widget--despesa .sidebar-resum-widget-cap {
    color: var(--bs-danger, #dc3545);
}

#sidebar .sidebar-resum-widget--ingres .sidebar-resum-widget-cap {
    color: var(--bs-success, #198754);
}

#sidebar .sidebar-resum-widget--transferencia .sidebar-resum-widget-cap {
    color: var(--bs-primary, #0d6efd);
}

#sidebar .sidebar-resum-widget-cos {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.55rem var(--sidebar-widget-padding-x, 0.6rem) 0.65rem;
}

#sidebar .sidebar-resum-periode-fila {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.55rem;
    padding: 0.15rem 0;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--sidebar-text-muted);
}

#sidebar .sidebar-resum-periode-label {
    min-width: 0;
}

#sidebar .sidebar-resum-periode-import {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
}

#sidebar .sidebar-resum-periode-fila--ingres .sidebar-resum-periode-import {
    color: var(--bs-success, #198754);
}

#sidebar .sidebar-resum-periode-fila--despesa .sidebar-resum-periode-import {
    color: var(--bs-danger, #dc3545);
}

#sidebar .sidebar-resum-periode-fila--transferencia .sidebar-resum-periode-import {
    color: var(--bs-primary, #0d6efd);
}

#sidebar .sidebar-footer {
    border-top-color: var(--sidebar-border) !important;
}

#sidebar .sidebar-logout-link {
    color: var(--sidebar-logout) !important;
}

#sidebar .sidebar-logout-link:hover {
    color: var(--sidebar-text) !important;
    background: var(--sidebar-hover);
}

/* Topbar de l'app: mateixa alçada i línia que el capçalera del sidebar */
.navbar-app-top {
    height: var(--app-header-height);
    min-height: var(--app-header-height);
    max-height: var(--app-header-height);
    padding-top: 0;
    padding-bottom: 0;
    flex-shrink: 0;
    align-items: center;
    border-bottom: 1px solid var(--app-topbar-border) !important;
}

#page-content {
    min-height: 100vh;
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
}

#wrapper.sidebar-collapsed #page-content {
    flex: 1 1 100%;
    max-width: 100%;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(0, 0, 0, 0.45);
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
}

/* Navegació sidebar */
#sidebar .nav-link {
    border-radius: 6px;
    padding: 0.45rem var(--sidebar-item-padding-x, 0.85rem);
    margin-bottom: 2px;
    font-size: 0.85rem;
    transition: background 0.15s, color 0.15s;
    color: var(--sidebar-text);
}

#sidebar .nav-link:hover {
    background-color: var(--sidebar-hover);
    color: var(--sidebar-text);
}

#sidebar .nav-link.active {
    background-color: var(--color-primary);
    color: #fff !important;
}

#sidebar .nav-link.text-muted,
#sidebar .text-muted {
    color: var(--sidebar-text-muted) !important;
}

/* Submenú del sidebar */
#sidebar .nav-submenu {
    padding-left: 1.25rem;
    margin-top: 2px;
    margin-bottom: 4px;
    border-left: 2px solid var(--sidebar-submenu-border);
    margin-left: 1.1rem;
}

#sidebar .nav-submenu .nav-link {
    display: flex;
    align-items: center;
    min-width: 0;
    font-size: 0.8rem;
    padding: 0.35rem var(--sidebar-item-padding-x, 0.85rem);
    opacity: 0.85;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#sidebar .nav-submenu .nav-link .bi {
    flex-shrink: 0;
}

#sidebar .nav-submenu .nav-link:hover,
#sidebar .nav-submenu .nav-link.active {
    opacity: 1;
}

/* Blocs del menú amb línies separadores */
#sidebar .sidebar-nav-bloc {
    list-style: none;
    margin: 0.85rem 0 0;
    padding: 0.65rem 0 0;
    border-top: 1px solid var(--sidebar-bloc-border);
}

#sidebar .sidebar-nav-bloc-llista {
    margin: 0;
    padding: 0;
}

#sidebar .sidebar-nav-bloc-llista > .nav-item:last-child .nav-link {
    margin-bottom: 0;
}

#sidebar .sidebar-nav-bloc .sidebar-nav-seccio {
    margin: 0;
}

/* Cards de comptes independents al sidebar */
#sidebar .sidebar-comptes-cards-item {
    list-style: none;
    margin-bottom: 1.35rem;
    max-width: 100%;
    min-width: 0;
}

#sidebar .sidebar-comptes-cards {
    padding: 0;
    margin: 0.45rem 0 0;
    border-left: none;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    max-width: 100%;
    min-width: 0;
}

#sidebar .sidebar-comptes-cards .nav-link {
    opacity: 1;
}

/* Secció col·lapsable (Configuració) */
#sidebar .sidebar-nav-seccio {
    margin: 0;
}

#sidebar .sidebar-nav-seccio-cap {
    display: flex;
    align-items: center;
    list-style: none;
    cursor: pointer;
    user-select: none;
}

#sidebar .sidebar-nav-seccio-cap::-webkit-details-marker {
    display: none;
}

#sidebar .sidebar-nav-seccio-fletxa {
    font-size: 0.65rem;
    opacity: 0.55;
    transition: transform 0.15s ease;
}

#sidebar .sidebar-nav-seccio:not([open]) .sidebar-nav-seccio-fletxa {
    transform: rotate(-90deg);
}

#sidebar .sidebar-nav-configuracio .nav-submenu,
#sidebar .sidebar-nav-informes .nav-submenu {
    margin-top: 0.15rem;
}

/* Grups de comptes al sidebar — card */
#sidebar .sidebar-compte-grup-item {
    margin-bottom: 0;
    list-style: none;
    max-width: 100%;
    min-width: 0;
}

#sidebar .sidebar-compte-grup {
    margin: 0;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background: var(--sidebar-grup-bg);
    border: 1px solid var(--sidebar-grup-border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--sidebar-grup-shadow);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

#sidebar .sidebar-compte-grup:hover {
    box-shadow: var(--sidebar-grup-shadow), 0 2px 8px var(--app-shadow);
}

#sidebar .sidebar-compte-grup--sense {
    padding: 0.25rem var(--sidebar-widget-padding-x, 0.6rem) 0.3rem;
}

#sidebar .sidebar-compte-grup-cap {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    list-style: none;
    cursor: pointer;
    padding: 0.4rem var(--sidebar-widget-padding-x, 0.6rem);
    border-radius: 0;
    user-select: none;
    border-bottom: 1px solid var(--sidebar-grup-cap-border);
    background: var(--sidebar-grup-cap-bg);
    color: var(--sidebar-text);
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

#sidebar .sidebar-compte-grup:not([open]) .sidebar-compte-grup-cap {
    border-bottom-color: transparent;
}

#sidebar .sidebar-compte-grup-cap::-webkit-details-marker {
    display: none;
}

#sidebar .sidebar-compte-grup-fletxa {
    font-size: 0.6rem;
    color: var(--sidebar-fletxa);
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

#sidebar .sidebar-compte-grup:not([open]) .sidebar-compte-grup-fletxa {
    transform: rotate(-90deg);
}

#sidebar .sidebar-compte-grup-cap:hover {
    background: var(--sidebar-grup-cap-hover);
}

#sidebar .sidebar-compte-grup-cap-row {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
}

#sidebar .sidebar-compte-grup-nom {
    font-size: 0.72rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

#sidebar .sidebar-compte-grup-badge {
    flex-shrink: 1;
    min-width: 0;
    max-width: 48%;
    padding: 0.15rem 0.35rem;
    border-radius: 5px;
    font-size: 0.68rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    line-height: 1.2;
    border: 1px solid;
    overflow: hidden;
    text-overflow: ellipsis;
}

#sidebar .sidebar-compte-grup-llista {
    margin: 0;
    padding: 0.25rem var(--sidebar-widget-padding-x, 0.6rem) 0.35rem;
    gap: 0.1rem;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

#sidebar .sidebar-compte-grup-llista .nav-item {
    margin: 0;
}

#sidebar .sidebar-compte-grup-llista .sidebar-compte-link {
    margin: 0;
    border-radius: 8px;
}

#sidebar .sidebar-compte-grup-llista .sidebar-compte-link:hover {
    background: var(--sidebar-hover);
}

#sidebar .sidebar-compte-grup-llista .sidebar-compte-link.active {
    background: var(--sidebar-active-compte);
}

#sidebar .sidebar-compte-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.4rem !important;
    font-size: 0.72rem;
    line-height: 1.15;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

#sidebar .sidebar-compte-icon {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 0.62rem;
    box-sizing: border-box;
    padding: 0;
    overflow: hidden;
}

#sidebar .sidebar-compte-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

#sidebar .sidebar-compte-nom {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--sidebar-compte-nom);
    line-height: 1.2;
}

#sidebar .sidebar-compte-saldo {
    font-size: 0.7rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

#sidebar .sidebar-compte-saldo--pos {
    color: #22c55e;
}

#sidebar .sidebar-compte-saldo--neg {
    color: #f87171;
}

#sidebar .sidebar-compte-link.active {
    background: var(--sidebar-active-compte);
    color: var(--sidebar-text);
}

#sidebar .sidebar-compte-link.active .sidebar-compte-nom {
    color: var(--sidebar-text);
    font-weight: 600;
}

#sidebar .sidebar-compte-link.active .sidebar-compte-saldo--pos {
    color: #34d399;
}

#sidebar .sidebar-compte-link.active .sidebar-compte-saldo--neg {
    color: #fca5a5;
}

#sidebar .sidebar-compte-link:hover {
    background: var(--sidebar-hover);
}

#sidebar .sidebar-compte-link:hover .sidebar-compte-nom {
    color: var(--sidebar-text);
}

/* Badges de saldo als grups (pàgina de gestió) */
.grup-compte-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
    display: inline-block;
}

.grup-compte-saldo-badge {
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    border: 1px solid transparent;
}

.grup-compte-saldo-badge--pos {
    color: #15803d;
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.grup-compte-saldo-badge--neg {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fecaca;
}

/* Llista de grups de comptes: una fila per grup a amplada completa */
.grups-comptes-llista .list-item-card {
    width: 100%;
}

.grup-compte-card-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.grup-compte-card-row .grup-compte-color-dot {
    width: 12px;
    height: 36px;
    border-radius: 4px;
    align-self: stretch;
}

.grup-compte-card-row .list-stacked-actions {
    flex-shrink: 0;
    margin-left: auto;
}

@media (max-width: 575px) {
    .grup-compte-card-row {
        flex-wrap: wrap;
    }

    .grup-compte-card-row .grup-compte-saldo-badge {
        order: 3;
        width: 100%;
        text-align: center;
    }

    .grup-compte-card-row .list-stacked-actions {
        margin-left: 0;
    }
}

/* Cards */
.card {
    border-radius: 12px;
}

.card-header {
    padding: 1rem 1.25rem 0.5rem;
}

/* Taules */
.table th {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
}

.table td {
    vertical-align: middle;
}

/* Alerts flash */
.alert {
    border-radius: 10px;
    border: none;
}

/* Formularis */
.form-control, .form-select {
    border-radius: 8px;
    font-size: 0.875rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.2rem rgba(13,110,253,0.15);
}

.btn {
    border-radius: 8px;
    font-size: 0.875rem;
}

/* Badge arrodonit per imports */
.badge-import {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.4em 0.75em;
    border-radius: 8px;
}

/* Progress bars */
.progress {
    border-radius: 50px;
    background-color: #e9ecef;
}

.ui-progress {
    height: 10px;
}

.ui-progress--sm {
    height: 6px;
}

.ui-progress--lg {
    height: 12px;
}

.pressupostos-llista {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.pressupostos-llista .list-item-card {
    width: 100%;
}

.pressupost-card-grid {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(0, 2.5fr) auto;
    gap: 1rem 1.5rem;
    align-items: center;
}

.pressupost-card-categoria {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.pressupost-card-periode {
    margin-top: 0.15rem;
}

.pressupost-card-categoria .fw-semibold {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pressupost-card-progres {
    min-width: 0;
}

@media (max-width: 767.98px) {
    .pressupost-card-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .pressupost-card-accions {
        justify-self: start;
    }
}

/* Targetes de resum (dashboard) */
.card-resum {
    border-left: 4px solid var(--color-primary);
}

/* Configuració del perfil: layout (menú al sidebar principal) */
.perfil-layout {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    width: 100%;
}

.perfil-layout--sense-nav {
    display: block;
}

.perfil-layout--sense-nav .perfil-layout-contingut {
    width: 100%;
    min-width: 0;
}

.perfil-layout-nav {
    flex: 0 0 220px;
    width: 220px;
    position: sticky;
    top: 1rem;
    background: var(--app-surface, #fff);
    border: 1px solid var(--app-border-strong, #dee2e6);
    border-radius: 0.75rem;
    padding: 0.75rem;
    box-shadow: 0 1px 3px var(--app-shadow, rgba(15, 23, 42, 0.06));
}

.perfil-layout-nav-cap {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--app-text-muted, #6c757d);
    padding: 0.35rem 0.75rem 0.65rem;
}

.perfil-layout-menu .nav-link {
    display: flex;
    align-items: center;
    border-radius: 0.5rem;
    padding: 0.55rem 0.75rem;
    color: var(--app-text, #212529);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.perfil-layout-link:hover {
    background: var(--app-surface-muted, #f8f9fa);
    color: var(--app-text, #212529);
}

.perfil-layout-link.active {
    background: rgba(13, 110, 253, 0.1);
    color: var(--color-primary, #0d6efd);
    font-weight: 600;
}

[data-bs-theme="dark"] .perfil-layout-link.active {
    background: rgba(13, 110, 253, 0.22);
    color: #9ec5fe;
}

.perfil-layout-contingut {
    flex: 1;
    min-width: 0;
}

/* Importació de moviments */
.import-wizard-pasos {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.import-wizard-pas {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--app-text-muted, #6c757d);
    padding: 0.35rem 0.75rem;
    border-radius: 2rem;
    background: var(--app-surface-muted, #f8f9fa);
}

.import-wizard-pas.actiu {
    color: var(--color-primary, #0d6efd);
    background: rgba(13, 110, 253, 0.1);
    font-weight: 600;
}

.import-wizard-pas.completat {
    color: var(--bs-success, #198754);
    background: rgba(25, 135, 84, 0.1);
}

.import-wizard-sep {
    color: var(--app-text-muted, #adb5bd);
    font-size: 0.75rem;
}

.import-formats-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 0.5rem;
    background: var(--app-surface-muted, #f8f9fa);
    border: 1px solid var(--app-border, #e9ecef);
}

.import-format-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.import-format-item i {
    font-size: 1.25rem;
    color: var(--color-primary, #0d6efd);
    margin-top: 0.1rem;
}

.import-format-item span {
    display: block;
    color: var(--app-text-muted, #6c757d);
    font-size: 0.8125rem;
}

.import-mapatge-table th {
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
}

.import-mapatge-col-desti {
    min-width: 220px;
}

.import-exemple-code {
    font-size: 0.8125rem;
    word-break: break-all;
}

.import-preview-table {
    font-size: 0.8125rem;
}

.import-preview-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.import-preview-fletxa {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
}

.import-preview-comptador {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--app-text-muted, #6c757d);
    min-width: 4.5rem;
    text-align: center;
    white-space: nowrap;
}

.import-preview-dl dt {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--app-text-muted, #6c757d);
}

.import-preview-dl dd {
    font-size: 0.875rem;
    margin-bottom: 0.65rem;
}

.import-preview-dl dd:last-child {
    margin-bottom: 0;
}

.import-preview-invalid {
    background: rgba(220, 53, 69, 0.04);
}

.import-preview-loading {
    opacity: 0.55;
    pointer-events: none;
}

.import-resum-list {
    padding-left: 1.25rem;
    font-size: 0.875rem;
    color: var(--app-text, #212529);
}

.import-resum-list li + li {
    margin-top: 0.35rem;
}

@media (max-width: 991px) {
    .perfil-layout {
        flex-direction: column;
        gap: 1rem;
    }

    .perfil-layout-nav {
        position: static;
        width: 100%;
        flex: none;
    }

    .perfil-layout-menu {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .perfil-layout-menu .nav-item {
        flex: 1 1 auto;
    }
}

/* Dashboard: capçaleres de widgets */
.dashboard-widget-cap {
    padding: 1rem 1.25rem;
    background: var(--app-surface-muted, #f8f9fa);
    color: var(--app-text, inherit);
}

.dashboard-widget-cap .h6 {
    color: inherit;
}

/* Dashboard: últimes transaccions per compte */
.dashboard-ultimes {
    margin-bottom: 0.5rem;
}

.dashboard-ultimes-titol {
    margin-bottom: 1rem;
    padding: 0 0.15rem;
}

.dashboard-ultimes-comptes {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dashboard-ultimes-compte-card {
    overflow: hidden;
    border-radius: 0.75rem;
    width: 100%;
}

.dashboard-ultimes-compte-cap {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: var(--app-surface-muted, #f8f9fa);
    transition: background 0.15s ease;
}

.dashboard-ultimes-compte-card:has(.dashboard-ultimes-cos.show) .dashboard-ultimes-compte-cap {
    border-bottom: 1px solid var(--app-border, #e9ecef);
}

.dashboard-ultimes-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 3rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--app-text-muted, #6c757d);
    transition: color 0.15s ease, background 0.15s ease;
}

.dashboard-ultimes-toggle:hover {
    background: var(--app-surface-soft, #f1f3f5);
    color: var(--app-text, inherit);
}

.dashboard-ultimes-chevron {
    font-size: 0.9rem;
    transition: transform 0.2s ease;
}

.dashboard-ultimes-toggle.collapsed .dashboard-ultimes-chevron {
    transform: rotate(-90deg);
}

.dashboard-ultimes-compte-enllac {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
    padding: 1.125rem 1.375rem 1.125rem 0;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.dashboard-ultimes-compte-enllac:hover {
    background: var(--app-surface-soft, #f1f3f5);
    color: inherit;
}

.dashboard-ultimes-compte-info {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    min-width: 0;
}

.dashboard-ultimes-compte-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.dashboard-ultimes-compte-nom {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
}

.dashboard-ultimes-compte-saldo {
    font-size: 0.8125rem;
    font-weight: 600;
}

.dashboard-ultimes-compte-fletxa {
    flex-shrink: 0;
    color: var(--app-text-muted, #6c757d);
    font-size: 0.875rem;
}

.dashboard-ultimes-llista {
    padding: 0.5rem 0;
}

.dashboard-ultimes-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9375rem 1.375rem;
    border-bottom: 1px solid var(--app-border-subtle, #f1f3f5);
}

.dashboard-ultimes-item:last-child {
    border-bottom: none;
}

.dashboard-ultimes-item-meta {
    min-width: 0;
    flex: 1;
}

.dashboard-ultimes-item-data {
    font-size: 0.75rem;
    color: var(--app-text-muted, #6c757d);
    margin-bottom: 0.25rem;
}

.dashboard-ultimes-item-desc {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-ultimes-item-cat {
    font-size: 0.75rem;
    color: var(--app-text-muted, #6c757d);
    margin-top: 0.2rem;
}

.dashboard-ultimes-item-import {
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    padding-top: 1.1rem;
}

.dashboard-ultimes-buit {
    padding: 1.5rem 1.375rem;
    text-align: center;
    color: var(--app-text-muted, #6c757d);
    font-size: 0.875rem;
}

.dashboard-ultimes-buit--compte {
    padding-top: 0.75rem;
    padding-bottom: 1.25rem;
}

/* Login / registre */
body.bg-light {
    background: linear-gradient(135deg, #f0f4ff 0%, #f8f9fa 100%) !important;
}

/* Navbar superior */
.navbar:not(.navbar-app-top) {
    min-height: 56px;
}

/* Scrollbar sidebar */
#sidebar::-webkit-scrollbar {
    width: 4px;
}
#sidebar::-webkit-scrollbar-thumb {
    background: var(--sidebar-scrollbar);
    border-radius: 2px;
}

/* Responsive: sidebar com a panel fix en mòbil */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1050;
        height: 100%;
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        max-width: var(--sidebar-width);
        transform: translateX(0);
        transition: transform 0.25s ease, visibility 0.25s ease;
        visibility: visible;
        pointer-events: auto;
    }

    #sidebar.collapsed {
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        max-width: var(--sidebar-width);
        padding-left: var(--sidebar-padding-x);
        padding-right: var(--sidebar-padding-x);
        transform: translateX(-100%);
        visibility: hidden;
        pointer-events: none;
    }

    #page-content {
        margin-left: 0 !important;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    #page-content main {
        max-width: 100%;
        overflow-x: hidden;
    }

    #wrapper.sidebar-mobile-open .sidebar-backdrop {
        display: block;
    }

    body.sidebar-open {
        overflow: hidden;
    }
}

@media (max-width: 575.98px) {
    #page-content main.p-4 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .form-section {
        padding: 1rem;
    }

    .form-actions-bar {
        padding: 0.85rem 1rem;
        gap: 0.5rem;
    }

    .form-actions-bar .btn {
        flex: 1 1 auto;
    }

    .data-calendari {
        max-width: 100%;
        padding: 0.7rem 0.65rem 0.6rem;
    }

    .data-calendari-dia {
        font-size: 0.82rem;
    }
}

/* Select d'icona amb previsualització */
.select-icona-preview {
    min-width: 3rem;
    justify-content: center;
}

/* Filtres horitzontals de llistats (categories, recurrents, etc.) */
.list-filtres .list-filtre-btn,
.categories-filtres .categories-filtre-btn {
    border-radius: 8px;
    font-size: 0.85rem;
}


/* Icona de color rodona */
.icon-cercle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

/* Textos destacats d'import */
.import-gran {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
}

/* Separadors de grup al sidebar */
#sidebar .nav-link.text-muted {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    pointer-events: none;
    padding: 0.25rem 0.75rem;
}

/* ── Ample de contingut estàndard (llistats, formularis, dashboard…) ── */
.app-page,
.form-page,
.list-page {
    width: 100%;
    max-width: var(--app-content-max, 1200px);
    min-width: 0;
    margin-left: auto;
    margin-right: auto;
}

.form-page--full,
.list-page--full,
.app-page--full {
    max-width: none;
}

/* Detall d'un compte: mateix ample de contingut que Programats */
#txLlistat[data-tx-compte] .list-page,
#txLlistat[data-tx-compte] .list-page--full {
    max-width: var(--app-content-max, 1200px);
}

/* ── Formularis moderns (editar / crear) ── */
.form-page-header {
    margin-bottom: 1.75rem;
    min-width: 0;
    max-width: 100%;
}

.form-page-header .btn-back {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #495057;
    transition: all 0.15s ease;
}

.form-page-header .btn-back:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    color: #212529;
}

.form-page-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    align-items: start;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

@media (min-width: 992px) {
    .form-page-layout {
        grid-template-columns: 280px 1fr;
        gap: 1.5rem;
    }
}

.form-page-aside {
    position: sticky;
    top: 1rem;
}

.form-summary-card {
    background: #fff;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.form-summary-card .summary-accent {
    height: 4px;
    background: linear-gradient(90deg, var(--color-primary), #6610f2);
}

.form-summary-card.summary-ingres .summary-accent {
    background: linear-gradient(90deg, #198754, #20c997);
}

.form-summary-card.summary-gasto .summary-accent {
    background: linear-gradient(90deg, #dc3545, #fd7e14);
}

.form-summary-card.summary-transferencia .summary-accent {
    background: linear-gradient(90deg, #0d6efd, #6610f2);
}

.form-summary-body {
    padding: 1.25rem;
}

.form-summary-import {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.form-summary-meta {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #f1f3f5;
}

.form-summary-meta-item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    font-size: 0.8125rem;
    color: #495057;
}

.form-summary-meta-item i {
    color: #868e96;
    margin-top: 2px;
    flex-shrink: 0;
}

.form-main-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    background: #fff;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
    overflow-x: hidden;
}

.form-section {
    padding: 1.5rem;
    border-bottom: 1px solid #f1f3f5;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #868e96;
    margin-bottom: 1.25rem;
}

.form-section-title i {
    font-size: 0.95rem;
    color: var(--color-primary);
}

.form-field {
    margin-bottom: 1rem;
    min-width: 0;
    max-width: 100%;
}

/* Últim camp directe d'una secció sense marge extra (excepte si s'indica mb-*) */
.form-section > .form-field:last-child:not(.mb-3):not(.mb-4):not(.mb-0) {
    margin-bottom: 0;
}

/* Últim camp d'un bloc condicional (compte/categoria o transferència) abans dels camps comuns */
[data-tipus-camp]:not(.d-none) > .form-field:last-child {
    margin-bottom: 1.5rem;
}

.form-section .form-field.mb-3 {
    margin-bottom: 1rem;
}

.form-section .form-field.mb-4 {
    margin-bottom: 1.5rem;
}

.form-field-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #343a40;
    margin-bottom: 0.4rem;
}

.form-field-hint {
    font-size: 0.75rem;
    color: #868e96;
    margin-top: 0.35rem;
}

.form-input-icon {
    position: relative;
    min-width: 0;
    max-width: 100%;
}

.form-input-icon > i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
    pointer-events: none;
    z-index: 2;
}

.form-input-icon .form-control,
.form-input-icon .form-select {
    padding-left: 2.35rem;
    border-color: #e9ecef;
    background: #fafbfc;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.form-input-icon .form-control:focus,
.form-input-icon .form-select:focus {
    background: #fff;
}

.form-input-lg .form-control {
    font-size: 1.35rem;
    font-weight: 600;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    letter-spacing: -0.01em;
}

/* Autocompletat de descripcions de transaccions */
.form-descripcio-autocomplete {
    position: relative;
}

.descripcio-suggeriments {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.25rem);
    z-index: 20;
    margin: 0;
    padding: 0.35rem 0;
    list-style: none;
    max-height: 14rem;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    background: #fff;
    box-shadow: 0 0.5rem 1.25rem rgba(33, 37, 41, 0.12);
}

.descripcio-suggeriment {
    padding: 0.45rem 0.85rem 0.45rem 2.35rem;
    cursor: pointer;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.descripcio-suggeriment:hover,
.descripcio-suggeriment.is-active {
    background: #f1f3f5;
}

/* Selector de freqüència tipus targeta */
.freq-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

@media (min-width: 576px) {
    .freq-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.freq-grid--3 {
    grid-template-columns: repeat(3, 1fr);
}

.freq-grid.freq-grid--dues {
    grid-template-columns: repeat(2, 1fr);
}

.freq-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.freq-option label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.65rem 0.35rem;
    border: 1.5px solid #e9ecef;
    border-radius: 12px;
    background: #fafbfc;
    font-size: 0.75rem;
    font-weight: 600;
    color: #495057;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    min-height: 64px;
}

.freq-option label i {
    font-size: 1.1rem;
    color: #adb5bd;
    transition: color 0.15s;
}

.freq-option input:checked + label {
    border-color: var(--color-primary);
    background: rgba(13, 110, 253, 0.06);
    color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

.freq-option input:checked + label i {
    color: var(--color-primary);
}

.freq-option label:hover {
    border-color: #ced4da;
    background: #fff;
}

/* Botons toggle de comptes al perfil (agrupar gràfic) */
.perfil-comptes-toggles {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
}

@media (min-width: 576px) {
    .perfil-comptes-toggles {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 768px) {
    .perfil-comptes-toggles {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.perfil-compte-toggle {
    position: relative;
    min-width: 0;
    width: 100%;
}

.perfil-compte-toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.perfil-compte-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 0.85rem;
    border: 1.5px solid #e9ecef;
    border-radius: 12px;
    background: #fafbfc;
    color: #495057;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.perfil-compte-toggle-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.perfil-compte-toggle-nom {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.perfil-compte-toggle-check {
    font-size: 0.95rem;
    color: #ced4da;
    flex-shrink: 0;
    margin-left: auto;
    transition: color 0.15s ease, transform 0.15s ease;
}

.perfil-compte-toggle-btn:hover {
    border-color: #ced4da;
    background: #fff;
}

.perfil-compte-toggle-input:focus-visible + .perfil-compte-toggle-btn {
    outline: 2px solid rgba(13, 110, 253, 0.35);
    outline-offset: 2px;
}

.perfil-compte-toggle-input:checked + .perfil-compte-toggle-btn {
    border-color: var(--color-primary);
    background: rgba(13, 110, 253, 0.08);
    color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

.perfil-compte-toggle-input:checked + .perfil-compte-toggle-btn .perfil-compte-toggle-check {
    color: var(--color-primary);
    transform: scale(1.08);
}

/* Toggle estat actiu */
.form-status-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
    border-radius: 12px;
    border: 1.5px solid #e9ecef;
    background: #fafbfc;
    transition: border-color 0.15s, background 0.15s;
}

.form-status-card.is-active {
    border-color: rgba(25, 135, 84, 0.35);
    background: rgba(25, 135, 84, 0.04);
}

.form-status-card .form-check-input {
    width: 2.75rem;
    height: 1.4rem;
    cursor: pointer;
}

.form-status-card .form-check-input:checked {
    background-color: var(--color-success);
    border-color: var(--color-success);
}

/* Peu del formulari amb accions */
.form-actions-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1.15rem 1.5rem;
    background: #fafbfc;
    border-top: 1px solid #f1f3f5;
    border-radius: 0 0 16px 16px;
}

.form-actions-bar .btn-primary {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
    font-weight: 600;
}

.form-alert-modern {
    border-radius: 12px;
}

.form-page-layout-single {
    grid-template-columns: 1fr !important;
}

.form-page-layout-single .form-main-card {
    max-width: none;
    width: 100%;
}

/* Resum del compte a dalt, amplada completa (editar compte) */
.form-page-layout-aside-top {
    grid-template-columns: 1fr !important;
}

.form-page-layout-aside-top .form-page-aside {
    position: static;
    width: 100%;
}

.compte-editar-resum {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    width: 100%;
}

.compte-editar-resum-esquerra {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    min-width: 0;
    flex: 1;
}

.compte-editar-resum-text {
    min-width: 0;
    flex: 1;
}

.compte-editar-resum-saldo {
    flex-shrink: 0;
    font-size: 1.75rem;
    margin: 0;
    margin-left: auto;
    text-align: right;
    align-self: center;
}

.compte-editar-resum-meta {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    margin-top: 0.35rem;
    padding-top: 0;
    border-top: none;
}

@media (max-width: 575px) {
    .compte-editar-resum {
        flex-direction: column;
        align-items: stretch;
    }

    .compte-editar-resum-saldo {
        margin-left: 0;
        text-align: left;
        align-self: flex-start;
    }
}

/* Selector tipus ingrés/despesa tipus targeta */
.tipus-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.tipus-grid--tres {
    grid-template-columns: 1fr 1fr 1fr;
}

.tipus-option {
    min-width: 0;
}

.tipus-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tipus-option label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    border: 1.5px solid #e9ecef;
    border-radius: 12px;
    background: #fafbfc;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    white-space: normal;
    line-height: 1.2;
    hyphens: auto;
}

.tipus-option label i { font-size: 1.15rem; }

.tipus-option input:checked + label.tipus-gasto {
    border-color: #dc3545;
    background: rgba(220, 53, 69, 0.06);
    color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.12);
}

.tipus-option input:checked + label.tipus-ingres {
    border-color: #198754;
    background: rgba(25, 135, 84, 0.06);
    color: #198754;
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.12);
}

.tipus-option input:checked + label.tipus-transferencia {
    border-color: #0d6efd;
    background: rgba(13, 110, 253, 0.06);
    color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

.tipus-option label:hover { background: #fff; border-color: #ced4da; }

@media (max-width: 575.98px) {
    .tipus-grid--tres {
        gap: 0.4rem;
    }

    .tipus-option label {
        flex-direction: column;
        gap: 0.2rem;
        padding: 0.55rem 0.25rem;
        font-size: 0.72rem;
    }

    .tipus-option label i {
        font-size: 1rem;
    }
}

.form-summary-card.summary-primary .summary-accent {
    background: linear-gradient(90deg, var(--color-primary), #6610f2);
}

.form-summary-card.summary-info .summary-accent {
    background: linear-gradient(90deg, #0dcaf0, var(--color-primary));
}

/* ── Llistats moderns ── */
.list-page-header .btn-primary {
    font-weight: 600;
    padding-left: 1rem;
    padding-right: 1rem;
}

.list-card,
.list-table-card,
.list-filters-card {
    background: #fff;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.list-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f3f5;
    background: #fafbfc;
}

.list-filters-body {
    padding: 1rem 1.25rem;
}

.tx-filtres-form {
    --bs-gutter-x: 0.5rem;
    margin-left: 0;
    margin-right: 0;
    width: 100%;
}

.tx-filtres-form > [class*="col"] {
    min-width: 0;
}

@media (max-width: 575.98px) {
    .tx-filtres-form > .col-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

.list-table thead th {
    background: #fafbfc;
    border-bottom: 1px solid #f1f3f5;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #868e96;
    padding: 0.85rem 1rem;
}

.list-table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f8f9fa;
}

.list-table tbody tr:last-child td {
    border-bottom: none;
}

.list-table tbody tr:hover {
    background: rgba(13, 110, 253, 0.02);
}

/* Contenidor responsive del gràfic de projecció de saldo */
.projeccio-grafic-wrap {
    position: relative;
    width: 100%;
    min-width: 0;
    /* Alçada suficient per llegir el gràfic en qualsevol viewport */
    height: clamp(320px, 55vh, 520px);
    min-height: 320px;
}

.projeccio-grafic-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* Taula de moviments projectats */
.proj-moviments {
    background: #fff;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.proj-moviments-cap {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid #f1f3f5;
    background: #fafbfc;
}

.proj-moviments-titol {
    margin: 0;
    font-size: 1rem;
    font-weight: 650;
    color: #212529;
}

.proj-moviments-sub {
    margin-top: 0.35rem;
    font-size: 0.8125rem;
    color: #868e96;
}

.proj-moviments-compte + .proj-moviments-compte {
    border-top: 1px solid #f1f3f5;
}

.proj-moviments-compte-cap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.25rem;
    width: 100%;
    padding: 0.9rem 1.5rem;
    margin: 0;
    border: 0;
    border-bottom: 1px solid #f1f3f5;
    background: #f8f9fa;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.proj-moviments-compte-cap:hover {
    background: #f1f3f5;
}

.proj-moviments-compte-cap:focus-visible {
    outline: 2px solid rgba(13, 110, 253, 0.35);
    outline-offset: -2px;
    z-index: 1;
}

.proj-moviments-compte-titol {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.9375rem;
    font-weight: 650;
    color: #212529;
}

.proj-moviments-compte-chevron {
    font-size: 0.85rem;
    color: #868e96;
    transition: transform 0.2s ease;
}

.proj-moviments-compte-cap.collapsed .proj-moviments-compte-chevron {
    transform: rotate(-90deg);
}

.proj-moviments-compte-cap.collapsed {
    border-bottom-color: transparent;
}

.proj-moviments-compte-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.proj-moviments-compte-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    height: 1.4rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.06);
    color: #6c757d;
    font-size: 0.75rem;
    font-weight: 600;
}

.proj-moviments-compte-saldos {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.list-table--proj-moviments {
    width: 100%;
}

.list-table--proj-moviments thead th {
    padding: 0.95rem 1.5rem;
}

.list-table--proj-moviments tbody td {
    padding: 1rem 1.5rem;
}

.list-table--proj-moviments .proj-mov-data {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #868e96;
    font-variant-numeric: tabular-nums;
}

.proj-mov-pendent {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
}

.proj-mov-pendent-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: rgba(255, 193, 7, 0.18);
    color: #997404;
    font-size: 0.6875rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.list-table--proj-moviments .proj-mov-desc {
    font-weight: 600;
    color: #212529;
}

.list-table--proj-moviments .proj-mov-compte {
    font-size: 0.875rem;
    color: #6c757d;
}

.list-table--proj-moviments .proj-mov-import {
    font-variant-numeric: tabular-nums;
    font-size: 0.9375rem;
}

.list-table--proj-moviments .proj-mov-saldo {
    font-size: 0.875rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 767.98px) {
    .list-table--proj-moviments thead {
        display: none;
    }

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

    .list-table--proj-moviments tbody tr {
        padding: 1rem 1.25rem;
        border-bottom: 1px solid #f1f3f5;
    }

    .list-table--proj-moviments tbody tr:last-child {
        border-bottom: none;
    }

    .list-table--proj-moviments tbody td {
        padding: 0.15rem 0;
        border: none;
        text-align: left !important;
    }

    .list-table--proj-moviments tbody td:first-child {
        margin-bottom: 0.15rem;
    }

    .list-table--proj-moviments .proj-mov-desc {
        margin-bottom: 0.25rem;
    }
}

/* Selecció múltiple de transaccions */
.tx-massa-th-check,
.tx-massa-td-check {
    width: 2.5rem;
    padding-left: 0.75rem !important;
    padding-right: 0.25rem !important;
    vertical-align: middle;
}

/* Amplades de columnes uniformes entre taules mensuals de transaccions */
.tx-llistat-transaccions .list-table--transaccions {
    table-layout: fixed;
    width: 100%;
}

.tx-llistat-transaccions .list-table--transaccions .col-tx-check {
    width: 2.75rem;
}

.tx-llistat-transaccions .list-table--transaccions .col-tx-accions {
    width: 7.5rem;
}

.tx-llistat-transaccions.tx-llistat-transaccions--amb-compte .list-table--transaccions .col-tx-data {
    width: 6.5rem;
}

.tx-llistat-transaccions.tx-llistat-transaccions--amb-compte .list-table--transaccions .col-tx-desc {
    width: 28%;
}

.tx-llistat-transaccions.tx-llistat-transaccions--amb-compte .list-table--transaccions .col-tx-compte {
    width: 14%;
}

.tx-llistat-transaccions.tx-llistat-transaccions--amb-compte .list-table--transaccions .col-tx-categoria {
    width: 15%;
}

.tx-llistat-transaccions.tx-llistat-transaccions--amb-compte .list-table--transaccions .col-tx-import {
    width: 14%;
}

.tx-llistat-transaccions.tx-llistat-transaccions--sense-compte .list-table--transaccions .col-tx-data {
    width: 7rem;
}

.tx-llistat-transaccions.tx-llistat-transaccions--sense-compte .list-table--transaccions .col-tx-desc {
    width: 36%;
}

.tx-llistat-transaccions.tx-llistat-transaccions--sense-compte .list-table--transaccions .col-tx-categoria {
    width: 18%;
}

.tx-llistat-transaccions.tx-llistat-transaccions--sense-compte .list-table--transaccions .col-tx-import {
    width: 15%;
}

.tx-cel-import-saldo {
    vertical-align: middle;
    line-height: 1.25;
}

.tx-cel-import-saldo,
.tx-th-import {
    white-space: nowrap;
    padding-right: 2.75rem !important;
}

.tx-llistat-transaccions .list-table--transaccions .tx-cel-accions {
    padding-left: 1.5rem !important;
}

.tx-import-valor {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.2;
}

.tx-saldo-valor {
    margin-top: 0.2rem;
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.75;
}

.tx-llistat-transaccions .list-table--transaccions td {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Llistat de transaccions: targetes en tablet i mòbil */
@media (max-width: 991.98px) {
    .tx-llistat-transaccions .list-table-card .table-responsive {
        overflow-x: visible;
    }

    .tx-llistat-transaccions .list-table--transaccions {
        table-layout: auto;
        display: block;
    }

    .tx-llistat-transaccions .list-table--transaccions colgroup {
        display: none;
    }

    .tx-llistat-transaccions .list-table--transaccions thead {
        display: none;
    }

    .tx-llistat-transaccions .list-table--transaccions tbody {
        display: block;
    }

    .tx-llistat-transaccions .list-table--transaccions tbody tr {
        display: grid;
        grid-template-columns: 2.25rem 1fr min-content;
        gap: 0.2rem 0.65rem;
        padding: 0.85rem 1rem;
        border-bottom: 1px solid var(--app-border, #f1f3f5);
        align-items: start;
    }

    .tx-llistat-transaccions .list-table--transaccions tbody tr:last-child {
        border-bottom: none;
    }

    .tx-llistat-transaccions .list-table--transaccions tbody td {
        display: block;
        width: auto;
        padding: 0;
        border: none;
    }

    .tx-llistat-transaccions .list-table--transaccions .tx-massa-td-check {
        grid-column: 1;
        grid-row: 1 / -1;
        align-self: start;
        padding-top: 0.15rem;
    }

    .tx-llistat-transaccions .list-table--transaccions .tx-cel-import-saldo {
        grid-column: 3;
        align-self: start;
        text-align: right;
        padding-right: 0 !important;
        white-space: nowrap;
    }

    .tx-llistat-transaccions .list-table--transaccions .tx-cel-accions {
        grid-column: 3;
        justify-self: end;
        align-self: end;
        padding-left: 0 !important;
    }

    .tx-llistat-transaccions.tx-llistat-transaccions--sense-compte .list-table--transaccions .tx-cel-import-saldo {
        grid-row: 1 / 3;
    }

    .tx-llistat-transaccions.tx-llistat-transaccions--sense-compte .list-table--transaccions .tx-cel-accions {
        grid-row: 3;
    }

    .tx-llistat-transaccions.tx-llistat-transaccions--amb-compte .list-table--transaccions .tx-cel-import-saldo {
        grid-row: 1 / 4;
    }

    .tx-llistat-transaccions.tx-llistat-transaccions--amb-compte .list-table--transaccions .tx-cel-accions {
        grid-row: 4;
    }

    .tx-llistat-transaccions .list-table--transaccions .tx-cel-accions .list-stacked-actions--inline {
        flex-wrap: nowrap;
        gap: 0.25rem;
    }

    /* Sense columna de compte (filtre per compte) */
    .tx-llistat-transaccions.tx-llistat-transaccions--sense-compte .list-table--transaccions tbody td:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
    }

    .tx-llistat-transaccions.tx-llistat-transaccions--sense-compte .list-table--transaccions tbody td:nth-child(3) {
        grid-column: 2;
        grid-row: 2;
    }

    .tx-llistat-transaccions.tx-llistat-transaccions--sense-compte .list-table--transaccions tbody td:nth-child(4) {
        grid-column: 2;
        grid-row: 3;
        font-size: 0.8125rem;
    }

    /* Amb columna de compte */
    .tx-llistat-transaccions.tx-llistat-transaccions--amb-compte .list-table--transaccions tbody td:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
    }

    .tx-llistat-transaccions.tx-llistat-transaccions--amb-compte .list-table--transaccions tbody td:nth-child(3) {
        grid-column: 2;
        grid-row: 2;
    }

    .tx-llistat-transaccions.tx-llistat-transaccions--amb-compte .list-table--transaccions tbody td:nth-child(4) {
        grid-column: 2;
        grid-row: 3;
        font-size: 0.8125rem;
    }

    .tx-llistat-transaccions.tx-llistat-transaccions--amb-compte .list-table--transaccions tbody td:nth-child(5) {
        grid-column: 2;
        grid-row: 4;
        font-size: 0.8125rem;
    }

    .tx-llistat-transaccions .list-table--transaccions .list-action-icon {
        width: 34px;
        height: 34px;
        font-size: 0.925rem;
    }

    .tx-llistat-transaccions .tx-mes-stats {
        flex-wrap: wrap;
    }
}

@media (max-width: 575.98px) {
    .tx-llistat-transaccions .list-table--transaccions tbody tr {
        padding: 0.75rem 0.85rem;
        gap: 0.15rem 0.5rem;
    }

    .tx-llistat-transaccions .tx-import-valor {
        font-size: 1rem;
    }

    .tx-llistat-transaccions .tx-saldo-valor {
        font-size: 0.75rem;
    }
}

.tx-massa-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border-strong);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--app-shadow);
}

.tx-massa-bar-info {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--app-text);
}

.tx-massa-bar-accions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.tx-massa-bar-accions .form-select {
    min-width: 11rem;
}

.list-table tbody tr.tx-massa-row-selected {
    background: rgba(13, 110, 253, 0.06);
}

.tx-etiquetes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.tx-etiqueta-badge {
    font-weight: 500;
    font-size: 0.7rem;
}

.form-input-etiquetes .ts-control {
    min-height: 2.5rem;
    padding-left: 2.25rem;
}

.form-input-etiquetes,
.form-input-etiquetes .ts-wrapper,
.form-descripcio-autocomplete {
    min-width: 0;
    max-width: 100%;
}

.form-input-etiquetes .ts-wrapper {
    width: 100%;
}

.form-input-etiquetes > i {
    z-index: 2;
}

.list-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    background: #fff;
    border-radius: 16px;
    border: 1px dashed #dee2e6;
    color: #868e96;
}

.list-empty i {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

.list-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.list-stat-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    background: #fff;
    border: 1px solid #e9ecef;
}

.list-stat-success { color: #198754; background: rgba(25,135,84,0.06); border-color: rgba(25,135,84,0.2); }
.list-stat-danger  { color: #dc3545; background: rgba(220,53,69,0.06);  border-color: rgba(220,53,69,0.2); }
.list-stat-default { color: #495057; background: #fafbfc; }

.tx-mes-bloc + .tx-mes-bloc {
    margin-top: 2rem;
}

.recurrents-mes-bloc + .recurrents-mes-bloc {
    margin-top: 2rem;
}

.tx-mes-stats {
    width: 100%;
    justify-content: flex-start;
    gap: 1rem;
}

.tx-mes-stats .list-stat-item {
    padding: 0;
    background: transparent !important;
    border: none !important;
    border-radius: 0;
    font-size: 0.8125rem;
    font-weight: 500;
}

.tx-mes-stats .list-stat-success {
    color: #198754;
}

.tx-mes-stats .list-stat-danger {
    color: #dc3545;
}

.tx-mes-stats .list-stat-default {
    color: #6c757d;
    background: transparent !important;
}

.tx-mes-stat-saldo {
    margin-left: auto;
}

[data-bs-theme="dark"] .tx-mes-stats .list-stat-success {
    color: #75b798;
}

[data-bs-theme="dark"] .tx-mes-stats .list-stat-danger {
    color: #ea868f;
}

[data-bs-theme="dark"] .tx-mes-stats .list-stat-default {
    color: var(--app-text-muted);
    background: transparent !important;
}

.list-grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.list-stack-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.list-stack-cards .list-item-card {
    height: auto;
}

.objectius-llista,
.deutes-llista {
    width: 100%;
}

.objectius-llista .list-item-card {
    width: 100%;
}

.compte-card-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.compte-drag-handle {
    border: none;
    background: transparent;
    color: #adb5bd;
    cursor: grab;
    padding: 0.35rem 0.25rem;
    flex-shrink: 0;
    line-height: 1;
    border-radius: 8px;
}

.compte-drag-handle:hover {
    color: #6c757d;
    background: #f8f9fa;
}

.compte-drag-handle:active {
    cursor: grabbing;
}

.compte-card-info {
    flex: 1 1 auto;
    min-width: 0;
}

.compte-card-saldo {
    flex: 0 0 auto;
    text-align: right;
    min-width: 120px;
}

.compte-card-accions {
    flex: 0 0 auto;
}

.compte-card-ghost {
    opacity: 0.45;
}

.comptes-grups-llista {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Llista de comptes: aspecte neutre sense colors de compte/grup */
.comptes-grups-llista .compte-grup-bloc:not(.compte-grup-bloc--0) {
    border-left: 4px solid var(--app-border-strong, #dee2e6);
}

.comptes-grups-llista .list-item-card[class*="list-item-card--compte-"] {
    border-width: 1px;
    border-color: var(--app-border, rgba(0, 0, 0, 0.06));
}

.comptes-grups-llista .list-item-card[class*="list-item-card--compte-"]:hover {
    border-color: var(--app-border-strong, #dee2e6);
}

.comptes-grups-llista .compte-card-icon:not(.compte-icona-wrap--imatge) {
    background: var(--app-text-muted, #6c757d) !important;
}

.compte-grup-bloc {
    background: #fff;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.compte-grup-bloc--0 {
    border-left: 4px solid #dee2e6;
}

.compte-grup-cap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: #fafbfc;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.compte-grup-drag-handle {
    border: none;
    background: transparent;
    color: #adb5bd;
    cursor: grab;
    padding: 0.35rem 0.25rem;
    flex-shrink: 0;
    line-height: 1;
    border-radius: 8px;
}

.compte-grup-drag-handle:hover {
    color: #6c757d;
    background: #eef1f4;
}

.compte-grup-drag-handle:active {
    cursor: grabbing;
}

.compte-grup-cap-info {
    flex: 1 1 auto;
    min-width: 0;
}

.compte-grup-cap-nom {
    font-weight: 600;
    font-size: 1rem;
}

.compte-grup-dot {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
    display: inline-block;
    background: #dee2e6;
}

.comptes-grup-llista {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 3.5rem;
}

.comptes-grup-llista:empty {
    margin: 0.75rem;
    border: 1px dashed #dee2e6;
    border-radius: 10px;
    background: #fafbfc;
}

.comptes-grup-llista:empty::after {
    content: 'Arrossega comptes aquí';
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    color: #adb5bd;
    font-size: 0.8125rem;
}

.comptes-grup-llista .list-item-card {
    margin: 0;
}

.compte-grup-bloc--sense-drag .compte-grup-cap {
    padding-left: 1rem;
}

@media (max-width: 767.98px) {
    .compte-card-row {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .compte-card-saldo {
        width: 100%;
        text-align: left;
        padding-left: 2rem;
    }

    .compte-card-accions {
        margin-left: auto;
    }
}

.list-item-card {
    background: #fff;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
    padding: 1.25rem;
    height: 100%;
    transition: box-shadow 0.15s ease;
}

.list-item-card:hover {
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.1);
}

.list-item-card.inactiu {
    opacity: 0.55;
}

.compte-card-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    max-width: 40px;
    max-height: 40px;
    flex-shrink: 0;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0 !important;
    overflow: hidden;
    border-radius: 50% !important;
    line-height: 1;
}

.compte-card-icon > .bi {
    font-size: 1.1rem;
    line-height: 1;
}

.compte-icona-imatge {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.compte-icona-wrap--imatge,
.sidebar-compte-icon.compte-icona-wrap--imatge,
.badge.compte-icona-wrap--imatge {
    background: #fff !important;
    padding: 0 !important;
}

.sidebar-compte-icon .compte-icona-imatge {
    border-radius: 6px;
    object-fit: cover;
}

.compte-icona-preview-form {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #fff;
    padding: 2px;
    object-fit: contain;
}

.list-item-card .dropdown .btn {
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.list-actions .btn {
    border-radius: 8px;
}

.list-actions .btn-sm {
    padding: 0.25rem 0.5rem;
}

/* Llistat apilat: cada registre és una targeta independent */
.list-stacked {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Graella de moviments programats: 3 columnes (escriptori), 1 (mòbil) */
.recurrents-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 992px) {
    .recurrents-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.recurrents-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
}

.recurrents-card .list-stacked-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
}

.recurrents-card .list-stacked-meta-sep {
    display: none;
}

.recurrents-card .list-stacked-chips {
    margin-bottom: 0.5rem;
}

.recurrents-card .list-stacked-actions {
    margin-top: auto;
    flex-wrap: wrap;
}

.list-stacked-item {
    background: #fff;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
    padding: 1.15rem 1.25rem;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.list-stacked-item:hover {
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.1);
}

.list-stacked-item.inactiu {
    opacity: 0.55;
}

.list-stacked-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.list-stacked-title {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    min-width: 0;
}

.list-stacked-title strong {
    font-size: 0.9375rem;
    line-height: 1.35;
    word-break: break-word;
}

.list-stacked-import {
    font-size: 1.05rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.list-stacked-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.65rem;
    font-size: 0.8125rem;
    color: #6c757d;
    margin-bottom: 0.75rem;
}

.list-stacked-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.list-stacked-meta-item i {
    font-size: 0.85rem;
    opacity: 0.7;
}

.list-stacked-meta-sep {
    color: #dee2e6;
    user-select: none;
}

.list-stacked-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #f1f3f5;
    color: #495057;
}

.list-stacked-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0;
}

.list-stacked-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    padding-top: 0.85rem;
    margin-top: 0.85rem;
    border-top: 1px solid #f1f3f5;
}

/* Dins de taules o capçaleres de targeta: sense separador */
.list-stacked-actions--inline {
    padding-top: 0;
    margin-top: 0;
    border-top: none;
}

.list-action-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    height: 38px;
    padding: 0 0.85rem;
    border-radius: 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: opacity 0.15s ease, transform 0.1s ease;
}

.list-action-primary:hover {
    opacity: 0.92;
    color: #fff;
}

.list-action-primary:active {
    transform: scale(0.98);
}

.list-action-tools {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.list-action-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1.5px solid #e9ecef;
    background: #fafbfc;
    color: #495057;
    font-size: 1rem;
    text-decoration: none;
    transition: all 0.15s ease;
}

.list-action-icon:hover {
    background: #fff;
    border-color: #ced4da;
    color: #212529;
}

.list-action-icon-warning:hover {
    background: rgba(255, 193, 7, 0.1);
    border-color: rgba(255, 193, 7, 0.45);
    color: #997404;
}

.list-action-icon-danger:hover {
    background: rgba(220, 53, 69, 0.08);
    border-color: rgba(220, 53, 69, 0.35);
    color: #dc3545;
}

@media (max-width: 400px) {
    .list-stacked-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}

.form-info-banner {
    background: rgba(13, 110, 253, 0.06);
    border: 1px solid rgba(13, 110, 253, 0.15);
    border-radius: 12px;
    padding: 1rem 1.15rem;
    font-size: 0.875rem;
    color: #084298;
    margin-bottom: 1.25rem;
}

/* ── Modal de confirmació modern ── */
.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(1.25rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.confirm-modal.is-open {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
}

.confirm-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.confirm-modal.is-open .confirm-modal-backdrop {
    opacity: 1;
}

.confirm-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 420px);
    margin: auto;
    background: #fff;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow:
        0 0 0 1px rgba(15, 23, 42, 0.04),
        0 8px 16px rgba(15, 23, 42, 0.06),
        0 32px 64px rgba(15, 23, 42, 0.16);
    padding: 2rem 1.75rem 1.5rem;
    text-align: center;
    transform: scale(0.88) translateY(20px);
    opacity: 0;
    transition:
        transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.22s ease;
}

.confirm-modal.is-open .confirm-modal-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.confirm-modal-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #adb5bd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.confirm-modal-close:hover {
    background: #f1f3f5;
    color: #495057;
}

.confirm-modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.15rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.65rem;
    background: rgba(220, 53, 69, 0.1);
    color: var(--color-danger);
    box-shadow: 0 0 0 8px rgba(220, 53, 69, 0.06);
}

.confirm-modal.is-warning .confirm-modal-icon {
    background: rgba(255, 193, 7, 0.15);
    color: #997404;
    box-shadow: 0 0 0 8px rgba(255, 193, 7, 0.08);
}

.confirm-modal.is-primary .confirm-modal-icon {
    background: rgba(13, 110, 253, 0.1);
    color: var(--color-primary);
    box-shadow: 0 0 0 8px rgba(13, 110, 253, 0.06);
}

.confirm-modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #212529;
    margin: 0 0 0.55rem;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.confirm-modal-message {
    font-size: 0.9375rem;
    color: #6c757d;
    margin: 0 0 1.5rem;
    line-height: 1.55;
    max-width: 32ch;
    margin-left: auto;
    margin-right: auto;
}

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

.confirm-modal-actions .btn {
    flex: 1;
    padding: 0.65rem 1.1rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.875rem;
    transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.confirm-modal-actions .btn:active {
    transform: scale(0.97);
}

.confirm-modal-btn-cancel {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    color: #495057;
}

.confirm-modal-btn-cancel:hover {
    background: #e9ecef;
    border-color: #dee2e6;
    color: #212529;
}

.confirm-modal-btn-ok {
    background: var(--color-danger);
    border: 1px solid var(--color-danger);
    color: #fff;
    box-shadow: 0 4px 14px rgba(220, 53, 69, 0.28);
}

.confirm-modal-btn-ok:hover {
    background: #bb2d3b;
    border-color: #b02a37;
    color: #fff;
    box-shadow: 0 6px 18px rgba(220, 53, 69, 0.32);
}

.confirm-modal.is-warning .confirm-modal-btn-ok {
    background: var(--color-warning);
    border-color: var(--color-warning);
    color: #212529;
    box-shadow: 0 4px 14px rgba(255, 193, 7, 0.35);
}

.confirm-modal.is-warning .confirm-modal-btn-ok:hover {
    background: #e0a800;
    border-color: #d39e00;
    color: #212529;
}

.confirm-modal.is-primary .confirm-modal-btn-ok {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(13, 110, 253, 0.28);
}

.confirm-modal.is-primary .confirm-modal-btn-ok:hover {
    background: #0b5ed7;
    border-color: #0a58ca;
}

body.confirm-modal-open {
    overflow: hidden;
}

@media (max-width: 480px) {
    .confirm-modal-dialog {
        padding: 1.75rem 1.25rem 1.25rem;
        border-radius: 18px;
    }

    .confirm-modal-actions {
        flex-direction: column-reverse;
    }
}

/* ── Mode fosc: components personalitzats ── */
[data-bs-theme="dark"] body {
    background-color: var(--color-bg);
    color: var(--app-text);
}

[data-bs-theme="dark"] #page-content main {
    background-color: var(--color-bg);
}

[data-bs-theme="dark"] .list-item-card,
[data-bs-theme="dark"] .form-summary-card,
[data-bs-theme="dark"] .form-card,
[data-bs-theme="dark"] .dashboard-card,
[data-bs-theme="dark"] .dashboard-ultimes-compte-card,
[data-bs-theme="dark"] .compte-grup-bloc,
[data-bs-theme="dark"] .ui-list-cap,
[data-bs-theme="dark"] .confirm-modal-dialog {
    background: var(--app-surface);
    border-color: var(--app-border);
    color: var(--app-text);
}

[data-bs-theme="dark"] .list-item-card:hover,
[data-bs-theme="dark"] .compte-grup-bloc:hover {
    box-shadow: 0 8px 24px var(--app-shadow);
}

[data-bs-theme="dark"] .perfil-layout-nav,
[data-bs-theme="dark"] .dashboard-widget-cap,
[data-bs-theme="dark"] .dashboard-ultimes-compte-cap,
[data-bs-theme="dark"] .compte-grup-cap,
[data-bs-theme="dark"] .form-page-header .btn-back,
[data-bs-theme="dark"] .list-stat-default,
[data-bs-theme="dark"] .tipus-option label,
[data-bs-theme="dark"] .comptes-grup-llista:empty {
    background: var(--app-surface-muted);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .comptes-grup-llista:empty::after {
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .perfil-layout-link:hover,
[data-bs-theme="dark"] .dashboard-ultimes-toggle:hover,
[data-bs-theme="dark"] .dashboard-ultimes-compte-enllac:hover,
[data-bs-theme="dark"] .form-page-header .btn-back:hover,
[data-bs-theme="dark"] .tipus-option label:hover {
    background: var(--app-surface-soft);
    color: var(--app-text);
}

/* Mode fosc: formularis crear / editar / perfil */
[data-bs-theme="dark"] .form-main-card {
    background: var(--app-surface);
    border-color: var(--app-border);
    color: var(--app-text);
    box-shadow: 0 4px 24px var(--app-shadow);
}

[data-bs-theme="dark"] .form-page-header .fw-semibold,
[data-bs-theme="dark"] .form-page-header .h4 {
    color: var(--app-text);
}

[data-bs-theme="dark"] .form-section {
    border-bottom-color: var(--app-border-strong);
}

[data-bs-theme="dark"] .form-section-title {
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .form-section-title i {
    color: #6ea8fe;
}

[data-bs-theme="dark"] .form-field-label {
    color: var(--app-text);
}

[data-bs-theme="dark"] .form-field-hint {
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .form-field-hint a {
    color: #9ec5fe;
}

[data-bs-theme="dark"] .form-field-hint a:hover {
    color: #cfe2ff;
}

[data-bs-theme="dark"] .form-input-icon > i {
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .descripcio-suggeriments {
    border-color: var(--app-border, #343a40);
    background: var(--app-surface, #212529);
    box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.45);
}

[data-bs-theme="dark"] .descripcio-suggeriment {
    color: var(--app-text, #e9ecef);
}

[data-bs-theme="dark"] .descripcio-suggeriment:hover,
[data-bs-theme="dark"] .descripcio-suggeriment.is-active {
    background: rgba(255, 255, 255, 0.08);
}

/* Calendari en línia (camp de data de transaccions) */
.form-field--calendari {
    position: relative;
    max-width: 100%;
    overflow: hidden;
}

.data-calendari-input-natiu {
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.data-calendari {
    width: 100%;
    max-width: 22rem;
    box-sizing: border-box;
    border: 1px solid #e9ecef;
    border-radius: 0.75rem;
    background: #fff;
    padding: 0.85rem 0.9rem 0.75rem;
    box-shadow: 0 0.25rem 0.75rem rgba(33, 37, 41, 0.06);
}

.data-calendari-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}

.data-calendari-titol {
    font-weight: 600;
    font-size: 0.95rem;
    color: #212529;
    text-align: center;
    flex: 1;
    letter-spacing: -0.01em;
}

.data-calendari-nav {
    width: 2rem;
    height: 2rem;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    background: #f8f9fa;
    color: #495057;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.data-calendari-nav:hover {
    background: #eef1f4;
    color: #212529;
}

.data-calendari-cap,
.data-calendari-graella {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.2rem;
}

.data-calendari-cap {
    margin-bottom: 0.35rem;
}

.data-calendari-dow {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: #adb5bd;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding: 0.15rem 0;
}

.data-calendari-dia {
    aspect-ratio: 1;
    width: 100%;
    min-width: 0;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: #212529;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0;
    line-height: 1;
    transition: background 0.12s, color 0.12s;
}

.data-calendari-dia:hover {
    background: #f1f3f5;
}

.data-calendari-dia.is-fora {
    color: #ced4da;
}

.data-calendari-dia.is-avui {
    box-shadow: inset 0 0 0 1.5px #0d6efd;
}

.data-calendari-dia.is-seleccionat,
.data-calendari-dia.is-seleccionat:hover {
    background: #0d6efd;
    color: #fff;
    box-shadow: none;
}

.data-calendari-avui {
    display: block;
    width: 100%;
    margin-top: 0.65rem;
    border: 0;
    border-radius: 0.5rem;
    background: #f1f3f5;
    color: #495057;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.4rem 0.5rem;
}

.data-calendari-avui:hover {
    background: #e9ecef;
    color: #212529;
}

[data-bs-theme="dark"] .data-calendari {
    border-color: var(--app-border, #343a40);
    background: var(--app-surface, #212529);
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.35);
}

[data-bs-theme="dark"] .data-calendari-titol {
    color: var(--app-text, #e9ecef);
}

[data-bs-theme="dark"] .data-calendari-nav {
    border-color: var(--app-border, #343a40);
    background: rgba(255, 255, 255, 0.04);
    color: var(--app-text-muted, #adb5bd);
}

[data-bs-theme="dark"] .data-calendari-nav:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--app-text, #e9ecef);
}

[data-bs-theme="dark"] .data-calendari-dow {
    color: var(--app-text-muted, #6c757d);
}

[data-bs-theme="dark"] .data-calendari-dia {
    color: var(--app-text, #e9ecef);
}

[data-bs-theme="dark"] .data-calendari-dia:hover {
    background: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .data-calendari-dia.is-fora {
    color: #6c757d;
}

[data-bs-theme="dark"] .data-calendari-dia.is-avui {
    box-shadow: inset 0 0 0 1.5px #6ea8fe;
}

[data-bs-theme="dark"] .data-calendari-dia.is-seleccionat,
[data-bs-theme="dark"] .data-calendari-dia.is-seleccionat:hover {
    background: #0d6efd;
    color: #fff;
}

[data-bs-theme="dark"] .data-calendari-avui {
    background: rgba(255, 255, 255, 0.06);
    color: var(--app-text-muted, #adb5bd);
}

[data-bs-theme="dark"] .data-calendari-avui:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--app-text, #e9ecef);
}

[data-bs-theme="dark"] .form-input-icon .form-control,
[data-bs-theme="dark"] .form-input-icon .form-select {
    background: var(--app-surface-muted);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .form-input-icon .form-control:focus,
[data-bs-theme="dark"] .form-input-icon .form-select:focus {
    background: var(--app-surface-soft);
    border-color: rgba(13, 110, 253, 0.55);
    color: var(--app-text);
}

[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-control[readonly],
[data-bs-theme="dark"] .form-select:disabled {
    background-color: var(--app-surface-muted);
    border-color: var(--app-border);
    color: var(--app-text-muted);
    opacity: 0.9;
}

[data-bs-theme="dark"] textarea.form-control {
    background-color: var(--app-surface-muted);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] textarea.form-control:focus {
    background-color: var(--app-surface-soft);
    color: var(--app-text);
}

[data-bs-theme="dark"] .form-control-color {
    background-color: var(--app-surface-muted);
    border-color: var(--app-border-strong);
}

[data-bs-theme="dark"] .freq-option label {
    background: var(--app-surface-muted);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .freq-option label i {
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .freq-option label:hover {
    background: var(--app-surface-soft);
    border-color: var(--app-border-strong);
}

[data-bs-theme="dark"] .freq-option input:checked + label {
    border-color: #6ea8fe;
    background: rgba(13, 110, 253, 0.15);
    color: #9ec5fe;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2);
}

[data-bs-theme="dark"] .freq-option input:checked + label i {
    color: #6ea8fe;
}

[data-bs-theme="dark"] .perfil-compte-toggle-btn {
    background: var(--app-surface-muted);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .perfil-compte-toggle-btn:hover {
    background: var(--app-surface-soft);
    border-color: var(--app-border-strong);
}

[data-bs-theme="dark"] .perfil-compte-toggle-check {
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .perfil-compte-toggle-input:checked + .perfil-compte-toggle-btn {
    border-color: #6ea8fe;
    background: rgba(13, 110, 253, 0.15);
    color: #9ec5fe;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2);
}

[data-bs-theme="dark"] .perfil-compte-toggle-input:checked + .perfil-compte-toggle-btn .perfil-compte-toggle-check {
    color: #6ea8fe;
}

[data-bs-theme="dark"] .tipus-option input:checked + label.tipus-gasto {
    border-color: #f1aeb5;
    background: rgba(220, 53, 69, 0.15);
    color: #f1aeb5;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2);
}

[data-bs-theme="dark"] .tipus-option input:checked + label.tipus-ingres {
    border-color: #75b798;
    background: rgba(25, 135, 84, 0.18);
    color: #75b798;
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.2);
}

[data-bs-theme="dark"] .tipus-option input:checked + label.tipus-transferencia {
    border-color: #6ea8fe;
    background: rgba(13, 110, 253, 0.18);
    color: #9ec5fe;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2);
}

[data-bs-theme="dark"] .form-status-card {
    background: var(--app-surface-muted);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .form-status-card.is-active {
    border-color: rgba(117, 183, 152, 0.45);
    background: rgba(25, 135, 84, 0.12);
}

[data-bs-theme="dark"] .form-status-card .form-check-label,
[data-bs-theme="dark"] .form-status-card strong {
    color: var(--app-text);
}

[data-bs-theme="dark"] .form-status-card .text-muted {
    color: var(--app-text-muted) !important;
}

[data-bs-theme="dark"] .form-actions-bar {
    background: var(--app-surface-muted);
    border-top-color: var(--app-border-strong);
}

[data-bs-theme="dark"] .form-actions-bar .btn-link.text-muted {
    color: var(--app-text-muted) !important;
}

[data-bs-theme="dark"] .form-actions-bar .btn-link.text-muted:hover {
    color: var(--app-text) !important;
}

[data-bs-theme="dark"] .form-alert-modern.alert-danger {
    background: rgba(220, 53, 69, 0.15);
    color: #f1aeb5;
}

[data-bs-theme="dark"] .form-summary-meta {
    border-top-color: var(--app-border-strong);
}

[data-bs-theme="dark"] .form-summary-meta-item {
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .form-summary-meta-item i {
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .form-summary-body .text-muted {
    color: var(--app-text-muted) !important;
}

[data-bs-theme="dark"] .form-info-banner {
    background: rgba(13, 110, 253, 0.12);
    border-color: rgba(13, 110, 253, 0.28);
    color: #9ec5fe;
}

[data-bs-theme="dark"] .select-icona-wrap .input-group-text {
    background-color: var(--app-surface-muted);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .text-muted,
[data-bs-theme="dark"] .navbar-app-top .text-muted {
    color: var(--app-text-muted) !important;
}

[data-bs-theme="dark"] .table > :not(caption) > * > * {
    background-color: transparent;
    color: var(--app-text);
    border-color: var(--app-border-strong);
}

[data-bs-theme="dark"] .table-light {
    --bs-table-bg: var(--app-surface-muted);
    --bs-table-color: var(--app-text);
}

[data-bs-theme="dark"] .card {
    background-color: var(--app-surface);
    border-color: var(--app-border);
    color: var(--app-text);
}

[data-bs-theme="dark"] .card-header,
[data-bs-theme="dark"] .card-footer {
    background-color: var(--app-surface-muted);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .card-header.bg-white {
    background-color: var(--app-surface-muted) !important;
    color: var(--app-text) !important;
}

[data-bs-theme="dark"] .list-group-item {
    background-color: var(--app-surface);
    border-color: var(--app-border);
    color: var(--app-text);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--app-surface-muted);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: var(--app-surface-soft);
    color: var(--app-text);
}

[data-bs-theme="dark"] .input-group-text {
    background-color: var(--app-surface-muted);
    border-color: var(--app-border-strong);
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: var(--app-surface);
    border-color: var(--app-border-strong);
}

[data-bs-theme="dark"] .dropdown-item {
    color: var(--app-text);
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: var(--app-surface-soft);
    color: var(--app-text);
}

[data-bs-theme="dark"] .modal-content {
    background-color: var(--app-surface);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .confirm-modal-backdrop {
    background: rgba(0, 0, 0, 0.65);
}

[data-bs-theme="dark"] .grup-compte-saldo-badge--pos {
    color: #34d399;
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.35);
}

[data-bs-theme="dark"] .grup-compte-saldo-badge--neg {
    color: #fca5a5;
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.35);
}

[data-bs-theme="dark"] .list-item-card.inactiu {
    opacity: 0.65;
}

[data-bs-theme="dark"] .navbar-app-top .btn-outline-secondary {
    --bs-btn-color: #dee2e6;
    --bs-btn-border-color: rgba(255, 255, 255, 0.25);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: rgba(255, 255, 255, 0.08);
    --bs-btn-hover-border-color: rgba(255, 255, 255, 0.35);
}

/* Llistats (categories, taules, etc.) */
[data-bs-theme="dark"] .list-card,
[data-bs-theme="dark"] .list-table-card,
[data-bs-theme="dark"] .list-filters-card,
[data-bs-theme="dark"] .list-empty,
[data-bs-theme="dark"] .list-stacked-item {
    background: var(--app-surface);
    border-color: var(--app-border);
    color: var(--app-text);
    box-shadow: 0 4px 24px var(--app-shadow);
}

[data-bs-theme="dark"] .list-card .list-table-card {
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

[data-bs-theme="dark"] .list-card-header {
    background: var(--app-surface-muted);
    border-bottom-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .list-table thead th {
    background: var(--app-surface-muted);
    border-bottom-color: var(--app-border-strong);
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .list-table tbody td {
    border-bottom-color: var(--app-border);
    color: var(--app-text);
}

[data-bs-theme="dark"] .list-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

[data-bs-theme="dark"] .proj-moviments {
    background: var(--app-surface);
    border-color: var(--app-border-strong);
    box-shadow: none;
}

[data-bs-theme="dark"] .proj-moviments-cap {
    background: var(--app-surface-muted);
    border-bottom-color: var(--app-border-strong);
}

[data-bs-theme="dark"] .proj-moviments-titol {
    color: var(--app-text);
}

[data-bs-theme="dark"] .proj-moviments-sub {
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .proj-moviments-compte + .proj-moviments-compte {
    border-top-color: var(--app-border-strong);
}

[data-bs-theme="dark"] .proj-moviments-compte-cap {
    background: var(--app-surface-muted);
    border-bottom-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .proj-moviments-compte-cap:hover {
    background: rgba(255, 255, 255, 0.04);
}

[data-bs-theme="dark"] .proj-moviments-compte-cap.collapsed {
    border-bottom-color: transparent;
}

[data-bs-theme="dark"] .proj-moviments-compte-titol {
    color: var(--app-text);
}

[data-bs-theme="dark"] .proj-moviments-compte-chevron {
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .proj-moviments-compte-count {
    background: rgba(255, 255, 255, 0.08);
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .list-table--proj-moviments .proj-mov-desc {
    color: var(--app-text);
}

[data-bs-theme="dark"] .list-table--proj-moviments .proj-mov-data,
[data-bs-theme="dark"] .list-table--proj-moviments .proj-mov-compte {
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .proj-mov-pendent-badge {
    background: rgba(255, 193, 7, 0.16);
    color: #ffc107;
}

[data-bs-theme="dark"] .list-empty {
    border-color: var(--app-border-strong);
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .list-stacked-meta,
[data-bs-theme="dark"] .list-stacked-meta-sep {
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .list-stacked-chip {
    background: var(--app-surface-soft);
    color: var(--app-text);
}

[data-bs-theme="dark"] .list-stacked-actions {
    border-top-color: var(--app-border-strong);
}

[data-bs-theme="dark"] .list-action-icon {
    background: var(--app-surface-muted);
    border-color: var(--app-border-strong);
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .list-action-icon:hover {
    background: var(--app-surface-soft);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .list-action-icon-warning:hover {
    background: rgba(255, 193, 7, 0.12);
    border-color: rgba(255, 193, 7, 0.4);
    color: #ffc107;
}

[data-bs-theme="dark"] .list-action-icon-danger:hover {
    background: rgba(220, 53, 69, 0.15);
    border-color: rgba(220, 53, 69, 0.45);
    color: #f1aeb5;
}

/* Filtres de llistats: badges legibles en mode fosc */
[data-bs-theme="dark"] .list-filtre-btn .badge.bg-white,
[data-bs-theme="dark"] .categories-filtre-btn .badge.bg-white {
    background-color: rgba(255, 255, 255, 0.92) !important;
}

[data-bs-theme="dark"] .list-filtre-btn .badge.bg-danger-subtle,
[data-bs-theme="dark"] .categories-filtre-btn .badge.bg-danger-subtle {
    background-color: rgba(220, 53, 69, 0.18) !important;
    color: #f1aeb5 !important;
}

[data-bs-theme="dark"] .list-filtre-btn .badge.bg-success-subtle,
[data-bs-theme="dark"] .categories-filtre-btn .badge.bg-success-subtle {
    background-color: rgba(25, 135, 84, 0.2) !important;
    color: #75b798 !important;
}

[data-bs-theme="dark"] .list-filtre-btn .badge.bg-secondary-subtle,
[data-bs-theme="dark"] .categories-filtre-btn .badge.bg-secondary-subtle {
    background-color: rgba(173, 181, 189, 0.15) !important;
    color: #ced4da !important;
}

[data-bs-theme="dark"] .list-filtre-btn .badge.bg-primary-subtle,
[data-bs-theme="dark"] .categories-filtre-btn .badge.bg-primary-subtle {
    background-color: rgba(13, 110, 253, 0.2) !important;
    color: #9ec5fe !important;
}

[data-bs-theme="dark"] .list-filtre-btn.btn-outline-primary,
[data-bs-theme="dark"] .categories-filtre-btn.btn-outline-primary {
    --bs-btn-color: #9ec5fe;
    --bs-btn-border-color: rgba(13, 110, 253, 0.45);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: rgba(13, 110, 253, 0.2);
    --bs-btn-hover-border-color: rgba(13, 110, 253, 0.55);
}

[data-bs-theme="dark"] .list-filtre-btn.btn-outline-secondary,
[data-bs-theme="dark"] .categories-filtre-btn.btn-outline-secondary {
    --bs-btn-color: #ced4da;
    --bs-btn-border-color: rgba(255, 255, 255, 0.2);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: rgba(255, 255, 255, 0.08);
    --bs-btn-hover-border-color: rgba(255, 255, 255, 0.3);
}

/* Desplegable de categories amb cerca (Tom Select) */
.form-input-categoria-cerca .ts-wrapper {
    width: 100%;
}

.form-input-categoria-cerca .ts-control {
    padding-left: 2.35rem !important;
    min-height: calc(1.5em + 0.75rem + 2px);
    border-color: #e9ecef;
    background: #fafbfc;
}

.form-input-categoria-cerca .ts-control .item {
    margin: 0.1rem 0.25rem 0.1rem 0;
    padding: 0;
    background: transparent;
    border: none;
}

.form-input-categoria-cerca .ts-control:focus,
.form-input-categoria-cerca .ts-wrapper.focus .ts-control {
    background: #fff;
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-input-categoria-cerca .ts-dropdown {
    border-color: #dee2e6;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
    padding: 0.65rem 0.5rem;
    max-height: 340px;
    overflow: hidden;
}

.form-input-categoria-cerca .ts-dropdown .ts-dropdown-content {
    max-height: 300px;
    padding: 0.25rem 0.35rem 0.35rem;
}

.form-input-categoria-cerca .ts-dropdown .optgroup {
    padding: 0.15rem 0;
}

.form-input-categoria-cerca .ts-dropdown .optgroup + .optgroup {
    margin-top: 0.35rem;
    padding-top: 0.25rem;
}

.form-input-categoria-cerca .ts-dropdown .option {
    white-space: normal;
    padding: 0;
    margin: 0.3rem 0;
    border-radius: 10px;
    overflow: hidden;
}

.form-input-categoria-cerca .ts-dropdown .option.active {
    background: transparent;
}

.form-input-categoria-cerca .ts-dropdown .no-results {
    padding: 0.75rem 1rem;
    color: var(--app-text-muted);
    font-size: 0.875rem;
}

.categoria-color-dot,
.categoria-color-badge {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: -2px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
}

[data-bs-theme="dark"] .categoria-color-dot,
[data-bs-theme="dark"] .categoria-color-badge {
    border-color: rgba(255, 255, 255, 0.12);
}

.categoria-optgroup-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem 0.5rem;
    margin: 0 0.15rem 0.25rem;
    border-radius: 8px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--app-text-muted);
    background: var(--app-surface-muted);
    border-top: 1px solid var(--app-border);
}

.categoria-optgroup-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 6px;
    flex-shrink: 0;
}

.categoria-optgroup-header.categoria-optgroup-ingres {
    color: var(--color-success);
}

.categoria-optgroup-header.categoria-optgroup-ingres .categoria-optgroup-icon {
    background: rgba(25, 135, 84, 0.12);
    color: var(--color-success);
}

.categoria-optgroup-header.categoria-optgroup-gasto {
    color: var(--color-danger);
}

.categoria-optgroup-header.categoria-optgroup-gasto .categoria-optgroup-icon {
    background: rgba(220, 53, 69, 0.12);
    color: var(--color-danger);
}

.ts-dropdown .optgroup:first-child .categoria-optgroup-header {
    border-top: none;
}

.categoria-select-opcio {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    min-height: 2.75rem;
    padding: 0.55rem 0.85rem 0.55rem 0;
    border-radius: 10px;
    transition: background-color 0.15s ease;
}

.categoria-select-opcio--chip {
    display: inline-flex;
    min-height: auto;
    padding: 0.2rem 0.55rem 0.2rem 0.2rem;
    border-radius: 999px;
    border: 1px solid var(--app-border);
    background: var(--app-surface-muted);
    gap: 0.4rem;
}

.categoria-select-opcio--chip .categoria-select-icona {
    width: 1.35rem;
    height: 1.35rem;
    font-size: 0.75rem;
}

.categoria-select-opcio--chip .categoria-select-nom {
    font-size: 0.8125rem;
    font-weight: 600;
}

.categoria-select-stripe {
    width: 4px;
    align-self: stretch;
    flex-shrink: 0;
    border-radius: 4px 0 0 4px;
    margin-right: 0.15rem;
}

.categoria-select-icona {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 8px;
    border: 1px solid transparent;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.categoria-select-nom {
    flex: 1;
    min-width: 0;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    color: var(--app-text);
}

.categoria-select-opcio--pare .categoria-select-nom {
    font-weight: 600;
}

/* Subcategories: indentació a l'esquerra (llista plana) */
.categoria-select-opcio--sub {
    padding-left: 1.35rem;
}

.categoria-select-opcio--sub .categoria-select-nom {
    font-weight: 500;
}

.categoria-select-arrel {
    flex-shrink: 0;
    width: 0.85rem;
    margin-right: -0.15rem;
    color: var(--app-text-muted);
    font-size: 0.8rem;
    line-height: 1;
    opacity: 0.7;
}

.categoria-select-opcio[data-profunditat="2"] { padding-left: 2rem; }
.categoria-select-opcio[data-profunditat="3"] { padding-left: 2.65rem; }
.categoria-select-opcio[data-profunditat="4"] { padding-left: 3.3rem; }

.categoria-select-opcio--sub .categoria-select-stripe {
    opacity: 0.75;
}

.categoria-select-opcio[data-profunditat="2"] .categoria-select-stripe { opacity: 0.65; }
.categoria-select-opcio[data-profunditat="3"] .categoria-select-stripe { opacity: 0.55; }
.categoria-select-opcio[data-profunditat="4"] .categoria-select-stripe { opacity: 0.45; }

/* Jerarquia desplegable: subcategories sota la categoria pare */
.categoria-select-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    margin-right: 0.1rem;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: var(--app-surface-muted);
    color: var(--app-text-muted);
    flex-shrink: 0;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.categoria-select-toggle:hover {
    background: var(--app-border);
    color: var(--app-text);
}

.categoria-select-toggle .bi {
    font-size: 0.75rem;
    line-height: 1;
}

.categoria-select-opcio--amb-fills .categoria-select-nom {
    font-weight: 600;
}

.categoria-select-grup-fills {
    display: none !important;
    margin: 0.1rem 0 0.35rem 0.5rem;
    padding: 0.2rem 0 0.2rem 0.65rem;
    border-left: 2px solid var(--app-border);
}

.categoria-select-grup-fills.is-open {
    display: block !important;
}

.categoria-select-grup-fills .option {
    margin-left: 0;
}

.categoria-select-grup-fills .categoria-select-opcio--sub {
    padding-left: 0.65rem;
}

.categoria-select-grup-fills .categoria-select-grup-fills {
    margin-left: 0.35rem;
    border-left-color: var(--app-border-strong);
}

.categoria-select-cercant .categoria-select-grup-fills {
    display: block !important;
}

.form-input-categoria-cerca .categoria-select-toggle {
    position: relative;
    z-index: 3;
    pointer-events: auto;
}

.form-input-categoria-cerca .ts-dropdown .option:has(.categoria-select-toggle) {
    cursor: default;
}

.form-input-categoria-cerca .ts-dropdown .option:has(.categoria-select-toggle) .categoria-select-nom,
.form-input-categoria-cerca .ts-dropdown .option:has(.categoria-select-toggle) .categoria-select-icona {
    cursor: pointer;
}

.categoria-select-prefix {
    color: #6c757d;
    flex-shrink: 0;
}

[data-bs-theme="dark"] .categoria-select-prefix {
    color: var(--app-text-muted);
}

[data-bs-theme="dark"] .categoria-select-opcio--chip {
    background: var(--app-surface-soft);
}

[data-bs-theme="dark"] .form-input-categoria-cerca .ts-control {
    background: var(--app-surface-muted);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .form-input-categoria-cerca .ts-wrapper.focus .ts-control {
    background: var(--app-surface-soft);
}

[data-bs-theme="dark"] .form-input-categoria-cerca .ts-dropdown {
    background: var(--app-surface);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .form-input-categoria-cerca .ts-dropdown .option.active {
    background: var(--app-surface-soft);
    color: var(--app-text);
}

[data-bs-theme="dark"] .form-input-categoria-cerca .ts-dropdown .option:hover {
    background: var(--app-surface-muted);
    color: var(--app-text);
}

/* Informe ganàncies i pèrdues */
.informe-gp-card {
    border-radius: 14px;
    overflow: hidden;
}

.informe-gp-table {
    --informe-gp-row-py: 0.72rem;
    --informe-gp-row-px: 0.7rem;
    /* Fons opacs per files de totals (scroll horitzontal) */
    --informe-gp-total-success-bg: #edf5f0;
    --informe-gp-total-danger-bg: #fceeee;
    --informe-gp-total-net-bg: #ebf2fe;
    border-collapse: separate;
    border-spacing: 0;
}

.informe-gp-table th,
.informe-gp-table td {
    white-space: nowrap;
    font-size: 0.875rem;
    vertical-align: middle;
}

.informe-gp-table thead th {
    padding: 0.7rem var(--informe-gp-row-px);
    background: var(--app-surface-muted);
    border-bottom: 1px solid var(--app-border);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--app-text-muted);
}

.informe-gp-table tbody td {
    padding: var(--informe-gp-row-py) var(--informe-gp-row-px);
    border-bottom: 1px solid var(--app-border);
    transition: background-color 0.15s ease;
}

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

.informe-gp-table tbody tr.informe-gp-cat-row:hover td,
.informe-gp-table tbody tr:not(.informe-gp-seccio):not(.informe-gp-total):hover td {
    background: var(--app-surface-muted);
}

.informe-gp-table tbody tr:not(.informe-gp-total):hover .informe-gp-cat-col {
    background: var(--app-surface-muted);
    box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.1);
}

.informe-gp-table .informe-gp-seccio:not(.informe-gp-total) td.informe-gp-seccio-resta {
    padding: 1rem var(--informe-gp-row-px) 0.55rem;
    border-bottom: 0;
    background: transparent !important;
}

.informe-gp-table .informe-gp-seccio:not(.informe-gp-total) td.informe-gp-seccio-titol {
    padding: 1rem var(--informe-gp-row-px) 0.55rem;
    font-weight: 600;
    font-size: 0.8125rem;
    letter-spacing: 0.02em;
    border-bottom: 0;
    background: var(--app-surface) !important;
}

.informe-gp-table .informe-gp-seccio--success td.informe-gp-seccio-titol {
    color: var(--bs-success);
}

.informe-gp-table .informe-gp-seccio--danger td.informe-gp-seccio-titol {
    color: var(--bs-danger);
}

.informe-gp-table .informe-gp-total td {
    font-weight: 600;
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
}

/* Total ingressos, total despeses i resultat net: fons opac sempre (scroll horitzontal) */
.informe-gp-table > tbody > tr.informe-gp-total--success > td,
.informe-gp-table.table-hover > tbody > tr.informe-gp-total--success > td {
    background: var(--informe-gp-total-success-bg) !important;
    background-color: var(--informe-gp-total-success-bg) !important;
}

.informe-gp-table > tbody > tr.informe-gp-total--danger > td,
.informe-gp-table.table-hover > tbody > tr.informe-gp-total--danger > td {
    background: var(--informe-gp-total-danger-bg) !important;
    background-color: var(--informe-gp-total-danger-bg) !important;
}

.informe-gp-table > tbody > tr.informe-gp-total.informe-gp-seccio > td,
.informe-gp-table.table-hover > tbody > tr.informe-gp-total.informe-gp-seccio > td {
    background: var(--informe-gp-total-net-bg) !important;
    background-color: var(--informe-gp-total-net-bg) !important;
    border-top: 2px solid var(--app-border);
    border-bottom: 0;
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
}

.informe-gp-table tbody tr:not(.informe-gp-total) .informe-gp-cat-col {
    position: sticky;
    left: 0;
    z-index: 10;
    min-width: 14rem;
    max-width: 22rem;
    /* Fons opac: tapa les columnes de mesos en scroll horitzontal */
    background: var(--app-surface);
    box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.1);
}

.informe-gp-table tbody tr.informe-gp-total .informe-gp-cat-col {
    position: sticky;
    left: 0;
    z-index: 12;
    min-width: 14rem;
    max-width: 22rem;
    background-clip: padding-box;
    box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.12);
}

.informe-gp-table thead .informe-gp-cat-col {
    position: sticky;
    left: 0;
    z-index: 11;
    min-width: 14rem;
    max-width: 22rem;
    background: var(--app-surface-muted);
    box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.1);
}

.informe-gp-table .informe-gp-cat-col--pare,
.informe-gp-table .informe-gp-cat-col--fill {
    padding-left: 0.75rem;
}

.informe-gp-table .informe-gp-import-col {
    position: relative;
    z-index: 0;
    text-align: right;
    min-width: 5.75rem;
}

.informe-gp-table > tbody > tr.informe-gp-total--success .informe-gp-cat-col {
    background: var(--informe-gp-total-success-bg) !important;
    background-color: var(--informe-gp-total-success-bg) !important;
}

.informe-gp-table > tbody > tr.informe-gp-total--danger .informe-gp-cat-col {
    background: var(--informe-gp-total-danger-bg) !important;
    background-color: var(--informe-gp-total-danger-bg) !important;
}

.informe-gp-table > tbody > tr.informe-gp-total.informe-gp-seccio .informe-gp-cat-col {
    background: var(--informe-gp-total-net-bg) !important;
    background-color: var(--informe-gp-total-net-bg) !important;
}

@media (max-width: 767.98px) {
    .informe-gp-card .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    .informe-gp-table .informe-gp-cat-col {
        min-width: 12rem;
        max-width: 12rem;
        box-shadow: 6px 0 10px -2px rgba(0, 0, 0, 0.14);
    }

    .informe-gp-table tr.informe-gp-total td.informe-gp-cat-col {
        box-shadow: 6px 0 10px -2px rgba(0, 0, 0, 0.14);
    }
}

.informe-gp-table .informe-gp-cat-nom {
    display: grid;
    grid-template-columns: 1.25rem 14px minmax(0, 1fr);
    grid-template-rows: 1fr;
    column-gap: 0.5rem;
    align-items: center;
    max-width: 100%;
    vertical-align: middle;
}

.informe-gp-cat-toggle-col {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    overflow: hidden;
}

.informe-gp-table .informe-gp-cat-badge,
.informe-gp-table .informe-gp-cat-badge-spacer {
    grid-column: 2;
    grid-row: 1;
    justify-self: start;
    align-self: center;
    width: 14px;
    height: 14px;
    margin: 0;
}

.informe-gp-table .categoria-color-dot.informe-gp-cat-badge {
    display: block;
    vertical-align: top;
}

.informe-gp-cat-label {
    grid-column: 3;
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.informe-gp-table .informe-gp-cat-row[data-profunditat="1"] .informe-gp-cat-label {
    padding-left: 0;
}

.informe-gp-table .informe-gp-cat-row[data-profunditat="2"] .informe-gp-cat-label {
    padding-left: 3rem;
}

.informe-gp-table .informe-gp-cat-row[data-profunditat="3"] .informe-gp-cat-label {
    padding-left: 4.5rem;
}

.informe-gp-table .informe-gp-cat-row[data-profunditat="4"] .informe-gp-cat-label {
    padding-left: 6rem;
}

.informe-gp-cat-fletxa {
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.informe-gp-cat-text {
    min-width: 0;
}

.informe-gp-toggle-spacer {
    display: block;
    width: 1.25rem;
    height: 1.25rem;
}

.informe-gp-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    min-width: 1.25rem;
    max-width: 1.25rem;
    height: 1.25rem;
    padding: 0 !important;
    margin: 0;
    border: 0;
    line-height: 1;
    text-decoration: none;
    box-shadow: none !important;
}

.informe-gp-toggle:hover,
.informe-gp-toggle:focus-visible {
    color: var(--bs-primary);
}

/* Llistat de categories: mateixa graella de 3 columnes */
.categoria-jerarquia-fila {
    display: grid;
    grid-template-columns: 1.25rem 14px minmax(0, 1fr);
    column-gap: 0.5rem;
    align-items: center;
}

.categoria-jerarquia-toggle-col {
    grid-column: 1;
    width: 1.25rem;
    height: 1.25rem;
}

.categoria-jerarquia-badge,
.categoria-color-dot.categoria-jerarquia-badge {
    grid-column: 2;
    justify-self: start;
    display: block;
    width: 14px;
    height: 14px;
    margin: 0;
}

.categoria-jerarquia-label {
    grid-column: 3;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

tr[data-profunditat="1"] .categoria-jerarquia-label {
    padding-left: 1.5rem;
}

tr[data-profunditat="2"] .categoria-jerarquia-label {
    padding-left: 3rem;
}

tr[data-profunditat="3"] .categoria-jerarquia-label {
    padding-left: 4.5rem;
}

tr[data-profunditat="4"] .categoria-jerarquia-label {
    padding-left: 6rem;
}

.categoria-jerarquia-fletxa {
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.categoria-jerarquia-icona {
    flex-shrink: 0;
}

.categoria-jerarquia-nom {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


.informe-gp-table tbody tr.informe-gp-cat-fill td.informe-gp-cat-col {
    background: var(--app-surface);
    box-shadow: inset 0 0 0 9999px rgba(0, 0, 0, 0.025), 4px 0 8px -2px rgba(0, 0, 0, 0.1);
}

.informe-gp-table tbody tr.informe-gp-cat-fill:hover td.informe-gp-cat-col {
    background: var(--app-surface-muted);
    box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .informe-gp-table tbody tr.informe-gp-cat-fill td.informe-gp-cat-col {
    background: var(--app-surface);
    box-shadow: inset 0 0 0 9999px rgba(255, 255, 255, 0.04), 4px 0 8px -2px rgba(0, 0, 0, 0.25);
}

[data-bs-theme="dark"] .informe-gp-table tbody tr.informe-gp-cat-fill:hover td.informe-gp-cat-col {
    background: var(--app-surface-muted);
    box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.25);
}

.informe-gp-table tbody tr.informe-gp-total:hover td.informe-gp-cat-col {
    box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.12);
}

.informe-gp-cat-pare > td {
    font-weight: 500;
}

[data-bs-theme="dark"] .informe-gp-table {
    --informe-gp-total-success-bg: #1e3229;
    --informe-gp-total-danger-bg: #352022;
    --informe-gp-total-net-bg: #1c2738;
}

[data-bs-theme="dark"] .informe-gp-table tbody tr:not(.informe-gp-total):not(.informe-gp-cat-fill) td.informe-gp-cat-col {
    background: var(--app-surface);
}

[data-bs-theme="dark"] .informe-gp-table .informe-gp-seccio:not(.informe-gp-total) td.informe-gp-seccio-titol {
    background: var(--app-surface) !important;
}

[data-bs-theme="dark"] .informe-gp-table thead .informe-gp-cat-col {
    background: var(--app-surface-muted);
}

/* Mode fosc: anul·lar transparent de Bootstrap als totals */
[data-bs-theme="dark"] .informe-gp-table.table > tbody > tr.informe-gp-total--success > td {
    background-color: var(--informe-gp-total-success-bg) !important;
}

[data-bs-theme="dark"] .informe-gp-table.table > tbody > tr.informe-gp-total--danger > td {
    background-color: var(--informe-gp-total-danger-bg) !important;
}

[data-bs-theme="dark"] .informe-gp-table.table > tbody > tr.informe-gp-total.informe-gp-seccio > td {
    background-color: var(--informe-gp-total-net-bg) !important;
}

.informe-gp-cella-link {
    border: 0;
    background: none;
    padding: 0.12rem 0.4rem;
    margin: 0;
    border-radius: 6px;
    color: inherit;
    font: inherit;
    line-height: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.informe-gp-cella-link:hover,
.informe-gp-cella-link:focus-visible {
    color: var(--bs-primary);
    background: rgba(13, 110, 253, 0.08);
    outline: none;
}

.informe-gp-modal-taula th,
.informe-gp-modal-taula td {
    font-size: 0.875rem;
    vertical-align: middle;
}

/* Selector de categories amb popup */
.cat-picker-dialog {
    max-width: 28rem;
}

.cat-picker-cerca-wrap {
    position: relative;
}

.cat-picker-cerca-wrap .bi-search {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--app-text-muted);
    pointer-events: none;
}

.cat-picker-cerca-wrap .form-control {
    padding-left: 2.35rem;
    border-radius: 10px;
}

.cat-picker-llista {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: min(55vh, 420px);
    overflow-y: auto;
    padding: 0.15rem 0.1rem;
}

.cat-picker-grup-cap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-radius: 8px;
    background: var(--app-surface-muted);
}

.cat-picker-grup--ingres .cat-picker-grup-cap {
    color: var(--color-success);
}

.cat-picker-grup--gasto .cat-picker-grup-cap {
    color: var(--color-danger);
}

.cat-picker-grup-body {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.cat-picker-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.45rem 0.35rem calc(0.45rem + (var(--cat-nivell, 0) * 0.85rem));
    border-radius: 10px;
    transition: background-color 0.15s ease;
}

.cat-picker-item:hover,
.cat-picker-item.is-selected,
.cat-picker-item.is-keyboard-active {
    background: rgba(13, 110, 253, 0.08);
}

.cat-picker-item.is-selected {
    outline: 1px solid rgba(13, 110, 253, 0.25);
}

.cat-picker-item.is-keyboard-active {
    outline: 2px solid rgba(13, 110, 253, 0.45);
    background: rgba(13, 110, 253, 0.14);
}

.cat-picker-toggle {
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: var(--app-surface-muted);
    color: var(--app-text-muted);
    cursor: pointer;
}

.cat-picker-toggle:hover {
    background: var(--app-border);
    color: var(--app-text);
}

.cat-picker-select {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
    padding: 0.15rem 0.35rem;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: inherit;
}

.cat-picker-nom {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.3;
}

.cat-picker-item--sub .cat-picker-nom {
    font-weight: 400;
}

.cat-picker-fills {
    display: none;
    margin-left: 1.1rem;
    padding-left: 0.55rem;
    border-left: 2px solid var(--app-border);
}

.cat-picker-fills.is-open {
    display: block;
}

.cat-picker-buit {
    text-align: center;
    color: var(--app-text-muted);
    padding: 1.5rem 0.5rem;
    font-size: 0.875rem;
}

/* Pila de modals anidats: només el superior és interactiu */
.modal.modal-stack-pausat {
    pointer-events: none;
}

.modal-backdrop.modal-backdrop-stack-inferior {
    pointer-events: none;
}

.modal-transaccions-filtres {
    background: var(--bs-light, #f8f9fa);
}

[data-bs-theme="dark"] .modal-transaccions-filtres {
    background: var(--bs-dark-bg-subtle, #212529);
}

.categoria-popup-trigger-wrap {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    min-width: 0;
    max-width: 100%;
}

.categoria-popup-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
    min-height: calc(1.5em + 0.75rem + 2px);
    padding: 0.5rem 0.85rem;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    background: #fafbfc;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.categoria-popup-trigger:hover {
    border-color: #ced4da;
    background: #fff;
}

.categoria-popup-trigger:focus-visible {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    outline: none;
}

.categoria-popup-trigger-inner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    flex: 1;
}

.categoria-popup-text {
    font-size: 0.9375rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.categoria-popup-fletxa {
    color: var(--app-text-muted);
    flex-shrink: 0;
}

.categoria-popup-clear {
    flex-shrink: 0;
    align-self: center;
}

[data-bs-theme="dark"] .categoria-popup-trigger {
    background: var(--app-surface-muted);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

[data-bs-theme="dark"] .categoria-popup-trigger:hover {
    background: var(--app-surface-soft);
}

/* Llistat d'usuaris (admin) */
.admin-users-stats .card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.admin-users-stats-icon {
    width: 2.5rem;
    height: 2.5rem;
}

.admin-users-stats .card:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.08) !important;
}

.admin-user-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--bs-border-color-translucent);
    transition: background-color 0.15s ease;
}

.admin-user-item:last-child {
    border-bottom: 0;
}

.admin-user-item:hover {
    background: rgba(var(--bs-primary-rgb), 0.03);
}

.admin-user-item--warning {
    background: rgba(var(--bs-warning-rgb), 0.08);
}

.admin-user-item--warning:hover {
    background: rgba(var(--bs-warning-rgb), 0.12);
}

.admin-user-avatar {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.admin-user-body {
    flex: 1;
    min-width: 0;
}

.admin-user-name {
    font-weight: 600;
    color: var(--bs-body-color);
    text-decoration: none;
}

.admin-user-name:hover {
    color: var(--bs-primary);
}

.admin-user-email {
    font-size: 0.875rem;
    color: var(--bs-secondary-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-user-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-end;
}

.admin-user-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin-top: 0.65rem;
    font-size: 0.8125rem;
    color: var(--bs-secondary-color);
}

.admin-user-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.admin-user-meta-item code {
    font-size: 0.75rem;
}

.admin-user-block-info {
    margin-top: 0.5rem;
    padding: 0.45rem 0.65rem;
    border-radius: 0.375rem;
    background: rgba(var(--bs-danger-rgb), 0.08);
    font-size: 0.8125rem;
    color: var(--bs-danger);
}

/* Alertes estàndard: icona a l'esquerra, text a la dreta */
.app-alert {
    padding: 1rem 1.25rem;
    border-radius: 10px;
}

.app-alert__icon {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.125rem;
    line-height: 1;
}

.app-alert__icon .bi {
    display: block;
    line-height: 1;
}

.app-alert__body {
    min-width: 0;
}

.app-alert__text {
    line-height: 1.5;
    font-size: 0.9375rem;
    overflow-wrap: break-word;
}

.admin-users-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--bs-secondary-color);
}

.admin-users-empty .bi {
    font-size: 2.5rem;
    opacity: 0.35;
    margin-bottom: 0.75rem;
}

@media (max-width: 767.98px) {
    .admin-user-item {
        flex-direction: column;
        gap: 0.75rem;
    }

    .admin-user-top {
        width: 100%;
    }

    .admin-user-badges {
        justify-content: flex-start;
    }
}

/* Centre d'ajuda */
.ajuda-layout-contingut {
    max-width: 52rem;
}

.ajuda-page-header {
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--app-border);
}

.ajuda-doc {
    font-size: 0.9375rem;
    line-height: 1.65;
    color: var(--bs-body-color);
}

.ajuda-lead {
    font-size: 1.0625rem;
    color: var(--bs-secondary-color);
    margin-bottom: 1.5rem;
}

.ajuda-h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 1.75rem 0 0.75rem;
}

.ajuda-h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
}

.ajuda-p {
    margin-bottom: 1rem;
}

.ajuda-ul,
.ajuda-ol {
    margin-bottom: 1.25rem;
    padding-left: 1.35rem;
}

.ajuda-ul li,
.ajuda-ol li {
    margin-bottom: 0.35rem;
}

.ajuda-menu-grup {
    list-style: none;
    margin: 0.75rem 0 0.25rem;
    padding: 0.35rem 0.75rem 0;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
}

.ajuda-menu-grup:first-child {
    margin-top: 0;
}

.ajuda-callout {
    display: flex;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.625rem;
    margin: 1.25rem 0;
    border: 1px solid var(--app-border);
    background: var(--app-surface);
}

.ajuda-callout--info {
    border-left: 3px solid var(--bs-info);
}

.ajuda-callout--tip {
    border-left: 3px solid var(--bs-success);
}

.ajuda-callout--warning {
    border-left: 3px solid var(--bs-warning);
}

.ajuda-callout-icon {
    flex-shrink: 0;
    font-size: 1.125rem;
    line-height: 1.4;
    color: var(--bs-secondary-color);
}

.ajuda-callout-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.ajuda-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    counter-reset: ajuda-step;
}

.ajuda-step {
    position: relative;
    padding: 0 0 1.25rem 2.75rem;
    counter-increment: ajuda-step;
}

.ajuda-step::before {
    content: counter(ajuda-step);
    position: absolute;
    left: 0;
    top: 0;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--bs-primary);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ajuda-step-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.ajuda-step-text {
    color: var(--bs-secondary-color);
    font-size: 0.9rem;
}

.ajuda-mock {
    margin: 1.25rem 0 1.5rem;
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1px dashed var(--app-border);
    background: rgba(var(--bs-secondary-rgb), 0.04);
}

.ajuda-mock-sidebar {
    max-width: 14rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ajuda-mock-sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    color: var(--bs-secondary-color);
}

.ajuda-mock-sidebar-item.is-active {
    background: rgba(var(--bs-primary-rgb), 0.12);
    color: var(--bs-primary);
    font-weight: 600;
}

.ajuda-mock-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
}

.ajuda-mock-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.ajuda-mock-card {
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    font-size: 0.8125rem;
}

.ajuda-mock-card-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bs-secondary-color);
    margin-bottom: 0.25rem;
}

.ajuda-mock-form {
    max-width: 20rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.ajuda-mock-field label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bs-secondary-color);
    margin-bottom: 0.2rem;
}

.ajuda-mock-input {
    padding: 0.45rem 0.6rem;
    border-radius: 0.375rem;
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    font-size: 0.8125rem;
}

.ajuda-mock-input-select {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ajuda-mock-chips {
    display: flex;
    gap: 0.35rem;
}

.ajuda-mock-chip {
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--app-border);
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
}

.ajuda-mock-chip.is-active {
    border-color: var(--bs-danger);
    background: rgba(var(--bs-danger-rgb), 0.1);
    color: var(--bs-danger);
    font-weight: 600;
}

.ajuda-mock-tree {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-width: 16rem;
}

.ajuda-mock-tree-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8125rem;
    padding: 0.3rem 0.5rem;
    border-radius: 0.375rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
}

.ajuda-mock-tree-item.is-child {
    margin-left: 1.25rem;
}

.ajuda-mock-color {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 2px;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .ajuda-mock-cards {
        grid-template-columns: 1fr;
    }
}

/* Historial de versions (novetats) */
.changelog-main {
    padding: 0;
    flex: 1 1 auto;
}

.changelog-hero {
    position: relative;
    overflow: hidden;
    padding: 1.75rem 1.5rem 1.5rem;
    border-bottom: 1px solid var(--app-border);
    background:
        radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--color-primary) 14%, transparent) 0%, transparent 55%),
        radial-gradient(90% 120% at 100% 0%, color-mix(in srgb, var(--color-primary) 8%, transparent) 0%, transparent 50%),
        linear-gradient(180deg, var(--app-surface) 0%, var(--app-surface-muted) 100%);
}

.changelog-hero__inner {
    max-width: 44rem;
    margin: 0 auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem 1.15rem;
    align-items: center;
    animation: changelog-fade-up 0.45s ease both;
}

.changelog-hero__icon {
    width: 3rem;
    height: 3rem;
    border-radius: 0.9rem;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    color: #fff;
    background: linear-gradient(145deg, var(--color-primary), color-mix(in srgb, var(--color-primary) 70%, #0a58ca));
    box-shadow: 0 8px 20px color-mix(in srgb, var(--color-primary) 28%, transparent);
}

.changelog-hero__eyebrow {
    margin: 0 0 0.2rem;
    font-size: 0.72rem;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--app-text-muted);
}

.changelog-hero__title {
    margin: 0;
    font-size: 1.55rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--app-text);
}

.changelog-hero__subtitle {
    margin: 0.4rem 0 0;
    max-width: 34rem;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--app-text-muted);
}

.changelog-hero__version {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
    padding: 0.65rem 0.9rem;
    border-radius: 0.85rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border-strong);
    box-shadow: 0 4px 14px var(--app-shadow);
}

.changelog-hero__version-label {
    font-size: 0.65rem;
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--app-text-muted);
}

.changelog-hero__version-num {
    font-size: 1.05rem;
    font-weight: 750;
    letter-spacing: -0.01em;
    color: var(--color-primary);
    font-variant-numeric: tabular-nums;
}

.changelog-body {
    max-width: 44rem;
    margin: 0 auto;
    padding: 1.75rem 1.5rem 2.5rem;
}

.changelog-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--app-text-muted);
    animation: changelog-fade-up 0.4s ease both;
}

.changelog-empty i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.75rem;
    opacity: 0.55;
}

.changelog-empty p {
    margin: 0;
    font-size: 0.95rem;
}

.changelog-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

.changelog-item {
    display: grid;
    grid-template-columns: 1.5rem 1fr;
    gap: 0 1.1rem;
    position: relative;
    padding-bottom: 1.6rem;
    opacity: 0;
    transform: translateY(10px);
    animation: changelog-fade-up 0.5s ease forwards;
    animation-delay: var(--changelog-delay, 0ms);
}

.changelog-item:last-child {
    padding-bottom: 0;
}

.changelog-rail {
    position: relative;
    display: flex;
    justify-content: center;
}

.changelog-rail::before {
    content: "";
    position: absolute;
    top: 1.35rem;
    bottom: -1.6rem;
    width: 2px;
    border-radius: 1px;
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--color-primary) 45%, var(--app-border-strong)) 0%,
        var(--app-border-strong) 100%
    );
}

.changelog-item:last-child .changelog-rail::before {
    display: none;
}

.changelog-dot {
    position: relative;
    z-index: 1;
    width: 0.85rem;
    height: 0.85rem;
    margin-top: 0.45rem;
    border-radius: 50%;
    background: var(--app-surface);
    border: 2.5px solid color-mix(in srgb, var(--color-primary) 70%, var(--app-border-strong));
    box-shadow: 0 0 0 4px var(--color-bg);
}

.changelog-item--current .changelog-dot {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.changelog-dot--pulse {
    animation: changelog-pulse 2.4s ease-in-out infinite;
}

.changelog-release {
    min-width: 0;
    padding: 1.1rem 1.2rem 1.2rem;
    border-radius: 1rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    box-shadow: 0 1px 2px var(--app-shadow);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.changelog-release:hover {
    border-color: color-mix(in srgb, var(--color-primary) 28%, var(--app-border-strong));
    box-shadow: 0 8px 22px var(--app-shadow);
    transform: translateY(-1px);
}

.changelog-item--current .changelog-release {
    border-color: color-mix(in srgb, var(--color-primary) 40%, var(--app-border));
    background:
        linear-gradient(
            135deg,
            color-mix(in srgb, var(--color-primary) 6%, var(--app-surface)) 0%,
            var(--app-surface) 48%
        );
    box-shadow: 0 6px 18px color-mix(in srgb, var(--color-primary) 10%, var(--app-shadow));
}

.changelog-release__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem 1rem;
    margin-bottom: 0.55rem;
}

.changelog-release__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.changelog-release__version {
    font-size: 1.05rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    color: var(--app-text);
    font-variant-numeric: tabular-nums;
}

.changelog-release__badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    background: var(--color-primary);
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
}

.changelog-release__date {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--app-text-muted);
    white-space: nowrap;
}

.changelog-release__date i {
    font-size: 0.85rem;
    opacity: 0.75;
}

.changelog-release__title {
    margin: 0 0 0.85rem;
    font-size: 1rem;
    font-weight: 650;
    line-height: 1.35;
    color: var(--app-text);
}

.changelog-release__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.55rem;
}

.changelog-release__list li {
    display: grid;
    grid-template-columns: 1.1rem 1fr;
    gap: 0.55rem;
    align-items: start;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--app-text);
}

.changelog-release__list i {
    margin-top: 0.15rem;
    font-size: 0.95rem;
    color: var(--color-primary);
    opacity: 0.9;
}

.changelog-footer-note {
    margin: 1.75rem 0 0;
    text-align: center;
    font-size: 0.8rem;
    color: var(--app-text-muted);
}

@keyframes changelog-fade-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes changelog-pulse {
    0%, 100% {
        box-shadow: 0 0 0 4px var(--color-bg), 0 0 0 0 color-mix(in srgb, var(--color-primary) 35%, transparent);
    }
    50% {
        box-shadow: 0 0 0 4px var(--color-bg), 0 0 0 8px color-mix(in srgb, var(--color-primary) 0%, transparent);
    }
}

@media (max-width: 640px) {
    .changelog-hero {
        padding: 1.35rem 1rem 1.25rem;
    }

    .changelog-hero__inner {
        grid-template-columns: auto 1fr;
    }

    .changelog-hero__version {
        grid-column: 1 / -1;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .changelog-hero__title {
        font-size: 1.35rem;
    }

    .changelog-body {
        padding: 1.35rem 1rem 2rem;
    }

    .changelog-item {
        grid-template-columns: 1.15rem 1fr;
        gap: 0 0.85rem;
    }

    .changelog-release {
        padding: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .changelog-hero__inner,
    .changelog-item,
    .changelog-empty,
    .changelog-dot--pulse,
    .changelog-release {
        animation: none !important;
        transition: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}
