/* ============================================
   TascaPiena - Mobile-First CSS
   ============================================ */

:root {
    --bg: #f5f5f7;
    --bg-card: #ffffff;
    --bg-input: #f0f0f5;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --border: #e5e7eb;
    --accent: #3B82F6;
    --accent-light: #dbeafe;
    --green: #10B981;
    --green-light: #d1fae5;
    --red: #EF4444;
    --red-light: #fee2e2;
    --orange: #F59E0B;
    --orange-light: #fef3c7;
    --purple: #8B5CF6;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --nav-height: 64px;
    --header-height: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---- DARK MODE ---- */
[data-theme="dark"] {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-light: #64748b;
    --border: #334155;
    --accent: #60a5fa;
    --accent-light: #1e3a5f;
    --green: #34d399;
    --green-light: #064e3b;
    --red: #f87171;
    --red-light: #7f1d1d;
    --orange: #fbbf24;
    --orange-light: #78350f;
    --purple: #a78bfa;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
}

[data-theme="dark"] #app-header {
    background: #1e293b;
    border-bottom-color: #334155;
}

[data-theme="dark"] #bottom-nav {
    background: #1e293b;
    border-top-color: #334155;
}

[data-theme="dark"] .login-screen {
    background: #0f172a;
}

[data-theme="dark"] .login-card {
    background: #1e293b;
}

[data-theme="dark"] .modal {
    background: #1e293b;
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0,0,0,0.7);
}

[data-theme="dark"] .toast {
    background: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .dash-hero {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .insights-card {
    background: linear-gradient(135deg, #1e293b, #1e1b4b);
    border-color: #334155;
}

[data-theme="dark"] .nav-btn-add {
    box-shadow: 0 2px 12px rgba(59,130,246,0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
}

/* ---- HEADER ---- */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
}

#page-title {
    font-size: 18px;
    font-weight: 700;
}

.ambito-selector {
    font-size: 14px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    max-width: 160px;
}

/* ---- MAIN CONTENT ---- */
#app-content {
    padding-top: calc(var(--header-height) + 8px);
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 70px);
    padding-left: 16px;
    padding-right: 16px;
    min-height: 100dvh;
}

/* ---- BOTTOM NAV ---- */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 10px;
    padding: 6px 8px;
    cursor: pointer;
    transition: color 0.2s;
    min-width: 0;
}

.nav-btn.active {
    color: var(--accent);
}

.nav-icon {
    font-size: 22px;
    line-height: 1;
}

.nav-label {
    font-weight: 500;
}

.nav-btn-add {
    background: var(--accent);
    color: #fff !important;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    margin-top: -20px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    justify-content: center;
}

.nav-btn-add .nav-icon {
    font-size: 28px;
    font-weight: 300;
}

/* ---- CARDS ---- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* ---- KPI GRID ---- */
.kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.kpi-box {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    text-align: center;
}

.kpi-box.full-width {
    grid-column: 1 / -1;
}

.kpi-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}

.kpi-value.green { color: var(--green); }
.kpi-value.red { color: var(--red); }
.kpi-value.blue { color: var(--accent); }

.kpi-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ---- PERSONA CHIPS ---- */
.persona-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.persona-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    border: 2px solid var(--border);
    background: var(--bg-card);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.persona-chip.selected {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

.persona-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ---- PERSONA FILTER BAR ---- */
.persona-filter-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 0 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.persona-filter-bar::-webkit-scrollbar { display: none; }
.persona-filter-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    transition: all 0.2s;
}
.persona-filter-chip.selected {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}
.persona-filter-chip .persona-dot {
    width: 8px;
    height: 8px;
}

/* ---- CATEGORIA GRID ---- */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.cat-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 4px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: var(--bg-card);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    word-break: break-word;
}

.cat-btn.selected {
    border-color: var(--accent);
    background: var(--accent-light);
}

.cat-btn .cat-icon {
    font-size: 24px;
}

.cat-btn .cat-name {
    line-height: 1.2;
    color: var(--text-secondary);
}

/* ---- FORM ---- */
.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    font-size: 16px;
    color: var(--text);
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* Toggle spesa/entrata */
.tipo-toggle {
    display: flex;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

.tipo-toggle button {
    flex: 1;
    padding: 12px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-input);
    color: var(--text-secondary);
}

.tipo-toggle button.active-spesa {
    background: var(--red);
    color: #fff;
}

