/* =========================================
   ASILFAMILY — SOVEREIGN GOLD THEME v2.0
   Premium Glassmorphism + Micro-Animations
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;800&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
    /* Core Palette */
    --bg-main: #ffffff;
    --bg-card: #f7f6f3;
    --bg-glass: rgba(255, 255, 255, 0.72);
    --bg-glass-dark: rgba(255, 255, 255, 0.45);

    /* Gold System */
    --gold-main: #C9A84C;
    --gold-light: #E2C36A;
    --gold-dark: #A8882E;
    --gold-glow: rgba(201, 168, 76, 0.38);
    --gold-glow-intense: rgba(201, 168, 76, 0.6);
    --gold-subtle: rgba(201, 168, 76, 0.08);

    /* Text */
    --text-dark: #1a1a1a;
    --text-mid: #374151;
    --text-muted: #6b7280;
    --text-faint: #9ca3af;

    /* State Colors */
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.3);
    --success: #10b981;
    --warning: #f59e0b;

    /* Budget Animation Colors */
    --budget-default: #1a1a1a;
    --budget-danger: #ef4444;
    --budget-warning: #f59e0b;
    --budget-recover: #10b981;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.10);
    --shadow-gold: 0 8px 24px var(--gold-glow);

    /* Shape */
    --radius: 18px;
    --radius-sm: 10px;
    --radius-pill: 999px;

    /* Motion */
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
}

/* =====================
   RESET & BASE
   ===================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-card);
    background-image:
        radial-gradient(ellipse at 20% 10%, rgba(201, 168, 76, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 90%, rgba(201, 168, 76, 0.04) 0%, transparent 50%);
    color: var(--text-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

/* =====================
   APP CONTAINER
   ===================== */
.app-container {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    background-color: var(--bg-main);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    position: relative;
    overflow: hidden;
}

/* Subtle grain texture overlay */
.app-container::before {
    content: '';
    position: fixed;
    inset: 0;
    max-width: 480px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.025'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
}

/* =====================
   LOGIN SCREEN
   ===================== */
.login-header {
    text-align: center;
    margin-top: 50px;
    margin-bottom: 55px;
    animation: fadeSlideUp 0.7s var(--ease-out) both;
}

.logo-text {
    font-family: 'Playfair Display', serif;
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: -1.5px;
    line-height: 1;
}

.logo-text .asil {
    color: var(--text-dark);
}

.logo-text .family {
    color: var(--gold-main);
    text-shadow: 0 0 30px var(--gold-glow), 0 2px 8px rgba(201, 168, 76, 0.25);
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    margin-top: 12px;
    letter-spacing: 0.2px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
    animation: fadeSlideUp 0.7s 0.15s var(--ease-out) both;
}

/* =====================
   INPUT GROUPS
   ===================== */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.input-group input {
    width: 100%;
    padding: 15px 18px;
    border: 1.5px solid #e8e6e0;
    border-radius: var(--radius-sm);
    background-color: var(--bg-card);
    font-family: 'DM Sans', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-dark);
    outline: none;
    transition: border-color 0.25s var(--ease-smooth),
        box-shadow 0.25s var(--ease-smooth),
        background-color 0.25s var(--ease-smooth);
}

.input-group input:focus {
    border-color: var(--gold-main);
    box-shadow: 0 0 0 3px var(--gold-glow);
    background-color: var(--bg-main);
}

.input-group input::placeholder {
    color: var(--text-faint);
    font-weight: 400;
}

/* =====================
   BUTTONS
   ===================== */
.btn {
    width: 100%;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: transform 0.18s var(--ease-spring),
        box-shadow 0.25s var(--ease-smooth),
        background-color 0.2s var(--ease-smooth);
    text-align: center;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.2px;
}

/* Ripple effect */
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.2);
    opacity: 0;
    border-radius: inherit;
    transition: opacity 0.3s;
}

.btn:active {
    transform: scale(0.97);
}

.btn:active::after {
    opacity: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold-main) 50%, var(--gold-dark) 100%);
    color: #fff;
    box-shadow: var(--shadow-gold), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover {
    box-shadow: 0 10px 30px var(--gold-glow-intense);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: scale(0.97) translateY(0);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-muted);
    border: 1.5px solid #e8e6e0;
    font-weight: 600;
}

.btn-secondary:hover {
    border-color: var(--gold-main);
    color: var(--gold-main);
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--gold-main);
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.85rem;
    letter-spacing: 0.3px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s, transform 0.15s;
}

.btn-text:hover {
    background: var(--gold-subtle);
}

.btn-text:active {
    transform: scale(0.96);
}

.btn-danger {
    width: 100%;
    background: linear-gradient(135deg, #f87171, #ef4444);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    padding: 15px;
    transition: transform 0.18s var(--ease-spring), box-shadow 0.25s;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.28);
}

.btn-danger:active {
    transform: scale(0.97);
}

/* =====================
   DIVIDER
   ===================== */
.divider {
    text-align: center;
    color: var(--text-faint);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin: 16px 0;
    position: relative;
}

.divider::before,
.divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 38%;
    height: 1px;
    background: linear-gradient(to right, transparent, #e5e7eb);
}

.divider::before {
    left: 0;
    background: linear-gradient(to right, transparent, #e5e7eb);
}

.divider::after {
    right: 0;
    background: linear-gradient(to left, transparent, #e5e7eb);
}

/* =====================
   DASHBOARD LAYOUT
   ===================== */
.dashboard-layout {
    padding: 20px 22px 0 22px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.4s var(--ease-out) both;
}

/* HEADER */
.dash-header {
    position: relative;
    z-index: 10;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    flex-wrap: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.header-icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: 0.2s;
    flex-shrink: 0;
}

.header-icon-btn:hover {
    background: rgba(0,0,0,0.05);
}

.header-icon-btn.header-icon-gold {
    color: var(--gold-main);
}

/* Header responsive: prevent overflow on small screens */
@media (max-width: 380px) {
    .header-row { gap: 2px; }
    .budget-display { max-width: 90px; }
    .budget-amount { font-size: 1rem; }
    .header-icon-btn { width: 24px; height: 24px; font-size: 0.8rem; }
}

/* =====================
   BUDGET DISPLAY + ANIMATION ENGINE
   ===================== */
.budget-display {
    text-align: center;
}

.budget-label {
    font-size: 0.68rem;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
    display: block;
    margin-bottom: 2px;
}

/* The budget amount — the star of the show */
.budget-amount {
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--budget-default);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 8px;
    transition: color 0.6s var(--ease-smooth),
        text-shadow 0.6s var(--ease-smooth),
        transform 0.3s var(--ease-spring);
    display: inline-block;
    min-width: 60px;
    margin: 0;
    text-align: right;
    white-space: nowrap;
}

.budget-amount:active {
    background: var(--gold-subtle);
}

/* Budget state classes — toggled by JS */
.budget-amount.state-danger {
    color: var(--danger) !important;
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.5), 0 0 8px rgba(239, 68, 68, 0.3);
    animation: budgetPulseRed 0.6s var(--ease-spring);
}

