/* --- CSS VARIABLES --- */
:root {
    --primary: #6C63FF;
    --secondary: #00b894;
    --danger: #ff7675;
    --info: #0984e3;
    --bg: #dfe6e9;
    --card-bg: #ffffff;
    --text: #2d3436;
    --gray: #636e72;
    --input-bg: #f1f2f6;

    /* Variável para contraste do texto em fundos coloridos */
    --text-on-primary: #ffffff;

    --radius: 24px;
    --shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    --safe-bottom: env(safe-area-inset-bottom, 20px);
    --safe-top: env(safe-area-inset-top, 20px);
}

body.dark-mode {
    --bg: #1e1e1e;
    --card-bg: #2d2d2d;
    --text: #f5f5f5;
    --gray: #b2bec3;
    --input-bg: #3d3d3d;
    --shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* CORREÇÃO: Borda de Resgate para Tema Dark Premium no Modo Escuro */
body.dark-mode.theme-is-dark .balance-card,
body.dark-mode.theme-is-dark .type-selector.ts-compact .type-btn.selected,
body.dark-mode.theme-is-dark .btn-primary {
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

body.privacy-active .blur-target {
    filter: blur(6px);
    user-select: none;
}

/* SCROLL LOCK CLASS */
body.no-scroll {
    overflow: hidden;
    height: 100vh;
    position: fixed;
    width: 100%;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: calc(130px + var(--safe-bottom));
    user-select: none;
    overflow-x: hidden;
    overscroll-behavior: none;
    /* Previne efeito elástico indesejado */
    transition: background 0.3s, color 0.3s;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    padding-top: calc(10px + var(--safe-top));
}

/* ANIMATIONS */
@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0
    }

    to {
        transform: translateY(0);
        opacity: 1
    }
}

@keyframes slideUpDrawer {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes pop {
    0% {
        transform: scale(0.95)
    }

    100% {
        transform: scale(1)
    }
}

@keyframes fillBar {
    from {
        width: 0;
    }
}

@keyframes rotateBorder {
    100% {
        transform: rotate(360deg);
    }
}

.tapping {
    animation: pop 0.1s ease-out;
}

.slide-in-fast {
    animation: slideUp 0.3s ease-out backwards;
}

/* UX IMPROVEMENT: FORM ANIMATION */
#tx-form-body {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards;
    animation-delay: 0.1s;
}

/* --- TYPE SELECTOR STYLES (NEON & MORPHING) --- */
.type-selector {
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Cores Neon & Bordas */
.type-btn.t-inc {
    color: #00e676;
    border: 1px solid #00e676;
}

.type-btn.t-exp {
    color: #ff1744;
    border: 1px solid #ff1744;
}

.type-btn.t-crd {
    color: #2979ff;
    border: 1px solid #2979ff;
}

.type-btn.t-inv {
    color: #ffab00;
    border: 1px solid #ffab00;
}

.type-btn i {
    font-size: 1.2rem;
}

/* Estado Hero (Centro) */
.type-selector.ts-hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    padding-top: 15vh;
    padding-bottom: 5vh;
}

.type-selector.ts-hero .type-btn {
    padding: 25px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    cursor: pointer;
}

/* Glow Effects Hero */
.type-selector.ts-hero .type-btn.t-inc {
    box-shadow: 0 0 20px rgba(0, 230, 118, 0.2);
}

.type-selector.ts-hero .type-btn.t-exp {
    box-shadow: 0 0 20px rgba(255, 23, 68, 0.2);
}

.type-selector.ts-hero .type-btn.t-crd {
    box-shadow: 0 0 20px rgba(41, 121, 255, 0.2);
}

.type-selector.ts-hero .type-btn.t-inv {
    box-shadow: 0 0 20px rgba(255, 171, 0, 0.2);
}

.type-selector.ts-hero .type-btn i {
    font-size: 2.2rem;
    margin-bottom: 5px;
}

/* Estado Compacto (Topo) */
.type-selector.ts-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 15px;
}