.tipo-toggle button.active-entrata {
    background: var(--green);
    color: #fff;
}

/* Importo grande */
.importo-display {
    text-align: center;
    padding: 20px;
    margin-bottom: 12px;
}

.importo-display .currency {
    font-size: 20px;
    color: var(--text-secondary);
    vertical-align: top;
}

.importo-display .amount {
    font-size: 42px;
    font-weight: 700;
}

.importo-display input {
    font-size: 42px;
    font-weight: 700;
    text-align: center;
    border: none;
    background: transparent;
    color: var(--text);
    width: 100%;
    outline: none;
}

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

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

.btn-primary:active {
    transform: scale(0.98);
    opacity: 0.9;
}

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-google {
    background: #fff;
    color: #3c4043;
    border: 1px solid #dadce0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 14px;
    transition: background 0.2s, box-shadow 0.2s;
}
.btn-google:hover {
    background: #f7f8f8;
    box-shadow: 0 1px 3px rgba(60,64,67,0.15);
}
[data-theme="dark"] .btn-google {
    background: #2d2d2d;
    color: #e8eaed;
    border-color: #5f6368;
}
[data-theme="dark"] .btn-google:hover {
    background: #3c3c3c;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
    width: auto;
}

/* ---- LISTA MOVIMENTI ---- */
.mov-list {
    list-style: none;
}

.mov-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

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

.mov-icon {
    font-size: 28px;
    width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.mov-info {
    flex: 1;
    min-width: 0;
}

.mov-cat {
    font-size: 14px;
    font-weight: 600;
}

.mov-desc {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mov-meta {
    text-align: right;
    flex-shrink: 0;
}

.mov-amount {
    font-size: 15px;
    font-weight: 700;
}

.mov-amount.spesa { color: var(--red); }
.mov-amount.entrata { color: var(--green); }

.mov-date {
    font-size: 11px;
    color: var(--text-light);
}

.mov-persona {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ---- IMPEGNI ---- */
.impegno-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent);
}

.impegno-card.mutuo { border-left-color: var(--purple); }
.impegno-card.prestito { border-left-color: var(--orange); }
.impegno-card.assicurazione { border-left-color: var(--green); }

.impegno-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.impegno-tipo {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
}

.impegno-tipo.mutuo { background: #ede9fe; color: var(--purple); }
.impegno-tipo.prestito { background: var(--orange-light); color: var(--orange); }
.impegno-tipo.assicurazione { background: var(--green-light); color: var(--green); }

.impegno-nome {
    font-size: 15px;
    font-weight: 600;
}

.impegno-details {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.impegno-rata {
    font-weight: 700;
    color: var(--text);
}

.progress-bar {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

/* ---- PERSONA SALDO ---- */
.persona-saldo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.persona-saldo:last-child { border-bottom: none; }

.persona-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.persona-saldo-info {
    flex: 1;
}

.persona-saldo-nome {
    font-weight: 600;
    font-size: 14px;
}

.persona-saldo-detail {
    font-size: 12px;
    color: var(--text-secondary);
}

.persona-saldo-amount {
    font-weight: 700;
    font-size: 15px;
}

/* ---- FILTRI ---- */
.filters-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.filter-chip {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.filter-chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ---- MESE SELECTOR ---- */
.mese-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
}

.mese-nav button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    color: var(--text-secondary);
}

.mese-nav .mese-label {
    font-size: 16px;
    font-weight: 600;
    min-width: 140px;
    text-align: center;
}

/* ---- MODAL ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-overlay.hidden { display: none; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85dvh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
}

#modal-title {
    font-size: 17px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
}

.modal-body {
    padding: 16px;
}

/* ---- TOAST ---- */
#toast-container {
    position: fixed;
    top: calc(var(--header-height) + 8px);
    left: 16px;
    right: 16px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
    pointer-events: auto;
}

.toast.success { background: var(--green); color: #fff; }
.toast.error { background: var(--red); color: #fff; }
.toast.info { background: var(--accent); color: #fff; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- SETTINGS ---- */
.settings-section {
    margin-bottom: 20px;
}

.settings-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    box-shadow: var(--shadow);
}

.settings-item .label {
    font-size: 14px;
    font-weight: 500;
}

.settings-item .value {
    font-size: 13px;
    color: var(--text-secondary);
}

.color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border);
}

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state .message {
    font-size: 15px;
    margin-bottom: 16px;
}

/* ---- SWIPE TO DELETE ---- */
.swipeable {
    position: relative;
    overflow: hidden;
}

.swipe-actions {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
}

.swipe-delete {
    background: var(--red);
    color: #fff;
    border: none;
    padding: 0 20px;
    height: 100%;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

/* ---- LOGIN SCREEN ---- */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    font-size: 56px;
    text-align: center;
    margin-bottom: 8px;
}

.login-title {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text);
}

.login-divider {
    text-align: center;
    margin: 16px 0;
    position: relative;
    color: var(--text-light);
    font-size: 13px;
}

.login-divider::before,
.login-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border);
}