.budget-amount.state-warning {
    color: var(--warning) !important;
    text-shadow: 0 0 16px rgba(245, 158, 11, 0.4);
    animation: budgetPulseWarn 0.5s var(--ease-spring);
}

.budget-amount.state-recover {
    color: var(--success) !important;
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.5), 0 0 8px rgba(16, 185, 129, 0.3);
    animation: budgetPulseGreen 0.6s var(--ease-spring);
}

.budget-amount.state-normal {
    color: var(--budget-default) !important;
    text-shadow: none;
}

/* Tick-up animation when budget number changes */
.budget-amount.tick-up {
    animation: tickUp 0.4s var(--ease-spring);
}

.budget-amount.tick-down {
    animation: tickDown 0.35s var(--ease-spring);
}

@keyframes budgetPulseRed {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.12);
    }

    60% {
        transform: scale(0.97);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes budgetPulseGreen {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.1);
    }

    70% {
        transform: scale(0.98);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes budgetPulseWarn {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.06);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes tickUp {
    0% {
        transform: translateY(4px);
        opacity: 0.7;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes tickDown {
    0% {
        transform: translateY(-4px);
        opacity: 0.7;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* =====================
   FAMILY SELECTOR
   ===================== */
.custom-family-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(201, 168, 76, 0.18);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.22s var(--ease-smooth);
    max-width: 160px;
    font-size: 0.85rem;
}

.custom-family-selector:hover {
    border-color: rgba(201, 168, 76, 0.35);
    box-shadow: 0 4px 16px var(--gold-glow);
}

.custom-family-selector:active {
    transform: scale(0.97);
}

.selector-content {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--text-dark);
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chevron-icon {
    color: var(--gold-main);
    font-size: 0.75rem;
    transition: transform 0.3s var(--ease-smooth);
}

.custom-family-selector.open .chevron-icon {
    transform: rotate(180deg);
}

/* Dropdown */
.custom-dropdown {
    position: absolute;
    top: 68px;
    left: 22px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(201, 168, 76, 0.2);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    width: 230px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.97);
    transition: all 0.25s var(--ease-spring);
    overflow: hidden;
}

.custom-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dropdown-item {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, padding-left 0.2s;
}

.dropdown-item:hover {
    background: var(--gold-subtle);
    color: var(--text-dark);
    padding-left: 20px;
}

.dropdown-item.active {
    color: var(--gold-main);
    font-weight: 700;
}

.dropdown-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    margin: 4px 0;
}

.dropdown-item.add-new {
    color: var(--gold-main);
    font-size: 0.85rem;
}

/* =====================
   SHOPPING LIST SECTION
   ===================== */
.shopping-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px 0;
    scrollbar-width: none;
}

.shopping-list::-webkit-scrollbar {
    display: none;
}

.section-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    color: var(--text-dark);
    margin-bottom: 15px;
    font-weight: 700;
}

/* List Items */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-main);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 9px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid #d1d5db;
    transition: transform 0.2s var(--ease-spring),
        box-shadow 0.2s var(--ease-smooth),
        opacity 0.3s var(--ease-smooth);
    animation: listItemIn 0.35s var(--ease-spring) both;
    overflow: hidden;
}

/* Skip entrance animation for items already in the list */
.list-item.no-anim {
    animation: none;
}