.type-selector.ts-compact .type-btn {
    transition: all 0.4s ease;
    order: 2;
    flex: 1;
    padding: 10px;
    font-size: 0.8rem;
    opacity: 0.6;
    transform: scale(0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    border-radius: 12px;
}

.type-selector.ts-compact .type-btn i {
    font-size: 1rem;
    margin: 0;
}

/* Selected State in Compact */
.type-selector.ts-compact .type-btn.selected {
    order: 1;
    flex: 0 0 100%;
    padding: 15px;
    font-size: 1rem;
    opacity: 1;
    transform: scale(1);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Background fills on selection */
.type-selector.ts-compact .type-btn.selected.t-inc {
    background: #00e676;
    border-color: #00e676;
}

.type-selector.ts-compact .type-btn.selected.t-exp {
    background: #ff1744;
    border-color: #ff1744;
}

.type-selector.ts-compact .type-btn.selected.t-crd {
    background: #2979ff;
    border-color: #2979ff;
}

.type-selector.ts-compact .type-btn.selected.t-inv {
    background: #ffab00;
    border-color: #ffab00;
}


/* DIAMOND ICON ANIMATIONS */
@keyframes spinIntro {
    0% {
        transform: rotate(-360deg) scale(0);
        opacity: 0;
    }

    60% {
        transform: rotate(10deg) scale(1.1);
        opacity: 1;
    }

    100% {
        transform: rotate(0deg) scale(1);
    }
}

@keyframes sparkleStar {

    0%,
    85% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }

    90% {
        opacity: 1;
        transform: scale(1.2) rotate(45deg);
    }

    100% {
        opacity: 0;
        transform: scale(0) rotate(90deg);
    }
}

/* TOAST NOTIFICATION & UNDO */
#toast-container {
    position: fixed;
    top: calc(10px + var(--safe-top));
    left: 0;
    width: 100%;
    height: 0;
    overflow: visible;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.toast-pill {
    background: var(--text);
    color: var(--card-bg);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    width: fit-content;
    max-width: 90vw;
    pointer-events: auto;
    animation: toastSlideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: all 0.3s ease;
}

@keyframes toastSlideIn {
    from {
        transform: translateY(-20px) scale(0.9);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.toast-pill.hiding {
    animation: toastFadeOut 0.3s forwards;
}

@keyframes toastFadeOut {
    to {
        opacity: 0;
        transform: scale(0.9) translateY(-10px);
    }
}

.undo-btn {
    background: var(--card-bg);
    color: var(--text);
    border: none;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
}

.t-success .toast-pill {
    background: var(--secondary);
    color: white;
}

.t-info .toast-pill {
    background: var(--text);
    color: var(--card-bg);
}

.t-warn .toast-pill {
    background: #fdcb6e;
    color: #2d3436;
}

.t-sync .toast-pill {
    background: var(--info);
    color: white;
}

/* TIMELINE HEADERS */
.date-header {
    padding: 15px 5px 5px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gray);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 10px;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.day-total {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.8;
}

/* RANKING ACCORDION */
#ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--input-bg);
    padding: 12px 18px;
    border-radius: 16px;
    margin-bottom: 20px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text);
    transition: 0.2s;
}

#ranking-header:active {
    transform: scale(0.98);
}

.accordion-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-wrapper.open {
    grid-template-rows: 1fr;
    margin-bottom: 15px;
}

.accordion-inner {
    overflow: hidden;
}

#ranking-arrow {
    transition: transform 0.4s ease;
}

#ranking-arrow.rotated {
    transform: rotate(180deg);
}

.ranking-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px dashed var(--input-bg);
    font-size: 0.85rem;
    cursor: pointer;
    transition: opacity 0.3s;
}

.ranking-row:active {
    transform: scale(0.98);
}

.ranking-row.dimmed {
    opacity: 0.3;
    filter: grayscale(0.5);
}