.login-divider::before { left: 0; }
.login-divider::after { right: 0; }

.login-divider span {
    background: var(--bg-card);
    padding: 0 12px;
}

/* ---- MESE INPUT ---- */
.mese-input {
    font-size: 16px;
    font-weight: 600;
    min-width: 160px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    padding: 6px 12px;
    cursor: pointer;
    font-family: inherit;
}

/* ---- USER INFO ---- */
.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.user-badge.admin {
    background: #ede9fe;
    color: var(--purple);
}

.user-badge.user {
    background: var(--accent-light);
    color: var(--accent);
}

/* ---- ALTRO MENU ---- */
.altro-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.altro-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s;
    font-size: 16px;
    font-weight: 500;
}

.altro-item:active {
    transform: scale(0.98);
}

.altro-icon {
    font-size: 28px;
    width: 40px;
    text-align: center;
}

.altro-desc {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 400;
}

.altro-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 4px 4px;
}
.altro-section-title:first-child {
    padding-top: 0;
}

/* ---- SALVADANAIO ---- */
.salvadanaio-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--orange);
}

.salvadanaio-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.salvadanaio-nome {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

.salvadanaio-saldo {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    margin: 10px 0;
}

.salvadanaio-goal {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 6px;
}

.salvadanaio-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.salvadanaio-actions .btn {
    flex: 1;
    padding: 10px;
    font-size: 13px;
}

.pianificato-badge {
    text-align: center;
    font-size: 12px;
    color: var(--orange);
    font-weight: 600;
    padding: 4px 10px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
}

/* ---- REPORT ---- */
.report-filters {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.report-filters .filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.report-filters .filter-row:last-child {
    margin-bottom: 0;
}

.report-filters .form-input {
    padding: 10px 12px;
    font-size: 14px;
}

.report-filters label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 4px;
    display: block;
}

/* Trend bars */
.trend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.trend-label {
    width: 55px;
    flex-shrink: 0;
    font-weight: 500;
    font-size: 12px;
    color: var(--text-secondary);
}

.trend-bars {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.trend-bar {
    height: 10px;
    border-radius: 5px;
    min-width: 2px;
    transition: width 0.3s;
}

.trend-bar.entrata { background: var(--green); }
.trend-bar.spesa { background: var(--red); }

.trend-amounts {
    width: 80px;
    flex-shrink: 0;
    text-align: right;
    font-size: 11px;
    line-height: 1.4;
}

/* Confronto mesi */
.confronto-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.confronto-col {
    text-align: center;
}

.confronto-col .label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.confronto-col .value {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.confronto-col .sub {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Proiezione impegni */
.impegno-proiezione {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.impegno-proiezione:last-child { border-bottom: none; }

/* Top spese */
.top-spesa-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.top-spesa-item:last-child { border-bottom: none; }

.top-rank {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ---- EMOJI PICKER ---- */
.emoji-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    max-height: 160px;
    overflow-y: auto;
}
.emoji-opt {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}
.emoji-opt:hover { background: var(--accent-light); }
.emoji-opt.selected {
    background: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

/* ---- HEADER ICON BUTTONS ---- */
.header-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    padding: 0;
}
.header-icon-btn:hover, .header-icon-btn:active {
    background: var(--bg-input);
    color: var(--accent);
    border-color: var(--accent);
}

/* ---- USER MENU ---- */
.user-menu-wrapper {
    position: relative;
}
.user-menu-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid var(--accent);
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    padding: 0;
}
.user-menu-btn:hover, .user-menu-btn:active {
    background: var(--accent);
    color: white;
}
.user-dropdown {
    position: absolute;
    top: 44px;
    right: 0;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    z-index: 150;
    overflow: hidden;
    border: 1px solid var(--border);
}
.user-dropdown.hidden { display: none; }
.user-dropdown-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-input);
}
.user-dropdown-header .name {
    font-weight: 600;
    font-size: 14px;
}
.user-dropdown-header .email {
    font-size: 12px;
    color: var(--text-secondary);
}
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    color: var(--text);
}
.user-dropdown-item:hover {
    background: var(--bg-input);
}
.user-dropdown-item.danger {
    color: var(--red);
}
.user-dropdown-sep {
    height: 1px;
    background: var(--border);
    margin: 0;
}
.user-dropdown-version {
    padding: 8px 16px;
    font-size: 11px;
    color: var(--text-light);
    text-align: center;
}

.header-left {
    display: flex;
    align-items: center;
    min-width: 0;
}

.header-codice {
    font-family: monospace;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--accent);
    background: var(--accent-light);
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s;
}
.header-codice:active {
    opacity: 0.6;
}