@keyframes listItemIn {
    from {
        opacity: 0;
        transform: translateX(-12px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.list-item:hover {
    transform: translateX(3px);
    box-shadow: var(--shadow-md);
}

/* Check animation - item being removed */
.list-item.checking-out {
    animation: checkOut 0.4s var(--ease-smooth) forwards;
}

@keyframes checkOut {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    30% {
        transform: scale(1.03);
    }

    100% {
        transform: scale(0.9) translateX(20px);
        opacity: 0;
        height: 0;
        padding: 0;
        margin: 0;
    }
}

.priority-high {
    border-left-color: #ef4444;
}

.priority-med {
    border-left-color: #f59e0b;
}

.priority-low {
    border-left-color: #10b981;
}

.item-info {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.item-icon {
    font-size: 1.7rem;
    flex-shrink: 0;
}

.item-text h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-text p {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-text {
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.15s;
    min-width: 0;
    overflow: hidden;
}

.item-text:active {
    background: rgba(0, 0, 0, 0.04);
}

/* Check button */
.check-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid #e5e7eb;
    background: transparent;
    color: transparent;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s, transform 0.15s var(--ease-spring);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.check-btn:hover {
    border-color: var(--success);
    color: var(--success);
    background: rgba(16, 185, 129, 0.08);
}

.check-btn:active {
    transform: scale(0.88);
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

/* Edit button */
.edit-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid #e5e7eb;
    background: transparent;
    color: transparent;
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    margin-right: 7px;
}

.edit-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.07);
}

/* =====================
   SMART GRID FOOTER
   ===================== */
.smart-grid-container {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    margin: 0 -16px;
    padding: 10px 16px 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.04);
}

.smart-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* =====================
   STICKER PICKER
   ===================== */
.sticker-scroll-area {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    scrollbar-width: none;
}

.sticker-scroll-area::-webkit-scrollbar {
    display: none;
}

.sticker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    height: 56px;
    background: var(--bg-main);
    border-radius: 12px;
    border: 1.5px solid #e8e6e0;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.18s var(--ease-spring),
        box-shadow 0.2s var(--ease-smooth),
        border-color 0.2s var(--ease-smooth);
    position: relative;
    overflow: hidden;
    animation: stickerIn 0.4s var(--ease-spring) both;
}

@keyframes stickerIn {
    from {
        transform: scale(0.7);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Staggered animation for stickers */
.sticker-item:nth-child(1) {
    animation-delay: 0.02s;
}

.sticker-item:nth-child(2) {
    animation-delay: 0.04s;
}

.sticker-item:nth-child(3) {
    animation-delay: 0.06s;
}

.sticker-item:nth-child(4) {
    animation-delay: 0.08s;
}

.sticker-item:nth-child(5) {
    animation-delay: 0.10s;
}

.sticker-item:nth-child(6) {
    animation-delay: 0.12s;
}

.sticker-item:nth-child(7) {
    animation-delay: 0.14s;
}

.sticker-item:nth-child(8) {
    animation-delay: 0.16s;
}

.sticker-item:nth-child(9) {
    animation-delay: 0.18s;
}

.sticker-item:nth-child(10) {
    animation-delay: 0.20s;
}

.sticker-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 120%, rgba(255, 255, 255, 0.6) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.2s;
}

.sticker-item:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
}

.sticker-item:hover::after {
    opacity: 1;
}

.sticker-item:active {
    transform: scale(0.88);
    box-shadow: none;
}

/* Long-press visual feedback */
.sticker-item.pressing {
    transform: scale(0.92);
    box-shadow: 0 0 0 3px var(--gold-glow);
    border-color: var(--gold-main);
}

.sticker-emoji {
    font-size: 1.3rem;
    margin-bottom: 1px;
}

.sticker-name {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 54px;
    letter-spacing: 0.1px;
}

/* Store border colors */
.border-generic {
    border-color: #d4d4d4;
}

.border-store-1 {
    border-color: #ef4444;
    box-shadow: 0 0 0 0px rgba(239, 68, 68, 0.2);
}

.border-store-2 {
    border-color: #f97316;
}

.border-store-3 {
    border-color: #84cc16;
}

.border-store-4 {
    border-color: #3b82f6;
}

.border-store-5 {
    border-color: #8b5cf6;
}

/* =====================
   MODALS (GLASSMORPHISM)
   ===================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 10, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: opacity 0.28s var(--ease-smooth);
}

.modal-overlay.show {
    display: block !important;
    opacity: 1 !important;
}

.custom-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -44%) scale(0.96);
    background: var(--bg-glass);
    backdrop-filter: blur(24px) saturate(1.8);
    -webkit-backdrop-filter: blur(24px) saturate(1.8);
    border: 1px solid rgba(255, 255, 255, 0.65);
    width: 92%;
    max-width: 400px;
    padding: 26px;
    border-radius: var(--radius);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(201, 168, 76, 0.08) inset;
    z-index: 2001;
    display: none;
    opacity: 0;
    transition: all 0.3s var(--ease-spring);
}

.custom-modal.show {
    display: block !important;
    opacity: 1 !important;
    transform: translate(-50%, -50%) scale(1) !important;
}

.custom-modal h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =====================
   QUICK EMOJI BUTTONS
   ===================== */
.quick-emoji {
    background: var(--bg-card);
    border: 1.5px solid #e8e6e0;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.15s var(--ease-spring), border-color 0.2s;
}

.quick-emoji:active {
    border-color: var(--gold-main);
    transform: scale(0.88);
}

/* =====================
   BUDGET DISPLAY CARET
   ===================== */
.budget-label::after {
    content: ' ✏️';
    font-size: 0.65rem;
    opacity: 0.6;
}

/* =====================
   STORE SELECT BUTTONS
   ===================== */
.store-select-btn {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    border: 1.5px solid #e8e6e0;
    background: var(--bg-card);
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    text-align: left;
    animation: fadeSlideUp 0.3s var(--ease-out) both;
}

.store-select-btn:hover,
.store-select-btn:active {
    border-color: var(--gold-main);
    background: var(--gold-subtle);
    transform: translateX(4px);
}

.store-select-btn i {
    color: var(--gold-main);
    margin-right: 10px;
}

/* =====================
   FAB BUTTON
   ===================== */
.fab-button {
    position: fixed;
    bottom: 88px;
    right: 28px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
    color: #fff;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 6px 22px var(--gold-glow-intense), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    z-index: 1500;
    transition: transform 0.2s var(--ease-spring), box-shadow 0.2s;
    animation: fabEntrance 0.5s var(--ease-spring) both, fabPulse 3s 0.5s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab-button:active {
    transform: scale(0.88);
}

@keyframes fabEntrance {
    from {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }

    to {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes fabPulse {

    0%,
    100% {
        box-shadow: 0 6px 22px var(--gold-glow);
    }

    50% {
        box-shadow: 0 8px 32px var(--gold-glow-intense);
    }
}

/* =====================
   FOCUS MODE
   ===================== */
.focus-active .dash-header {
    border-bottom: none;
    padding-bottom: 8px;
}

/* =====================
   GLOBAL LOADER
   ===================== */
@keyframes rotazioneAsil {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.asil-spinner {
    animation: rotazioneAsil 0.9s linear infinite !important;
    display: inline-block;
}

/* =====================
   MEMBER MANAGEMENT
   ===================== */
.member-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 13px 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 9px;
    border: 1.5px solid #e8e6e0;
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    animation: fadeSlideUp 0.3s var(--ease-out) both;
    overflow: hidden;
}

.member-card:hover {
    border-color: var(--gold-main);
    box-shadow: 0 4px 16px var(--gold-glow);
    transform: translateY(-1px);
}

.member-card:active {
    transform: scale(0.98);
}

.member-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.member-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.member-details {
    min-width: 0;
    overflow: hidden;
    flex: 1;
}

.member-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-email {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
    white-space: nowrap;
}

.role-select-btn {
    width: 100%;
    padding: 12px 15px;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    border: 1.5px solid #e8e6e0;
    background: var(--bg-card);
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.role-select-btn:hover {
    border-color: var(--gold-main);
}

.role-select-btn.selected {
    border-color: var(--gold-main);
    background: var(--gold-subtle);
    box-shadow: 0 0 0 3px var(--gold-glow);
}

.role-select-btn .role-level {
    font-size: 0.68rem;
    color: var(--text-muted);
    background: var(--bg-main);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
}

/* Permission Toggles */
.perm-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: background 0.2s;
}

.perm-toggle-row:last-child {
    border-bottom: none;
}

.perm-toggle-label {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-dark);
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #d1d5db;
    border-radius: var(--radius-pill);
    transition: 0.3s var(--ease-smooth);
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s var(--ease-spring);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--gold-main);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(20px);
}

/* Locked UI */
.perm-locked {
    opacity: 0.38;
    pointer-events: none;
    position: relative;
    filter: grayscale(0.3);
}

.perm-locked::after {
    content: "🔒";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.4rem;
}

/* Scope Buttons */
.scope-btn {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    border: 1.5px solid #e8e6e0;
    background: var(--bg-card);
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    text-align: left;
    display: flex;
    align-items: center;
}

.scope-btn:hover {
    border-color: var(--gold-main);
    background: var(--gold-subtle);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--gold-glow);
}

/* =====================
   RECEIPT SCANNER
   ===================== */
.receipt-item {
    display: flex;
    flex-direction: column;
    padding: 16px;
    border-radius: 14px;
    margin-bottom: 10px;
    background: var(--bg-main);
    border: 1px solid rgba(201, 168, 76, 0.18);
    box-shadow: var(--shadow-sm);
    transition: all 0.25s var(--ease-smooth);
    animation: fadeSlideUp 0.3s var(--ease-out) both;
    overflow: hidden;
    word-break: break-word;
}

.receipt-item:hover {
    box-shadow: 0 6px 20px var(--gold-glow);
    transform: translateY(-2px);
}

.receipt-item.match {
    border-left: 4px solid #10b981;
}

.receipt-item.new {
    border-left: 4px solid var(--gold-main);
}

.receipt-item-checkbox {
    width: 22px;
    height: 22px;
    accent-color: var(--gold-main);
    cursor: pointer;
    border-radius: 6px;
    margin-left: 5px;
}

.receipt-item-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e8e6e0;
    border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    background: var(--bg-card);
    color: var(--text-dark);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.receipt-item-input:focus {
    border-color: var(--gold-main);
    outline: none;
    box-shadow: 0 0 0 3px var(--gold-glow);
}

/* =====================
   ANIMATIONS & UTILITIES
   ===================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    from {
        background-position: -200% 0;
    }

    to {
        background-position: 200% 0;
    }
}

/* Skeleton loader effect */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, #ede9df 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    color: transparent !important;
}