.rank-bar-bg {
    height: 6px;
    background: var(--input-bg);
    border-radius: 3px;
    margin-top: 5px;
    overflow: hidden;
    width: 100%;
}

.rank-bar-fill {
    height: 100%;
    border-radius: 3px;
    animation: fillBar 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    width: 0;
}

.rank-color-0 {
    background: #6C63FF;
}

.rank-color-1 {
    background: #0984e3;
}

.rank-color-2 {
    background: #00b894;
}

.rank-color-3 {
    background: #fdcb6e;
}

.rank-color-4 {
    background: #ff7675;
}

/* HEADER & DIAMOND ICON */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 5px;
}

.app-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.title-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.diamond-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-right: 0;
    filter: drop-shadow(0 3px 0px rgba(108, 99, 255, 0.3));
    transition: transform 0.1s, filter 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.diamond-wrapper:active {
    transform: translateY(3px);
    filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0));
}

.diamond-icon {
    font-size: 1.4rem;
    color: var(--primary);
    animation: spinIntro 1s ease-out backwards;
    will-change: transform;
}

.diamond-wrapper::after {
    content: '';
    position: absolute;
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    background: white;
    clip-path: polygon(50% 0%, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0% 50%, 40% 40%);
    opacity: 0;
    pointer-events: none;
    animation: sparkleStar 5s infinite ease-in-out;
    z-index: 2;
}

.version-tag {
    font-size: 0.6rem;
    background: var(--primary);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    position: relative;
    background: var(--card-bg);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: var(--gray);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: 0.2s;
}

.sync-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    border: none;
    transition: background 0.3s, transform 0.3s;
}

.sync-dot.online {
    background: var(--secondary);
    box-shadow: 0 0 5px var(--secondary);
}

.sync-dot.offline {
    background: var(--danger);
}

.lock-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--card-bg);
    color: var(--text);
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

#install-btn {
    display: none;
    background: var(--primary);
    color: white;
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(108, 99, 255, 0.3);
    animation: pop 0.5s;
}

/* DASHBOARD */
.balance-card {
    background: linear-gradient(135deg, var(--primary), rgba(0, 0, 0, 0.2));
    background-color: var(--primary);
    color: var(--text-on-primary);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: 0 15px 35px rgba(108, 99, 255, 0.25);
    margin-bottom: 20px;
    animation: pop 0.5s ease-out;
    position: relative;
}

.balance-label {
    font-size: 0.8rem;
    opacity: 0.9;
}

.balance-value {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 15px;
    letter-spacing: -1px;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.summary-item {
    position: relative;
    padding: 12px;
    border-radius: 15px;
    text-align: center;
    overflow: hidden;
    z-index: 0;
    background: var(--card-bg);
}

.summary-item::before {
    content: '';
    position: absolute;
    z-index: -2;
    left: -50%;
    top: -50%;
    width: 200%;
    height: 200%;
    background-image: conic-gradient(transparent, var(--neon-color), transparent 30%);
    animation: rotateBorder 4s linear infinite;
}

.summary-item::after {
    content: '';
    position: absolute;
    z-index: -1;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    background: var(--card-bg);
    border-radius: 11px;
}

.neon-green {
    --neon-color: #00b894;
    color: var(--text);
}

.neon-green .s-val {
    color: #00b894;
}

.neon-red {
    --neon-color: #ff7675;
    color: var(--text);
}

.neon-red .s-val {
    color: #ff7675;
}

.neon-blue {
    --neon-color: #0984e3;
    color: var(--text);
}

.neon-blue .s-val {
    color: #0984e3;
}

.s-label {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-bottom: 2px;
    position: relative;
    z-index: 2;
}

.s-val {
    font-weight: 700;
    font-size: 0.95rem;
    position: relative;
    z-index: 2;
}

/* COMPONENTS & CARDS */
.report-header {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.report-header.grid-2x2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.report-card {
    flex: 1;
    padding: 15px;
    border-radius: 16px;
    background: var(--input-bg);
    text-align: center;
}

.rc-label {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-bottom: 5px;
}

.rc-val {
    font-size: 0.9rem;
    font-weight: 700;
}

.section-header {
    margin: 20px 0 10px 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray);
    opacity: 0.3;
}

.tabs {
    display: flex;
    background: var(--card-bg);
    padding: 5px;
    border-radius: 18px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    font-weight: 600;
    color: var(--gray);
    cursor: pointer;
    border-radius: 14px;
    font-size: 0.9rem;
    transition: 0.3s;
}

.tab.active {
    color: var(--primary);
    background: rgba(108, 99, 255, 0.1);
}

.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    background: var(--card-bg);
    padding: 10px 15px;
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.date-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: center;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 5px;
}