.copy-banner {
    position: fixed;
    top: calc(var(--header-height) + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--green);
    color: #fff;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    z-index: 200;
    box-shadow: var(--shadow-lg);
    animation: bannerFadeIn 0.2s ease;
}
@keyframes bannerFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- HELP PANEL ---- */
.help-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    border-left: 4px solid var(--accent);
}
.help-panel h3 {
    font-size: 16px;
    color: var(--accent);
    margin: 0 0 10px 0;
}
.help-panel p {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0 0 8px 0;
}
.help-panel ul {
    margin: 8px 0;
    padding-left: 18px;
}
.help-panel li {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.help-panel .help-close {
    display: inline-block;
    margin-top: 10px;
    font-size: 12px;
    color: var(--accent);
    cursor: pointer;
    font-weight: 600;
}
.help-panel .help-manual-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 8px 14px;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s;
}
.help-panel .help-manual-link:hover {
    opacity: 0.85;
}

/* ---- CATEGORIE PREFERITE ---- */
.cat-picker-list {
    max-height: 50vh;
    overflow-y: auto;
}
.cat-picker-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}
.cat-picker-item:active {
    background: var(--accent-light);
}
.cat-picker-star {
    font-size: 20px;
    color: var(--accent);
}
.cat-section-label {
    grid-column: 1 / -1;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    padding: 4px 0 2px;
}
.cat-section-divider {
    grid-column: 1 / -1;
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}
.star-toggle {
    font-size: 18px;
    min-width: 36px;
    padding: 2px 8px;
    color: var(--text-light);
}
.star-toggle.active {
    color: var(--orange);
}