/* Icon button (generic) */
.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    transition: transform 0.15s var(--ease-spring), opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:active {
    transform: scale(0.85);
}

/* Long-press ring for sticker items */
@keyframes longPressRing {
    from {
        box-shadow: 0 0 0 0 var(--gold-glow);
    }

    to {
        box-shadow: 0 0 0 8px rgba(201, 168, 76, 0);
    }
}

.sticker-item.long-pressing {
    animation: longPressRing 0.5s var(--ease-out) forwards;
    border-color: var(--gold-main);
}

/* =========================================
   TOAST NOTIFICATIONS
   ========================================= */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    width: calc(100% - 40px);
    max-width: 420px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: white;
    box-shadow: var(--shadow-md);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    position: relative;
    overflow: hidden;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.hide {
    opacity: 0;
    transform: translateY(20px);
}

.toast i {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
}

.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info { background: var(--gold-dark); }

.toast-undo {
    background: var(--text-dark);
    flex-wrap: wrap;
}

.toast-undo-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.toast-undo-btn {
    background: none;
    border: none;
    color: var(--gold-light);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    font-family: 'DM Sans', sans-serif;
}

.toast-undo-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: var(--gold-main);
    transform-origin: left;
}

.toast-progress.animate {
    animation: toastProgress linear forwards;
}

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* =========================================
   ITEM CHECKED (Undo pending)
   ========================================= */
.list-item.item-checked {
    opacity: 0.4;
    text-decoration: line-through;
    transition: opacity 0.3s;
}

/* =========================================
   STICKER SEARCH BAR
   ========================================= */
.sticker-search-wrapper {
    position: relative;
    margin-bottom: 6px;
}

.sticker-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.sticker-search-input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    background: var(--bg-card);
    color: var(--text-dark);
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.sticker-search-input:focus {
    border-color: var(--gold-main);
}

.sticker-search-input::placeholder {
    color: var(--text-faint);
}

/* =========================================
   LIST FILTERS
   ========================================= */
.list-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.list-filters::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    padding: 6px 14px;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-pill);
    background: var(--bg-card);
    color: var(--text-muted);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.filter-chip:hover {
    border-color: var(--gold-main);
    color: var(--gold-dark);
}

.filter-chip.active {
    background: var(--gold-main);
    color: white;
    border-color: var(--gold-main);
}

.filter-store-chips {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.filter-store-chip {
    padding: 4px 10px;
    border: 1px solid var(--gold-main);
    border-radius: var(--radius-pill);
    background: var(--gold-subtle);
    color: var(--gold-dark);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-store-chip.active {
    background: var(--gold-main);
    color: white;
}

/* =========================================
   EMPTY STATES
   ========================================= */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    text-align: left;
}

.empty-state-icon {
    font-size: 2.5rem;
    color: var(--text-faint);
    margin-bottom: 12px;
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-mid);
    margin: 0 0 6px 0;
}

.empty-state-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

/* =========================================
   LANGUAGE SELECTOR
   ========================================= */
#langBtn {
    position: relative;
}

.lang-dropdown {
    display: none;
    position: fixed;
    top: 50px;
    right: 60px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(201, 168, 76, 0.25);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 5000;
    overflow: hidden;
    min-width: 160px;
}

.lang-dropdown.show {
    display: flex;
    flex-direction: column;
    animation: fadeInDown 0.2s ease;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.lang-option:hover {
    background: var(--gold-subtle);
}

.lang-option.active {
    background: var(--gold-subtle);
    color: var(--gold-dark);
    font-weight: 600;
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =========================================
   PRIORITY SYSTEM
   ========================================= */

/* Priority Selector (chip group in modals) */
.priority-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.priority-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: var(--radius-pill);
    border: 1.5px solid #e5e7eb;
    background: var(--bg-card);
    color: var(--text-mid);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.priority-chip:hover {
    border-color: var(--text-muted);
}

.priority-chip.active {
    border-color: var(--gold-main);
    background: var(--gold-subtle);
    color: var(--gold-dark);
}

.priority-chip.priority-urgent.active {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.priority-chip.priority-necessary.active {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

.priority-chip.priority-treat.active {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
    color: #7c3aed;
}

/* Priority Badge (on stickers and list items) */
.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.4;
}

.priority-badge.badge-urgent {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.priority-badge.badge-necessary {
    background: rgba(59, 130, 246, 0.15);
    color: #2563eb;
}

.priority-badge.badge-treat {
    background: rgba(139, 92, 246, 0.15);
    color: #7c3aed;
}

/* Priority badge on stickers */
.sticker-item .priority-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.55rem;
    padding: 1px 5px;
}

.sticker-item {
    position: relative;
}

/* Priority indicator stripe on shopping list items */
.list-item.priority-item-urgent {
    border-left: 3px solid #ef4444;
}

.list-item.priority-item-necessary {
    border-left: 3px solid #3b82f6;
}

.list-item.priority-item-treat {
    border-left: 3px solid #8b5cf6;
}

html[dir="rtl"] .list-item.priority-item-urgent,
html[dir="rtl"] .list-item.priority-item-necessary,
html[dir="rtl"] .list-item.priority-item-treat {
    border-left: none;
    border-right: 3px solid;
}

html[dir="rtl"] .list-item.priority-item-urgent { border-right-color: #ef4444; }
html[dir="rtl"] .list-item.priority-item-necessary { border-right-color: #3b82f6; }
html[dir="rtl"] .list-item.priority-item-treat { border-right-color: #8b5cf6; }

/* Focus mode priority filter chips */
.priority-filter-chips {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.focus-priority-chip {
    display: block;
    width: 100%;
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    border: 1.5px solid #e5e7eb;
    background: var(--bg-card);
    color: var(--text-mid);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.focus-priority-chip:hover {
    border-color: var(--gold-main);
}

.focus-priority-chip.active {
    border-color: var(--gold-main);
    background: var(--gold-subtle);
    color: var(--gold-dark);
}

html[dir="rtl"] .focus-priority-chip {
    text-align: right;
}

html[dir="rtl"] .sticker-item .priority-badge {
    right: auto;
    left: 4px;
}

/* =========================================
   ANALYTICS FULLSCREEN PAGE
   ========================================= */
.analytics-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-main);
    z-index: 5000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.analytics-fullscreen.open {
    display: flex;
}

.analytics-fs-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.analytics-back-btn {
    background: none;
    border: none;
    color: var(--gold-main);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.analytics-back-btn:hover {
    background: rgba(212, 175, 55, 0.1);
}

.analytics-fs-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-dark);
    display: flex;
    align-items: center;
}

.analytics-fs-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

.analytics-period-chips {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.period-chip {
    background: var(--bg-card);
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.period-chip:hover {
    border-color: var(--gold-main);
    color: var(--gold-main);
}

.period-chip.active {
    background: var(--gold-main);
    color: white;
    border-color: var(--gold-main);
}

.analytics-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-dark);
    letter-spacing: -0.5px;
}

.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 15px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.chart-title {
    margin: 0 0 12px 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dark);
}

.chart-container {
    position: relative;
    width: 100%;
}

.chart-doughnut { height: 260px; }
.chart-line { height: 230px; }
.chart-bar { height: 210px; }
.chart-horizontal { height: 320px; }

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Suggestion cards */
.suggestion-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: var(--bg-main);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid #f0f0f0;
}

.suggestion-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
}

.suggestion-text {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-dark);
    line-height: 1.4;
}

/* Header analytics icon */
#analyticsBtn:hover {
    color: var(--gold-main) !important;
}

/* Analytics RTL */
html[dir="rtl"] .analytics-fs-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .analytics-back-btn i {
    transform: scaleX(-1);
}

html[dir="rtl"] .suggestion-card {
    flex-direction: row-reverse;
    text-align: right;
}

/* =========================================
   PREMIUM PAGE & THEMES
   ========================================= */
.premium-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-main);
    z-index: 5000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.premium-fullscreen.open {
    display: flex;
}