.current-date {
    font-weight: 700;
    color: var(--text);
    font-size: 0.9rem;
    min-width: 120px;
    text-align: center;
    cursor: pointer;
    border-bottom: 1px dashed var(--gray);
}

.tool-btn {
    background: rgba(108, 99, 255, 0.1);
    border: none;
    color: var(--primary);
    width: 35px;
    height: 35px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}

.search-toggle {
    background: rgba(108, 99, 255, 0.1);
    border: none;
    color: var(--primary);
    width: 35px;
    height: 35px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
}

.search-box {
    margin-bottom: 15px;
    animation: slideUp 0.2s;
}

.search-input {
    width: 100%;
    padding: 12px 15px;
    border-radius: 15px;
    border: 2px solid var(--primary);
    background: var(--card-bg);
    color: var(--text);
    font-size: 0.9rem;
}

.list-scroller {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.list-chip {
    padding: 8px 15px;
    background: var(--input-bg);
    border-radius: 15px;
    white-space: nowrap;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    border: 1px solid transparent;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 2px solid transparent;
}

.list-chip.selected {
    background: var(--primary);
    color: white;
    font-weight: 700;
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(108, 99, 255, 0.4);
    transform: translateY(-2px) scale(1.02);
}

.list-chip:active {
    transform: scale(0.95);
}

.pantry-toggle {
    width: 100%;
    padding: 10px;
    background: var(--input-bg);
    border-radius: 15px;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    border: 1px dashed var(--primary);
}

.item-card {
    background: var(--card-bg);
    border-radius: 18px;
    margin-bottom: 12px;
    display: flex;
    padding: 0;
    box-shadow: var(--shadow);
    animation: slideUp 0.3s ease-out backwards;
    position: relative;
    overflow: hidden;
    min-height: 75px;
    transition: transform 0.3s;
}

.item-body {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    cursor: default;
    overflow: hidden;
    user-select: none;
    height: 100%;
    transition: 0.2s;
}

.item-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.item-icon:active {
    transform: scale(0.9);
}

.item-desc {
    flex: 1;
    min-width: 0;
}

.item-desc h4 {
    font-size: 0.95rem;
    margin-bottom: 2px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-desc small {
    font-size: 0.75rem;
    color: var(--gray);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
}

.cat-tag {
    font-size: 0.65rem;
    background: var(--input-bg);
    color: var(--gray);
    padding: 2px 6px;
    border-radius: 6px;
    margin-left: 0;
}

.installment-badge {
    font-size: 0.6rem;
    background: #b2bec3;
    color: white;
    padding: 1px 5px;
    border-radius: 4px;
}

.item-actions-area {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    padding: 10px 15px;
    gap: 5px;
    min-width: fit-content;
}

.amount-display {
    margin-bottom: 2px;
}

.item-amount {
    font-weight: 700;
    font-size: 0.9rem;
    display: block;
    text-align: right;
    white-space: nowrap;
}

.item-btns-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #b2bec3;
    background: transparent;
    cursor: pointer;
    transition: 0.2s;
    position: relative;
    flex-shrink: 0;
}

.status-dot.paid {
    background: var(--secondary);
    border-color: var(--secondary);
    box-shadow: 0 0 5px rgba(0, 184, 148, 0.4);
}

.status-dot.paid::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: white;
    font-size: 10px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.btn-quick-del {
    background: none;
    border: none;
    color: var(--gray);
    font-size: 1rem;
    padding: 5px;
    cursor: pointer;
    transition: 0.2s;
    flex-shrink: 0;
}

.btn-quick-del:active {
    transform: scale(0.9);
}

.btn-quick-del:hover {
    color: var(--danger);
    transform: scale(1.1);
}

.qty-ctrl {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-qty {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: var(--input-bg);
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
}

.fab {
    position: fixed;
    bottom: calc(30px + var(--safe-bottom));
    left: 50%;
    transform: translate(-50%, 0);
    width: 60px;
    height: 60px;
    background: var(--text);
    color: var(--card-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    cursor: grab;
    z-index: 1000;
    touch-action: none;
    user-select: none;
}

.fab:active {
    cursor: grabbing;
    transform: scale(0.95);
}

/* CHECKOUT BAR - RESTORED BASE VISUALS (Fixed Z-Index) */
#checkout-bar {
    position: fixed;
    bottom: calc(80px + var(--safe-bottom));
    left: 50%;
    width: 95%;
    max-width: 480px;
    background: var(--text);
    color: var(--card-bg);
    padding: 12px 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(30px) scale(0.5);
    transform-origin: center bottom;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#checkout-bar.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0) scale(1);
}

.cart-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cart-main {
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-sub-text {
    font-size: 0.7rem;
    opacity: 0.7;
}

.cart-disc-text {
    font-size: 0.75rem;
    color: var(--secondary);
    font-weight: 600;
}

/* RESTORED: Checkout Button (Simple & Clean) */
.btn-checkout {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 12px 18px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* NEW STYLES FOR SHOPPING & RECEIPT (GOAL 1 & 2 & 3) */
.text-success {
    color: var(--secondary);
    font-weight: 600;
}

.amount-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
}

.amt-discount {
    font-size: 0.7rem;
    color: var(--secondary);
    margin-bottom: 2px;
}

.amt-final {
    font-size: 0.95rem;
    font-weight: 700;
}

.btn-receipt {
    background: rgba(108, 99, 255, 0.1);
    color: var(--primary);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 5px;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.btn-receipt:active {
    transform: scale(0.9);
    background: rgba(108, 99, 255, 0.3);
}

.receipt-text {
    font-family: 'Courier New', Courier, monospace;
    white-space: pre-wrap;
    background: var(--input-bg);
    padding: 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--text);
    border: 1px dashed var(--gray);
    max-height: 300px;
    overflow-y: auto;
}

/* MODAL OVERLAY - Z-Index 2000 (Standard) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: 0.3s;
}

.modal-overlay.open {
    display: flex;
    opacity: 1;
}

.modal-bottom {
    margin-top: auto;
    width: 100%;
    height: 92vh;
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
    padding: 25px;
    padding-bottom: calc(25px + var(--safe-bottom));
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    color: var(--text);
}

.modal-overlay.open .modal-bottom {
    transform: translateY(0);
}

.modal-center {
    margin: auto;
    width: 90%;
    max-width: 400px;
    background: var(--card-bg);
    border-radius: 20px;
    padding: 20px;
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    color: var(--text);
}

.modal-overlay.open .modal-center {
    transform: scale(1);
}

/* LOCK SCREEN - Z-Index 99999 (Supreme) */
#lock-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 99999;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}

#lock-screen.visible {
    display: flex;
}

.lock-logo {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 20px;
    animation: pop 0.5s;
}

.pin-display {
    display: flex;
    gap: 15px;
    margin-bottom: 40px;
}

.pin-dot {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid var(--text);
    transition: 0.2s;
}

.pin-dot.filled {
    background: var(--text);
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 80%;
    max-width: 300px;
}

.num-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--card-bg);
    border: none;
    font-size: 1.5rem;
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.num-btn:active {
    background: var(--input-bg);
    transform: scale(0.95);
}

#challenge-container {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 80%;
    text-align: center;
    animation: slideUp 0.3s;
}