/* ---- ENTRATE RICORRENTI ---- */
.entrata-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--green);
}
.entrata-card.stipendio { border-left-color: #10B981; }
.entrata-card.pensione { border-left-color: #6366F1; }
.entrata-card.affitto { border-left-color: #F59E0B; }
.entrata-card.freelance { border-left-color: #3B82F6; }
.entrata-card.investimenti { border-left-color: #8B5CF6; }
.entrata-card.altro { border-left-color: #6B7280; }

.entrata-tipo {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
}
.entrata-tipo.stipendio { background: #d1fae5; color: #10B981; }
.entrata-tipo.pensione { background: #e0e7ff; color: #6366F1; }
.entrata-tipo.affitto { background: #fef3c7; color: #F59E0B; }
.entrata-tipo.freelance { background: #dbeafe; color: #3B82F6; }
.entrata-tipo.investimenti { background: #ede9fe; color: #8B5CF6; }
.entrata-tipo.altro { background: #f3f4f6; color: #6B7280; }

/* ---- UTILITY ---- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }

/* ---- TOP SAVE BUTTON (Nuovo Movimento) ---- */
.btn-salva-top {
    width: 100%;
    margin-bottom: 12px;
}

/* ---- GRAFICO ANDAMENTO ---- */
.chart-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    cursor: pointer;
}
.chart-checkbox input {
    accent-color: var(--green);
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.chart-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.chart-container canvas {
    display: block;
}
.chart-legenda {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.chart-legenda-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-secondary);
}
.chart-legenda-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ---- Insights Card ---- */
.insights-card {
    background: linear-gradient(135deg, #f0f9ff, #f5f3ff);
    border: 1px solid #e0e7ff;
}
.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text);
}
.insight-item + .insight-item {
    border-top: 1px solid rgba(0,0,0,0.05);
}
.insight-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}
.insight-text {
    flex: 1;
}
.insight-text b {
    font-weight: 700;
}

/* ---- Abbonamento Banner ---- */
.abbonamento-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    gap: 12px;
    font-size: 14px;
}
.abbonamento-banner.info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}
.abbonamento-banner.warning {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}
.abbonamento-banner .btn {
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* ---- RICEVUTA ---- */
.receipt-buttons {
    display: flex;
    gap: 8px;
}
.receipt-btn {
    flex: 1;
    padding: 10px 6px;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.receipt-paste-area {
    margin-top: 8px;
    padding: 12px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
    user-select: none;
}
.receipt-paste-area:focus {
    border-color: var(--accent);
    color: var(--accent);
}
.receipt-paste-area.hidden { display: none; }

.receipt-thumb-wrap {
    position: relative;
    display: inline-block;
    margin-top: 8px;
}

.receipt-thumb {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--border);
    cursor: pointer;
}

.receipt-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--red, #ef4444);
    color: #fff;
    border: none;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ---- GARANZIA ---- */
.garanzia-wrap {
    margin-top: 10px;
    padding: 10px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}
.garanzia-check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}
.garanzia-check-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}
.garanzia-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.garanzia-item:last-child { border-bottom: none; }
.garanzia-info { flex: 1; min-width: 0; }
.garanzia-desc { font-size: 14px; font-weight: 500; }
.garanzia-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.garanzia-status { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.garanzia-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}
.garanzia-badge.garanzia-attiva { background: var(--green-light); color: #059669; }
.garanzia-badge.garanzia-in-scadenza { background: var(--orange-light); color: #d97706; }
.garanzia-badge.garanzia-scaduta { background: var(--red-light); color: #dc2626; }
.garanzia-receipt { cursor: pointer; font-size: 18px; }

.receipt-badge {
    font-size: 12px;
    margin-right: 4px;
}

/* ---- SELEZIONE ALLEGATI ---- */
.allegato-selectable {
    cursor: pointer;
}
.allegato-selectable:not(.allegato-selected) {
    opacity: 0.85;
}
.allegato-selected {
    background: rgba(99, 102, 241, 0.1);
    border-left: 3px solid var(--accent);
    padding-left: 11px;
}
.allegato-check {
    font-size: 18px;
    margin-right: 8px;
    flex-shrink: 0;
    color: var(--accent);
}
.allegati-bar {
    position: fixed;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 480px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 24px rgba(0,0,0,0.3);
    z-index: 90;
}
.allegati-bar.hidden { display: none; }
.allegati-bar-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.allegati-bar-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.allegati-bar-size {
    font-size: 12px;
    color: var(--text-secondary);
}
.allegati-bar-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.allegati-bar-btn:active {
    opacity: 0.85;
}

/* Opzioni invio allegati */
.allegati-send-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.allegati-option {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.15s;
}
.allegati-option:active {
    background: var(--border);
}
.allegati-option-icon {
    font-size: 24px;
    flex-shrink: 0;
}
.allegati-option-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}
.allegati-option-desc {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
}

/* ---- PROGETTI INSIEME ---- */
.progetto-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent);
    cursor: pointer;
    transition: transform 0.15s;
}
.progetto-card:active { transform: scale(0.98); }
.progetto-stato-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 10px;
    flex-shrink: 0;
}
.progetto-stato-badge.attivo { background: var(--green-light); color: var(--green); }
.progetto-stato-badge.chiuso { background: var(--bg-input); color: var(--text-light); }

/* Selettore modalità progetto */
.prog-mode-selector {
    display: flex;
    gap: 10px;
}
.prog-mode-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 10px;
    background: var(--bg-main);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
}
.prog-mode-btn.active {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}
.prog-mode-icon { font-size: 24px; }
.prog-mode-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.prog-mode-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.3; }

.voce-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.voce-item:last-child { border-bottom: none; }
.voce-item.approvata { opacity: 1; }
.voce-item.rifiutata { opacity: 0.5; }
.settlement-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--red-light);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 14px;
}
.settlement-from { font-weight: 700; color: var(--red); }
.settlement-arrow { color: var(--text-secondary); font-weight: 600; white-space: nowrap; }
.settlement-to { font-weight: 700; color: var(--green); }

/* ---- TRASFERIMENTO ESTERNO ---- */
.transfer-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent);
}
.transfer-card.pending { border-left-color: #F59E0B; }
.transfer-card.accepted { border-left-color: #10B981; }
.transfer-card.rejected { border-left-color: #EF4444; }
.transfer-actions { display: flex; gap: 8px; margin-top: 10px; }
.transfer-actions .btn { flex: 1; }
.nav-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #EF4444;
    color: #fff;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    padding: 0 4px;
}

/* ---- ADSENSE ---- */
.ad-banner-bottom {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--safe-bottom));
    left: 0;
    right: 0;
    z-index: 90;
    text-align: center;
    background: #f0f0f0;
    padding: 4px 0;
    border-top: 1px solid var(--border);
}