.premium-status-card {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.12), rgba(212, 175, 55, 0.04));
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    margin-bottom: 20px;
}

.premium-badge-active {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--gold-main);
    color: white;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
}

.premium-expires {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 8px;
}

.premium-features {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 25px;
}

.premium-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid #e5e7eb;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-dark);
}

.premium-feature i {
    color: var(--gold-main);
    width: 20px;
    text-align: center;
}

.premium-pricing {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 25px;
}

.price-card {
    background: var(--bg-card);
    border: 2px solid #e5e7eb;
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    position: relative;
}

.price-card h4 {
    margin: 0 0 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.price-card-best {
    border-color: var(--gold-main);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.15);
}

.price-badge-save {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gold-main);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 10px;
    white-space: nowrap;
}

.price-amount {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.price-amount span {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.price-monthly-equiv {
    font-size: 0.75rem;
    color: var(--gold-main);
    font-weight: 600;
    margin-bottom: 12px;
}

.premium-buy-btn {
    width: 100%;
    padding: 10px !important;
    font-size: 0.85rem !important;
}

/* Theme grid */
.theme-section {
    margin-top: 10px;
}

.theme-scope-note {
    margin: 0 0 14px;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.theme-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0 0 15px;
    display: flex;
    align-items: center;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.theme-card {
    background: var(--bg-card);
    border: 2px solid #e5e7eb;
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.theme-card:hover {
    border-color: var(--gold-main);
    transform: translateY(-2px);
}

.theme-card.active {
    border-color: var(--gold-main);
    background: rgba(212, 175, 55, 0.06);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.15);
}

.theme-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.theme-card.locked:hover {
    transform: none;
}

.theme-icon {
    font-size: 1.5rem;
    margin-bottom: 6px;
}

.theme-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-dark);
}

.theme-badge {
    position: absolute;
    left: 8px;
    top: 8px;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    background: var(--gold-main);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.22);
}

.theme-badge-soft {
    top: auto;
    bottom: 8px;
    background: rgba(15, 23, 42, 0.72);
    box-shadow: none;
}

.theme-lock-icon {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* Premium activated animation */
.premium-activated-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.5s;
}

.premium-activated-overlay.show {
    opacity: 1;
}

.premium-activated-content {
    text-align: center;
    color: white;
    animation: premiumBounce 0.6s ease;
}

.premium-shield {
    font-size: 5rem;
    margin-bottom: 15px;
    animation: premiumPulse 1s ease infinite;
}

.premium-activated-content h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: #D4AF37;
    margin: 0 0 8px;
}

.premium-activated-content p {
    font-size: 1rem;
    color: rgba(255,255,255,0.8);
    margin: 0;
}

@keyframes premiumBounce {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes premiumPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* =========================================
   RTL SUPPORT (Arabic)
   ========================================= */
html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .header-row {
    flex-direction: row-reverse;
}

html[dir="rtl"] .header-actions {
    flex-direction: row-reverse;
}

html[dir="rtl"] .family-info {
    direction: rtl;
}

html[dir="rtl"] .member-info {
    flex-direction: row-reverse;
}

html[dir="rtl"] .list-item {
    flex-direction: row-reverse;
}

html[dir="rtl"] .sticker-search-icon {
    left: auto;
    right: 12px;
}

html[dir="rtl"] .sticker-search-input {
    padding-left: 12px;
    padding-right: 36px;
}

html[dir="rtl"] .smart-grid-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .custom-modal {
    text-align: right;
}

html[dir="rtl"] .input-group {
    text-align: right;
}

html[dir="rtl"] .role-badge {
    margin-left: 0;
    margin-right: auto;
}

html[dir="rtl"] .member-card {
    flex-direction: row-reverse;
}

html[dir="rtl"] .chevron-icon {
    transform: rotate(180deg);
}

html[dir="rtl"] .toast-container {
    direction: rtl;
}

html[dir="rtl"] .lang-dropdown {
    right: auto;
    left: 60px;
}

html[dir="rtl"] .lang-option {
    text-align: right;
    flex-direction: row-reverse;
}

html[dir="rtl"] .budget-amount {
    text-align: left;
}

html[dir="rtl"] .list-item {
    border-left: none;
    border-right: 4px solid #d1d5db;
}

html[dir="rtl"] .custom-dropdown {
    left: auto;
    right: 22px;
}

html[dir="rtl"] .list-item.item-enter {
    transform: translateX(12px) scale(0.98);
}

/* =========================================
   UI REFRESH OVERRIDES
   ========================================= */
body {
    background-color: #efe9dc;
    background-image:
        radial-gradient(circle at top left, rgba(201, 168, 76, 0.24) 0%, transparent 34%),
        radial-gradient(circle at 100% 20%, rgba(111, 78, 33, 0.12) 0%, transparent 28%),
        linear-gradient(180deg, #f6f0e4 0%, #ece3d4 100%);
}

.app-container {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(250, 247, 241, 0.98) 100%);
    border-radius: 30px;
    border: 1px solid rgba(93, 64, 31, 0.08);
}

.auth-shell {
    justify-content: space-between;
    padding: 24px 18px 22px;
    background:
        radial-gradient(circle at top center, rgba(201, 168, 76, 0.18) 0%, transparent 36%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 243, 235, 0.98) 100%);
}