.challenge-text {
    margin-bottom: 20px;
    font-weight: 600;
    color: var(--danger);
}

/* DIALOG MODAL STYLES */
.dialog-btn {
    padding: 12px 15px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
    font-size: 0.9rem;
    transition: 0.2s;
}

.dialog-btn:active {
    transform: scale(0.95);
}

.d-btn-primary {
    background: var(--text);
    color: var(--card-bg);
}

.d-btn-danger {
    background: rgba(255, 118, 117, 0.15);
    color: var(--danger);
}

.d-btn-ghost {
    background: transparent;
    color: var(--gray);
}

/* SETTINGS & SYNC STYLES */
#sync-section {
    border-top: 1px solid var(--gray);
    margin-top: 15px;
    padding-top: 15px;
    animation: slideUp 0.3s;
}

.qr-container {
    background: white;
    padding: 15px;
    border-radius: 15px;
    display: inline-block;
    margin: 15px 0;
}

.backup-code-box {
    background: var(--bg);
    padding: 15px;
    border-radius: 12px;
    font-family: monospace;
    word-break: break-all;
    margin-bottom: 10px;
    font-size: 0.8rem;
    border: 1px dashed var(--gray);
    color: var(--text);
}

.btn-copy {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
}

.status-tag {
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: auto;
}