.ad-block {
    margin: 12px 0;
    text-align: center;
    min-height: 100px;
    overflow: hidden;
    border-radius: var(--radius);
    background: #f9f9f9;
}

.ad-label {
    font-size: 9px;
    text-transform: uppercase;
    color: var(--text-light);
    letter-spacing: 0.5px;
    padding: 4px 0 0;
}

/* ---- Elimina Profilo ---- */
.delete-profile-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.delete-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 8px;
    background: var(--card-bg, #f9fafb);
    border: 1px solid var(--border, #e5e7eb);
    cursor: pointer;
    font-size: 14px;
    transition: border-color 0.2s;
}
.delete-option:hover { border-color: var(--red); }
.delete-option input[type="checkbox"] {
    width: 18px; height: 18px; accent-color: var(--red);
    flex-shrink: 0;
}
.delete-preview-box {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    border: 1px solid var(--border);
}
.delete-preview-total {
    display: flex;
    align-items: baseline;
    margin-bottom: 10px;
}
.delete-preview-ambiti {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.delete-preview-ambito {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}
.delete-preview-ambito .label {
    font-weight: 600;
    color: var(--text);
}
.delete-preview-ambito .value {
    color: var(--text-secondary);
}
.delete-preview-badge {
    font-size: 11px;
    background: var(--orange-light);
    color: var(--orange);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.delete-progress-bar-wrapper {
    width: 100%;
    height: 8px;
    background: var(--border, #e5e7eb);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}
.delete-progress-bar {
    height: 100%;
    background: var(--red);
    border-radius: 4px;
    transition: width 0.4s ease;
}
.delete-progress-log {
    max-height: 220px;
    overflow-y: auto;
    font-size: 13px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    padding: 8px 12px;
}
.delete-step {
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}
.delete-step-done {
    color: var(--green, #10b981);
}
.delete-step-spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--border, #e5e7eb);
    border-top-color: var(--red);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- DARK MODE ---- */
[data-theme="dark"] {
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-input: #252540;
    --text: #e4e4ed;
    --text-secondary: #9ca3af;
    --text-light: #6b7280;
    --border: #2d2d44;
    --accent: #60a5fa;
    --accent-light: #1e3a5f;
    --green: #34d399;
    --green-light: #064e3b;
    --red: #f87171;
    --red-light: #7f1d1d;
    --orange: #fbbf24;
    --orange-light: #78350f;
    --purple: #a78bfa;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
}
[data-theme="dark"] .login-screen {
    background: var(--bg);
}
[data-theme="dark"] .login-card {
    background: var(--bg-card);
    border-color: var(--border);
}
[data-theme="dark"] .modal {
    background: var(--bg-card);
}
[data-theme="dark"] .toast {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}
[data-theme="dark"] .toast.success { border-left: 4px solid var(--green); }
[data-theme="dark"] .toast.error { border-left: 4px solid var(--red); }
[data-theme="dark"] img { filter: brightness(0.9); }
[data-theme="dark"] .insights-card {
    background: linear-gradient(135deg, #1a1a2e, #1e1e3a);
    border-color: var(--border);
}
[data-theme="dark"] .insight-item + .insight-item {
    border-top-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .ad-banner-bottom {
    background: var(--bg-card);
}
[data-theme="dark"] .ad-block {
    background: var(--bg-card);
}
[data-theme="dark"] .impegno-tipo.mutuo {
    background: rgba(167, 139, 250, 0.15);
}
[data-theme="dark"] .user-badge.admin {
    background: rgba(167, 139, 250, 0.15);
}
[data-theme="dark"] .entrata-tipo.stipendio { background: rgba(16, 185, 129, 0.15); }
[data-theme="dark"] .entrata-tipo.pensione { background: rgba(99, 102, 241, 0.15); }
[data-theme="dark"] .entrata-tipo.affitto { background: rgba(245, 158, 11, 0.15); }
[data-theme="dark"] .entrata-tipo.freelance { background: rgba(59, 130, 246, 0.15); }
[data-theme="dark"] .entrata-tipo.investimenti { background: rgba(139, 92, 246, 0.15); }
[data-theme="dark"] .entrata-tipo.altro { background: rgba(107, 114, 128, 0.15); }
[data-theme="dark"] .abbonamento-banner.info {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}
[data-theme="dark"] .abbonamento-banner.warning {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}
[data-theme="dark"] .garanzia-wrap {
    background: rgba(255,255,255,0.05);
}
[data-theme="dark"] .garanzia-badge.garanzia-attiva { background: rgba(16,185,129,0.2); color: #34d399; }
[data-theme="dark"] .garanzia-badge.garanzia-in-scadenza { background: rgba(245,158,11,0.2); color: #fbbf24; }
[data-theme="dark"] .garanzia-badge.garanzia-scaduta { background: rgba(239,68,68,0.2); color: #f87171; }
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
}

/* ---- BUDGET PER CATEGORIA ---- */
.budget-card {
    margin-bottom: 12px;
}
.budget-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.budget-item:last-child { border-bottom: none; }
.budget-info {
    flex: 1;
    min-width: 0;
}
.budget-info .budget-cat {
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.budget-info .budget-detail {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.budget-bar-wrap {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 6px;
}
.budget-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}
.budget-bar.ok { background: var(--green); }
.budget-bar.warn { background: var(--orange); }
.budget-bar.over { background: var(--red); }
.budget-amount {
    text-align: right;
    white-space: nowrap;
    font-size: 13px;
}
.budget-amount .spent {
    font-weight: 700;
}
.budget-amount .limit {
    font-size: 11px;
    color: var(--text-light);
}
.budget-pct {
    font-size: 12px;
    font-weight: 700;
    min-width: 42px;
    text-align: right;
}
.budget-pct.ok { color: var(--green); }
.budget-pct.warn { color: var(--orange); }
.budget-pct.over { color: var(--red); }

/* ---- ONBOARDING ---- */
.onboarding-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: onb-fadein 0.3s ease;
}
@keyframes onb-fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes onb-slidein { from { opacity: 0; transform: translateY(24px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes onb-icon-pop { 0% { transform: scale(0.3) rotate(-15deg); opacity: 0; } 60% { transform: scale(1.15) rotate(3deg); } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.onboarding-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 36px 28px 28px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 16px 48px rgba(0,0,0,0.2);
    animation: onb-slidein 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.onboarding-card h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}
.onboarding-card p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 24px;
}
.onboarding-steps {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 24px;
}
.onboarding-step {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.3s ease;
}
.onboarding-step.active {
    background: var(--accent);
    width: 24px;
    border-radius: 4px;
    transform: none;
}
.onboarding-step.done {
    background: var(--green);
}
.onboarding-icon {
    font-size: 56px;
    margin-bottom: 16px;
    animation: onb-icon-pop 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
    display: inline-block;
}
.onboarding-card .btn {
    margin-top: 8px;
    width: 100%;
}
.onboarding-card .btn-primary {
    padding: 14px;
    font-size: 16px;
    border-radius: 12px;
}
.onboarding-card .btn-outline {
    padding: 10px;
    font-size: 14px;
    border-radius: 10px;
}

/* ---- DASHBOARD HERO ---- */
.dash-hero {
    background: linear-gradient(135deg, #1e293b, #334155);
    border-radius: 16px;
    padding: 24px 20px 20px;
    margin-bottom: 16px;
    color: #fff;
    box-shadow: 0 8px 24px rgba(30, 41, 59, 0.25);
}

.dash-hero-saldo {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -1px;
    text-align: center;
    line-height: 1.1;
}

.dash-hero-saldo.positive { color: #6ee7b7; }
.dash-hero-saldo.negative { color: #fca5a5; }

.dash-hero-label {
    text-align: center;
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    margin-top: 4px;
    margin-bottom: 16px;
}
.dash-riporto {
    text-align: center;
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    margin-top: -10px;
    margin-bottom: 14px;
}

.dash-progress-wrap {
    margin-bottom: 16px;
}

.dash-progress-bar {
    height: 8px;
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
    overflow: hidden;
}

.dash-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10B981, #F59E0B, #EF4444);
    border-radius: 4px;
    transition: width 0.6s ease;
}

.dash-progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    margin-top: 6px;
}

.dash-hero-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.dash-hero-stat {
    flex: 1;
    text-align: center;
}

.dash-hero-stat-value {
    font-size: 20px;
    font-weight: 700;
}

.dash-hero-stat-value.green { color: #6ee7b7; }
.dash-hero-stat-value.red { color: #fca5a5; }

.dash-hero-stat-label {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dash-hero-divider {
    width: 1px;
    height: 36px;
    background: rgba(255,255,255,0.15);
    margin: 0 16px;
}

/* ---- DASHBOARD TOP CATEGORIES ---- */
.dash-top-cat {
    padding: 16px;
}

.dash-cat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.dash-cat-row + .dash-cat-row {
    border-top: 1px solid var(--border);
}

.dash-cat-icon {
    font-size: 20px;
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}

.dash-cat-info {
    flex: 1;
    min-width: 0;
}

.dash-cat-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.dash-cat-bar-wrap {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}

.dash-cat-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.dash-cat-amount {
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    color: var(--red);
}

/* ---- Search Results ---- */
.search-result-item {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.search-result-item:hover {
    background: var(--bg-input);
}

.search-result-item:last-child {
    border-bottom: none;
}

/* ---- SETTINGS MENU (redesign) ---- */
.settings-menu {
    padding: 16px;
    max-width: 500px;
    margin: 0 auto;
}

.settings-group-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 20px 0 8px;
    padding: 0 4px;
}

.settings-group-title:first-child {
    margin-top: 0;
}

.settings-group {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.settings-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}

.settings-menu-item:last-child {
    border-bottom: none;
}

.settings-menu-item:active {
    background: var(--bg-input);
}

.settings-menu-item.current {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.settings-menu-item.danger .settings-menu-label {
    color: var(--red);
}

.settings-menu-item.add-item {
    cursor: pointer;
}

.settings-menu-icon {
    font-size: 22px;
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}

.settings-menu-body {
    flex: 1;
    min-width: 0;
}

.settings-menu-label {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.3;
}

.settings-menu-desc {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 2px;
    line-height: 1.3;
}

.settings-menu-arrow {
    font-size: 20px;
    color: var(--text-light);
    flex-shrink: 0;
    font-weight: 300;
}

.settings-menu-toggle {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.theme-btn {
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.toggle-pill {
    width: 48px;
    height: 28px;
    border-radius: 14px;
    background: var(--border);
    border: none;
    padding: 2px;
    cursor: pointer;
    transition: background 0.25s;
    flex-shrink: 0;
    position: relative;
}

.toggle-pill.active {
    background: var(--green);
}

.toggle-knob {
    display: block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.25s;
}

.toggle-pill.active .toggle-knob {
    transform: translateX(20px);
}

/* Toggle switch (checkbox-based) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    border-radius: 14px;
    transition: background 0.25s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    left: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.25s;
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--green);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.settings-footer {
    text-align: center;
    margin-top: 32px;
    padding-bottom: 24px;
}

.btn-logout {
    background: none;
    border: 1px solid var(--red);
    color: var(--red);
    padding: 12px 40px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:active {
    background: var(--red);
    color: #fff;
}

.settings-version {
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-light);
}

/* ---- Category Popup Tabs & Lists ---- */
.cat-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
}

.cat-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.cat-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.cat-section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 12px 4px 6px;
}

.cat-list-group {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 8px;
}

.cat-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    transition: opacity 0.2s;
}

.cat-list-item:last-child {
    border-bottom: none;
}

.cat-list-item.cat-hidden {
    opacity: 0.4;
}

.cat-list-icon {
    font-size: 18px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.cat-list-body {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cat-list-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.cat-badge-custom {
    font-size: 9px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-light);
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.cat-list-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.cat-action-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.cat-action-btn:active {
    transform: scale(0.92);
}

.cat-action-delete {
    border-color: var(--red-light);
    color: var(--red);
}

.cat-star-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    font-size: 20px;
    color: var(--text-light);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.cat-star-btn.active {
    color: var(--orange);
}

.cat-star-btn:active {
    transform: scale(1.2);
}

/* ---- Settings Personalizzazione ---- */
.settings-item select.form-input {
    padding: 6px 10px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}