.auth-stage {
    position: relative;
    z-index: 1;
}

.auth-shell::after {
    content: '';
    position: absolute;
    inset: 14px 18px auto;
    height: 180px;
    border-radius: 34px;
    background:
        radial-gradient(circle at 50% 25%, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0) 70%),
        linear-gradient(135deg, rgba(201, 168, 76, 0.14), rgba(255, 255, 255, 0));
    pointer-events: none;
}

.login-header {
    margin-top: 24px;
    margin-bottom: 24px;
}

.logo-text {
    font-size: clamp(2.9rem, 9vw, 3.4rem);
}

.subtitle {
    max-width: 290px;
    margin: 14px auto 0;
    font-size: 1rem;
    line-height: 1.55;
}

.auth-card {
    position: relative;
    z-index: 1;
    gap: 16px;
    padding: 22px 20px;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid rgba(201, 168, 76, 0.22);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow:
        0 24px 45px rgba(79, 58, 32, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.auth-error {
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(239, 68, 68, 0.18);
    background: rgba(254, 242, 242, 0.95);
    color: #b91c1c;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
}

.auth-footer {
    position: relative;
    z-index: 1;
    margin-top: 18px;
    padding: 16px 10px 4px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.65;
}

.legal-inline-links {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.legal-inline-links a {
    color: var(--text-dark);
    text-decoration: none;
}

.legal-inline-links a:hover {
    color: var(--gold-main);
}

.auth-card .input-group input {
    padding: 16px 18px;
    border-radius: 16px;
    background: rgba(247, 243, 236, 0.92);
}

.auth-card .btn {
    border-radius: 16px;
}

.dashboard-shell {
    gap: 12px;
    padding: 16px 18px 0;
    background:
        radial-gradient(circle at top center, rgba(201, 168, 76, 0.14) 0%, transparent 30%),
        linear-gradient(180deg, rgba(250, 247, 241, 0.98) 0%, rgba(245, 239, 229, 0.98) 100%);
}

.dash-hero {
    padding: 14px;
    border-radius: 28px;
    border: 1px solid rgba(201, 168, 76, 0.18);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(248, 243, 235, 0.88));
    box-shadow:
        0 16px 34px rgba(82, 61, 33, 0.09),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    border-bottom: none;
}

.header-row {
    gap: 10px;
    align-items: stretch;
}

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

.custom-family-selector {
    min-height: 60px;
    padding: 12px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(201, 168, 76, 0.2);
    box-shadow: 0 10px 18px rgba(72, 54, 29, 0.08);
}

.selector-content {
    gap: 8px;
    font-size: 0.92rem;
    max-width: 100%;
}

.budget-display {
    min-width: 118px;
    padding: 10px 12px;
    border-radius: 20px;
    background:
        linear-gradient(145deg, rgba(201, 168, 76, 0.16), rgba(255, 255, 255, 0.74));
    border: 1px solid rgba(201, 168, 76, 0.22);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.budget-label {
    letter-spacing: 1.7px;
}

.budget-amount {
    font-size: 1.28rem;
    min-width: 78px;
}

.header-actions {
    gap: 6px;
    padding: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(201, 168, 76, 0.16);
    box-shadow: 0 8px 18px rgba(72, 54, 29, 0.07);
}

.header-icon-btn {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
}

.header-icon-btn:hover {
    background: rgba(201, 168, 76, 0.12);
}

.shopping-panel {
    padding: 14px 14px 18px;
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(248, 243, 235, 0.82));
    border: 1px solid rgba(201, 168, 76, 0.16);
    box-shadow: 0 18px 36px rgba(82, 61, 33, 0.08);
}

.shopping-list-header {
    position: sticky;
    top: 0;
    z-index: 3;
    gap: 12px;
    padding: 2px 2px 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 255, 255, 0) 100%);
}

.shopping-list-header .btn {
    width: auto;
    white-space: nowrap;
}

.list-filters {
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 4px;
}

.filter-chip {
    padding: 8px 15px;
    border: 1px solid rgba(201, 168, 76, 0.14);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 6px 14px rgba(82, 61, 33, 0.06);
    font-weight: 600;
}

.filter-chip.active {
    background: linear-gradient(135deg, var(--gold-light), var(--gold-main));
    color: #fff;
    box-shadow: 0 10px 22px rgba(201, 168, 76, 0.24);
}

.list-item {
    padding: 15px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(201, 168, 76, 0.08);
    box-shadow: 0 12px 22px rgba(82, 61, 33, 0.06);
}

.list-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 28px rgba(82, 61, 33, 0.09);
}

.item-info {
    gap: 12px;
}

.item-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(201, 168, 76, 0.16), rgba(255, 255, 255, 0.92));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.smart-grid-dock {
    margin: 0 -18px;
    padding: 14px 18px calc(18px + env(safe-area-inset-bottom, 0px));
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(244, 238, 228, 0.96));
    border-top: 1px solid rgba(201, 168, 76, 0.2);
    box-shadow: 0 -18px 40px rgba(82, 61, 33, 0.08);
}

.smart-grid-header {
    margin-bottom: 10px;
    font-size: 0.74rem;
    letter-spacing: 1px;
}

.sticker-search-wrapper {
    margin-bottom: 10px;
}

.sticker-search-input {
    padding: 11px 14px 11px 38px;
    border-radius: 14px;
    border: 1px solid rgba(201, 168, 76, 0.16);
    background: rgba(255, 255, 255, 0.86);
}

.sticker-item {
    min-width: 72px;
    height: 72px;
    border-radius: 18px;
    border: 1px solid rgba(201, 168, 76, 0.15);
    box-shadow: 0 10px 18px rgba(82, 61, 33, 0.06);
}

.sticker-emoji {
    font-size: 1.5rem;
    margin-bottom: 3px;
}

.sticker-name {
    font-size: 0.68rem;
}

.empty-state {
    border-radius: 24px;
    border: 1px dashed rgba(201, 168, 76, 0.22);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(248, 243, 235, 0.78));
}

@media (max-width: 420px) {
    .app-container {
        border-radius: 0;
    }

    .dashboard-shell {
        padding: 14px 14px 0;
    }

    .dash-hero {
        padding: 12px;
    }

    .header-row {
        gap: 8px;
    }

    .custom-family-selector {
        min-height: 56px;
        padding: 10px 12px;
    }

    .budget-display {
        min-width: 102px;
        padding: 9px 10px;
    }

    .budget-amount {
        font-size: 1.12rem;
    }

    .header-actions {
        gap: 4px;
        padding: 4px;
    }

    .header-icon-btn {
        width: 30px;
        height: 30px;
        font-size: 0.86rem;
    }

    .shopping-panel {
        padding: 12px 12px 16px;
    }

    .smart-grid-dock {
        margin: 0 -14px;
        padding: 12px 14px calc(16px + env(safe-area-inset-bottom, 0px));
    }
}