.st-ok {
    background: rgba(0, 184, 148, 0.2);
    color: var(--secondary);
}

.st-no {
    background: rgba(99, 110, 114, 0.2);
    color: var(--gray);
}

.settings-option {
    padding: 15px;
    border-radius: 16px;
    background: var(--input-bg);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
}

.settings-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.cat-scroller {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.cat-chip {
    padding: 10px 18px;
    background: var(--input-bg);
    border-radius: 20px;
    white-space: nowrap;
    cursor: pointer;
    font-size: 0.9rem;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
    color: var(--text);
    user-select: none;
}

.cat-chip.selected {
    background: var(--text);
    color: var(--card-bg);
    font-weight: 600;
}

input,
select {
    width: 100%;
    padding: 16px;
    background: var(--input-bg);
    border: none;
    border-radius: 14px;
    margin-bottom: 15px;
    font-size: 1rem;
    color: var(--text);
}

.row-inputs {
    display: flex;
    gap: 10px;
}

.type-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.type-btn {
    flex: 1;
    padding: 12px;
    border: 1px solid transparent;
    background: var(--input-bg);
    border-radius: 12px;
    font-weight: 600;
    color: var(--gray);
    cursor: pointer;
    font-size: 0.9rem;
    transition: 0.2s;
}

.t-inc.selected {
    background: rgba(0, 184, 148, 0.15);
    color: var(--secondary);
    border-color: var(--secondary);
}

.t-exp.selected {
    background: rgba(255, 118, 117, 0.15);
    color: var(--danger);
    border-color: var(--danger);
}

.t-crd.selected {
    background: rgba(9, 132, 227, 0.15);
    color: var(--info);
    border-color: var(--info);
}

.btn-primary {
    width: 100%;
    padding: 18px;
    background: var(--text);
    color: var(--card-bg);
    border: none;
    border-radius: 14px;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: 0.3s;
}

.hidden {
    display: none !important;
}

/* IMPORTANT ADDED HERE */
#success-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--card-bg);
    opacity: 0.95;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 20px 20px 0 0;
    z-index: 10;
}

.success-icon {
    font-size: 4rem;
    color: var(--secondary);
    animation: checkmark 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-text {
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 15px;
    color: var(--text);
    animation: fadeIn 0.5s;
}

.date-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.month-btn {
    padding: 10px;
    background: var(--input-bg);
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text);
}

.month-btn.selected {
    background: var(--primary);
    color: white;
}

.year-selector {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 1.2rem;
    font-weight: 700;
}