/* =========================================
   CONFIRM MODAL (replaces native confirm())
   ========================================= */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.confirm-overlay.show { opacity: 1; }
.confirm-modal {
    background: var(--card-bg, #fff);
    border-radius: 16px;
    padding: 24px;
    max-width: 340px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.confirm-message {
    font-size: 1rem;
    color: var(--text-main, #1a1a2e);
    margin: 0 0 20px;
    line-height: 1.5;
}
.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.confirm-btn {
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.2s;
}
.confirm-cancel {
    background: var(--bg-secondary, #f0f0f0);
    color: var(--text-muted, #666);
}
.confirm-ok {
    background: #ef4444;
    color: #fff;
}
.confirm-ok:hover { background: #dc2626; }

/* =========================================
   ONBOARDING TUTORIAL
   ========================================= */

.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 7500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: onboardingFadeIn 0.4s var(--ease-smooth);
}

@keyframes onboardingFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.onboarding-container {
    width: 100%;
    max-width: 400px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg), 0 0 60px rgba(201, 168, 76, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: onboardingSlideUp 0.5s var(--ease-spring);
}

@keyframes onboardingSlideUp {
    from { opacity: 0; transform: translateY(40px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.onboarding-slides {
    width: 100%;
    display: flex;
    overflow: hidden;
    min-height: 280px;
    transition: transform 0.35s var(--ease-smooth);
    will-change: transform;
    touch-action: pan-y;
}

.onboarding-slide {
    width: 100%;
    min-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 30px 25px;
    text-align: center;
    box-sizing: border-box;
}

.slide-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-main), var(--gold-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #fff;
    margin-bottom: 24px;
    box-shadow: 0 8px 30px var(--gold-glow);
    animation: slideIconPulse 2s ease-in-out infinite;
}

.slide-icon-premium {
    background: linear-gradient(135deg, #D4AF37, #f5d76e, #D4AF37);
    background-size: 200% 200%;
    animation: slideIconPulse 2s ease-in-out infinite, premiumShimmer 3s ease infinite;
}

@keyframes slideIconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

@keyframes premiumShimmer {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.slide-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 10px;
    letter-spacing: -0.3px;
    visibility: visible;
    opacity: 1;
}

.slide-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
    max-width: 300px;
    visibility: visible;
    opacity: 1;
}

.onboarding-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 8px 0 20px;
}

.onboarding-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-faint);
    transition: all 0.3s var(--ease-smooth);
    cursor: pointer;
}

.onboarding-dot.active {
    width: 24px;
    border-radius: var(--radius-pill);
    background: var(--gold-main);
    box-shadow: 0 2px 8px var(--gold-glow);
}

.onboarding-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px 24px;
}

.onboarding-skip {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    transition: all 0.2s var(--ease-smooth);
}

.onboarding-skip:hover {
    color: var(--text-dark);
    background: rgba(0, 0, 0, 0.04);
}

.onboarding-next {
    padding: 12px 32px !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    border-radius: var(--radius-pill) !important;
    min-width: 120px;
}

/* RTL support for onboarding */
html[dir="rtl"] .onboarding-slide {
    direction: rtl;
}

html[dir="rtl"] .onboarding-slides {
    flex-direction: row-reverse;
}

html[dir="rtl"] .onboarding-actions {
    flex-direction: row-reverse;
}

/* =========================================
   SAVINGS TRACKER — "Hai Risparmiato"
   ========================================= */

/* Analytics stat card — savings colors */
.stat-savings-positive { color: #22c55e !important; }
.stat-savings-negative { color: #ef4444 !important; }

.stat-card-savings-positive {
    border-color: rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.06);
}
.stat-card-savings-negative {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.06);
}

/* Savings stat spans full width (5th card) */
#statSavingsCard {
    grid-column: 1 / -1;
}

.savings-message {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

/* Piggy bank pulse animation when savings > 0 */
.stat-card-savings-positive .stat-value::before {
    content: '\1F437 ';
    display: inline;
    animation: piggyPulse 2s ease-in-out infinite;
}

@keyframes piggyPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.15); }
}

.stat-card-savings-positive .stat-value {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Dashboard savings badge (under budget) */
.dash-savings-badge {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 2px;
    letter-spacing: 0.3px;
}

.dash-savings-positive {
    color: #22c55e;
}

.dash-savings-negative {
    color: #ef4444;
}

/* Savings Tracker — new savings-card style (green accent) */
.savings-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.05));
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.savings-card .stat-value {
    color: #10b981;
}
.savings-card .stat-icon {
    color: #10b981;
}

.app-meta-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 18px 20px 26px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.app-meta-footer a {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
}

.app-meta-footer a:hover {
    color: var(--gold-main);
}

/* =========================================
   SETTINGS SHEET
   ========================================= */
body.settings-open {
    overflow: hidden;
}

.header-icon-btn.header-icon-settings {
    color: #6f5430;
    background: linear-gradient(135deg, rgba(255, 248, 232, 0.96), rgba(245, 236, 214, 0.92));
    border: 1px solid rgba(201, 168, 76, 0.2);
    box-shadow: 0 10px 20px rgba(87, 63, 29, 0.12);
}

.header-icon-btn.header-icon-settings:hover {
    background: linear-gradient(135deg, rgba(255, 248, 232, 1), rgba(241, 229, 198, 0.98));
}

.settings-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.42);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
    z-index: 1498;
}

.settings-sheet-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.settings-sheet {
    position: fixed;
    top: 18px;
    right: 18px;
    width: min(430px, calc(100vw - 24px));
    max-height: calc(100vh - 36px);
    display: flex;
    flex-direction: column;
    border-radius: 30px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(249, 245, 237, 0.95));
    border: 1px solid rgba(201, 168, 76, 0.18);
    box-shadow: 0 28px 60px rgba(34, 24, 13, 0.22);
    transform: translate3d(0, 16px, 0) scale(0.98);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.26s ease, opacity 0.24s ease;
    overflow: hidden;
    z-index: 1499;
}

.settings-sheet.open {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.settings-sheet-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 22px 14px;
    background:
        radial-gradient(circle at top right, rgba(212, 175, 55, 0.18), transparent 38%),
        linear-gradient(180deg, rgba(255, 250, 239, 0.98), rgba(255, 255, 255, 0.7));
    border-bottom: 1px solid rgba(201, 168, 76, 0.14);
}