.filter-section {
    margin-bottom: 15px;
}

.filter-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gray);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--gray);
    background: var(--card-bg);
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.2s;
    flex: 1;
    text-align: center;
    white-space: nowrap;
}

.filter-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(108, 99, 255, 0.3);
}

.filter-chip:active {
    transform: scale(0.95);
}

/* CALC MODAL - Z-Index 6000 (Above standard Modals) */
.calc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 6000;
    display: none;
    flex-direction: column;
    justify-content: flex-end;
}

.calc-overlay.open {
    display: flex;
}

.calc-body {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 20px 20px 0 0;
    padding-bottom: calc(20px + var(--safe-bottom));
}

.calc-display {
    background: var(--input-bg);
    color: var(--text);
    font-size: 2rem;
    padding: 15px;
    text-align: right;
    border-radius: 12px;
    margin-bottom: 15px;
    font-weight: 700;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.calc-btn {
    padding: 20px;
    border-radius: 12px;
    border: none;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--input-bg);
    color: var(--text);
}

.calc-btn.op {
    background: rgba(108, 99, 255, 0.1);
    color: var(--primary);
}

.calc-btn.eq {
    background: var(--secondary);
    color: white;
    grid-column: span 2;
}

.calc-btn:active {
    opacity: 0.8;
}

/* IMPROVED PANTRY TOGGLE BUTTON */
#btn-pantry-toggle {
    border: 2px solid var(--primary) !important;
    /* Always colored border */
    background: rgba(108, 99, 255, 0.05);
    /* Slight tint */
    color: var(--primary);
    font-weight: 600;
    transition: all 0.2s ease;
}

#btn-pantry-toggle:active {
    transform: scale(0.95);
    background: var(--primary);
    color: white;
}

/* --- SHOPPING ADVANCED CALCULATOR STYLES --- */
#shoppingCalcModal .sc-display-area {
    background: var(--input-bg);
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
}

.sc-main-display {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    word-break: break-all;
    text-align: right;
}

.sc-preview-display {
    font-size: 1rem;
    color: var(--gray);
    margin-top: 5px;
    min-height: 1.2rem;
    font-weight: 500;
}

.sc-history-btn {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg);
    padding: 8px 20px;
    border-radius: 20px 20px 0 0;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    z-index: 5;
}

.sc-history-drawer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
    z-index: 10;
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.2);
    padding: 20px;
    transform: translateY(110%);
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    display: flex;
    flex-direction: column;
}

.sc-history-drawer.open {
    transform: translateY(0);
}

.sc-hist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--input-bg);
}

.sc-hist-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sc-hist-item {
    background: var(--input-bg);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.sc-hist-item:active {
    opacity: 0.7;
}

.sc-hist-eq {
    font-size: 0.75rem;
    color: var(--gray);
    margin-bottom: 2px;
}

.sc-hist-res {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

/* --- THEME PICKER --- */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    justify-content: center;
}

.theme-option {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border: 2px solid var(--card-bg);
}

.theme-option:active {
    transform: scale(0.9);
}

/* --- BIOMETRIC BUTTON --- */
.bio-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    background: transparent;
    color: var(--primary);
    font-size: 1.5rem;
    margin-top: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulseBio 2s infinite;
    transition: transform 0.2s;
}

.bio-btn:active {
    transform: scale(0.95);
    background: rgba(108, 99, 255, 0.1);
}

@keyframes pulseBio {
    0% {
        box-shadow: 0 0 0 0 rgba(108, 99, 255, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(108, 99, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(108, 99, 255, 0);
    }
}

/* --- SHOPPING INTELLIGENCE (NEW) --- */
.input-helper {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-top: -10px;
    margin-bottom: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    animation: slideUp 0.2s;
}

.btn-history {
    background: none;
    border: none;
    color: var(--info);
    font-size: 1rem;
    padding: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.history-modal-content {
    background: var(--input-bg);
    border-radius: 12px;
    padding: 10px;
    margin-top: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dashed var(--gray);
    font-size: 0.85rem;
}

.trend-up {
    color: var(--danger);
    font-weight: 700;
}

.trend-down {
    color: var(--secondary);
    font-weight: 700;
}

/* --- WALLET TAGS (NEW PHASE 3) --- */
.wallet-tag {
    position: absolute;
    top: 25px;
    right: 25px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: white;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: transform 0.2s;
    z-index: 5;
}

.wallet-tag:active {
    transform: scale(0.95);
}

/* Wallet Manager List */
.wallet-row {
    background: var(--input-bg);
    padding: 12px 15px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.wallet-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 10px;
    display: inline-block;
}

/* --- DRAG & DROP REORDERING (NEW) --- */
.drag-handle {
    cursor: grab;
    color: var(--gray);
    margin-right: 15px;
    display: flex;
    align-items: center;
    font-size: 1.2rem;
    padding: 5px;
    touch-action: none;
    /* Prevents scrolling while dragging */
}

/* Hide handle by default, show in reorder mode */
.drag-handle {
    display: none;
}

body.reorder-mode .drag-handle {
    display: flex;
    animation: pop 0.2s;
}

/* Disable item actions in reorder mode to prevent accidental clicks */
body.reorder-mode .item-body {
    pointer-events: none;
    opacity: 0.7;
}

body.reorder-mode .item-actions-area {
    pointer-events: none;
    opacity: 0.3;
}

body.reorder-mode .drag-handle {
    pointer-events: auto;
    opacity: 1;
    color: var(--primary);
}

/* Highlight the active sort button */
body.reorder-mode #btn-reorder {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

/* Visual feedback while dragging */
.item-card.dragging {
    opacity: 0.5;
    transform: scale(1.02);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    z-index: 100;
    position: relative;
}

/* --- PROFILE MANAGER STYLES (Fase 6) --- */
.profile-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.profile-item {
    background: var(--input-bg);
    padding: 15px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: transform 0.2s, border 0.2s;
    border: 2px solid transparent;
}

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

.profile-item.active-profile {
    border-color: var(--primary);
    background: rgba(108, 99, 255, 0.05);
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    touch-action: manipulation;
    /* Remove delay de 300ms no mobile */
    flex: 1;
    /* Garante que ocupe todo espaço disponível */
}

.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
    pointer-events: none;
    /* Deixa o clique passar direto para o pai (.profile-info) */
}

.profile-actions {
    display: flex;
    gap: 10px;
}

.btn-profile-action {
    background: none;
    border: none;
    color: var(--gray);
    cursor: pointer;
    padding: 5px;
}

/* --- PRINT STYLES (NEW PHASE 4) --- */
@media print {
    body * {
        visibility: hidden;
    }

    #printable-area,
    #printable-area * {
        visibility: visible;
    }

    #printable-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: white;
        color: black;
        font-family: 'Courier New', Courier, monospace;
        padding: 20px;
    }

    /* Reset colors for printing */
    :root {
        --bg: white;
        --text: black;
    }
}

/* --- DARK PREMIUM THEME FIXES --- */
/* Força a cor dos controles para Branco/Cinza Claro quando o tema é Dark Premium E o modo escuro está ativo */
body.dark-mode.theme-is-dark {
    --primary: #f5f5f5;
    /* Controles ficam brancos para contraste */
}

/* Mas o Card de Balanço e o Título mantêm a identidade Dark Premium */
body.dark-mode.theme-is-dark .balance-card {
    background: #2d3436 !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* O título ganha um contorno suave se necessário, ou fica na cor do tema (mas visível) */
body.dark-mode.theme-is-dark .app-title {
    color: #b2bec3;
    text-shadow: 0 0 1px #ffffff;
    /* Garante leitura no fundo preto */
}

/* CORREÇÃO CRÍTICA: Tag de versão legível no fundo branco */
body.dark-mode.theme-is-dark .version-tag {
    color: #2d3436;
    font-weight: 700;
}