.settings-sheet-kicker {
    margin: 0 0 6px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gold-main);
}

.settings-sheet-title {
    margin: 0;
    font-size: 1.2rem;
    line-height: 1.2;
    color: var(--text-dark);
}

.settings-sheet-subtitle {
    margin: 8px 0 0;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.settings-sheet-close {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: none;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.74);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(201, 168, 76, 0.12);
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.settings-sheet-close:hover {
    background: rgba(255, 247, 228, 0.98);
    color: var(--gold-main);
    transform: translateY(-1px);
}

.settings-sheet-body {
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-section-label {
    padding: 0 4px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.settings-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 15px;
    border: 1px solid rgba(222, 211, 191, 0.92);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.8);
    color: inherit;
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.settings-row:hover {
    transform: translateY(-1px);
    border-color: rgba(201, 168, 76, 0.34);
    background: rgba(255, 250, 240, 0.98);
    box-shadow: 0 12px 24px rgba(72, 54, 29, 0.08);
}

.settings-row-highlighted {
    border-color: rgba(212, 175, 55, 0.34);
    background:
        linear-gradient(135deg, rgba(255, 249, 226, 0.98), rgba(255, 255, 255, 0.92));
}

.settings-row-muted .settings-row-subtitle {
    color: var(--text-faint);
}

.settings-row-danger {
    background: rgba(255, 251, 251, 0.95);
}

.settings-row-danger .settings-row-icon {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

.settings-row-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 15px;
    background: rgba(201, 168, 76, 0.12);
    color: #7a5b2b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.settings-row-icon-gold {
    background: linear-gradient(135deg, rgba(244, 219, 131, 0.32), rgba(212, 175, 55, 0.18));
    color: var(--gold-main);
}

.settings-row-copy {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-row-title {
    display: block;
    font-weight: 700;
    color: var(--text-dark);
}

.settings-row-subtitle {
    display: block;
    font-size: 0.84rem;
    line-height: 1.4;
    color: var(--text-muted);
}

.settings-row-chevron {
    color: var(--text-faint);
    flex-shrink: 0;
}

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

.settings-lang-option {
    border: 1px solid rgba(222, 211, 191, 0.92);
    border-radius: 18px;
    padding: 12px 10px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-dark);
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.settings-lang-option:hover {
    transform: translateY(-1px);
    border-color: rgba(201, 168, 76, 0.34);
    background: rgba(255, 250, 240, 0.98);
}

.settings-lang-option.active {
    border-color: rgba(212, 175, 55, 0.45);
    background: linear-gradient(135deg, rgba(255, 248, 232, 1), rgba(247, 238, 213, 0.98));
    box-shadow: 0 12px 26px rgba(201, 168, 76, 0.14);
}

@media (max-width: 768px) {
    .settings-sheet {
        top: auto;
        right: 10px;
        bottom: 10px;
        left: 10px;
        width: auto;
        max-height: min(82vh, 760px);
        border-radius: 26px;
        transform: translate3d(0, 28px, 0);
    }

    .settings-sheet-header {
        padding: 18px 18px 12px;
    }

    .settings-sheet-body {
        padding: 14px;
        gap: 14px;
    }
}

@media (max-width: 430px) {
    .settings-sheet {
        left: 0;
        right: 0;
        bottom: 0;
        max-height: min(88vh, 760px);
        border-radius: 24px 24px 0 0;
    }

    .settings-sheet-header {
        position: sticky;
        top: 0;
        z-index: 1;
        padding-top: 16px;
    }

    .settings-sheet-header::before {
        content: "";
        position: absolute;
        top: 8px;
        left: 50%;
        width: 52px;
        height: 5px;
        border-radius: 999px;
        background: rgba(168, 135, 52, 0.24);
        transform: translateX(-50%);
    }

    .settings-sheet-kicker {
        margin-top: 8px;
    }

    .settings-row {
        padding: 13px;
        border-radius: 18px;
    }

    .settings-row-icon {
        width: 40px;
        height: 40px;
        border-radius: 14px;
    }

    .settings-language-grid {
        gap: 8px;
    }

    .settings-lang-option {
        padding: 10px 8px;
        font-size: 0.82rem;
        gap: 6px;
    }
}

html[dir="rtl"] .settings-sheet {
    right: auto;
    left: 18px;
}

html[dir="rtl"] .settings-sheet-header,
html[dir="rtl"] .settings-row {
    direction: rtl;
}

html[dir="rtl"] .settings-row-copy {
    text-align: right;
}

html[dir="rtl"] .settings-row-chevron {
    transform: scaleX(-1);
}

@media (max-width: 768px) {
    html[dir="rtl"] .settings-sheet {
        left: 10px;
        right: 10px;
    }
}

@media (max-width: 430px) {
    html[dir="rtl"] .settings-sheet {
        left: 0;
        right: 0;
    }
}

/* =========================================
   LEGAL / SUPPORT PAGES
   ========================================= */
.legal-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(212, 175, 55, 0.16), transparent 34%),
        linear-gradient(180deg, #f8f5ec 0%, #f4efe5 100%);
    color: var(--text-dark);
}

.legal-shell {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 20px 48px;
}

.legal-hero {
    padding: 12px 0 8px;
}

.legal-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 700;
    margin-bottom: 18px;
}

.legal-back-link:hover {
    color: var(--gold-main);
}

.legal-kicker {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(212, 175, 55, 0.14);
    color: var(--gold-dark);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.legal-title {
    margin: 18px 0 12px;
    font-family: 'Playfair Display', serif;
    font-size: clamp(2rem, 6vw, 3.3rem);
    line-height: 1.05;
    letter-spacing: -0.03em;
}

.legal-lead {
    max-width: 700px;
    margin: 0;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.7;
}

.legal-card {
    margin-top: 18px;
    padding: 22px 22px 24px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(201, 168, 76, 0.12);
    border-radius: 22px;
    box-shadow: 0 18px 40px rgba(95, 72, 35, 0.08);
}

.legal-card h2 {
    margin: 0 0 12px;
    font-size: 1.02rem;
    font-weight: 800;
}

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

.legal-copy {
    margin: 0;
    line-height: 1.7;
    color: var(--text-dark);
}

.legal-copy + .legal-copy {
    margin-top: 10px;
}

.legal-copy-muted {
    color: var(--text-muted);
}

.legal-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text-dark);
    line-height: 1.75;
}

.legal-list li + li {
    margin-top: 8px;
}

.legal-card a,
.legal-footer a {
    color: var(--gold-dark);
    font-weight: 700;
}

.legal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding: 8px 2px 0;
    color: var(--text-muted);
    font-size: 0.84rem;
}

@media (max-width: 720px) {
    .legal-grid {
        grid-template-columns: 1fr;
    }

    .legal-footer {
        flex-direction: column;
        align-items: flex-start;
    }
}
