body {
    background: #f5f7fb;
    color: #252a34;
}

.auth-page { min-height: calc(100vh - 120px); display: grid; place-items: center; padding: 2rem 0; }
.auth-card { width: min(100%, 440px); padding: 2.2rem; background: #fff; border-radius: 18px; box-shadow: 0 12px 35px #15223818; }
.auth-brand { display: flex; justify-content: center; margin-bottom: 1rem; padding: .7rem 1rem; border-radius: 12px; background: #1f2937; }
.auth-brand img { width: 205px; height: auto; }
.auth-tagline { margin-bottom: 1.8rem; color: #64748b; text-align: center; }
.auth-card h1 { margin-bottom: .5rem; color: #252a34; font-size: 1.7rem; text-align: center; }
.auth-subtitle { margin-bottom: 1.5rem; color: #64748b; text-align: center; }
.auth-form { display: grid; gap: 1rem; }
.auth-field label { display: block; margin-bottom: .4rem; color: #374151; font-weight: 600; }
.auth-field input { display: block; width: 100%; min-height: 46px; padding: .65rem .8rem; border: 1px solid #cbd5e1; border-radius: 8px; color: #1f2937; transition: border-color .15s, box-shadow .15s; }
.auth-field input:focus { border-color: #2563eb; outline: 0; box-shadow: 0 0 0 3px #2563eb22; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 3rem; }
.password-toggle { position: absolute; top: 50%; right: .55rem; border: 0; background: transparent; color: #64748b; transform: translateY(-50%); cursor: pointer; font-size: 1.1rem; }
.password-toggle:focus-visible { border-radius: 4px; outline: 2px solid #2563eb; }
.auth-submit { width: 100%; min-height: 46px; margin-top: .35rem; background: #2563eb; color: #fff; font-weight: 600; }
.auth-submit:hover, .auth-submit:focus-visible { background: #1d4ed8; color: #fff; }
.auth-footer { margin: 1.4rem 0 0; color: #64748b; text-align: center; }
.auth-footer a { color: #2563eb; font-weight: 600; text-decoration: none; }
.auth-alert, .auth-error { display: block; margin-top: .35rem; color: #b91c1c; font-size: .85rem; }
.auth-alert { margin-bottom: 1rem; padding: .7rem .8rem; border-radius: 8px; background: #fef2f2; }

.controlefin-brand img {
    display: block;
    width: 250px;
    height: auto;
}

.card {
    border: 0;
    box-shadow: 0 2px 12px #00000012;
}

.report-card {
    display: flex;
    flex-direction: column;
    transition: transform 0.15s, box-shadow 0.15s;
}

.report-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 22px #15223818;
}

.report-icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    background: #eff6ff;
    border-radius: 12px;
    color: #2563eb;
    font-size: 1.35rem;
}

.report-chart {
    position: relative;
    height: 280px;
}
.report-chart-svg { width: 100%; overflow-x: auto; }
.report-chart-svg svg { display: block; width: 100%; min-width: 620px; height: auto; }

/* Estruturas compartilhadas: evitam que textos longos e mídias ampliem a página. */
img, svg, canvas { max-width: 100%; }
.mobile-only { display: none; }

.site-navbar { padding: 0.8rem 0; }
.site-navbar .container { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.main-navigation { display: flex; align-items: center; gap: 1.25rem; margin-left: auto; }
.nav-links { display: flex; align-items: center; gap: 0.4rem; }
.nav-link-item { display: inline-flex; align-items: center; gap: 0.42rem; padding: 0.52rem 0.72rem; border: 1px solid #475569; border-radius: 7px; background: #252b33; color: #e2e8f0; font-size: 0.9rem; text-decoration: none; white-space: nowrap; transition: background .18s, border-color .18s, color .18s, transform .18s; }
.nav-link-item:hover, .nav-link-item:focus-visible { background: #343d49; border-color: #64748b; color: #fff; transform: translateY(-1px); }
.nav-link-item.active { background: #2563eb; border-color: #2563eb; color: #fff; font-weight: 600; }
.nav-logout { background: #fbbf24; border-color: #fbbf24; color: #1f2937; }
.nav-logout-form { margin: 0; }
.nav-logout:hover, .nav-logout:focus-visible { background: #f59e0b; border-color: #f59e0b; color: #111827; }
.nav-toggle { display: none; border: 1px solid #64748b; border-radius: 7px; background: #252b33; color: #fff; padding: .4rem .65rem; font-size: 1.3rem; line-height: 1; }
.nav-toggle:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }

.form-card {
    max-width: 620px;
    padding: 28px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 18px #1522380b;
}

.form-card input:not([type='radio']),
.form-card select {
    display: block;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
}

.type-options {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.type-option {
    padding: 12px 18px;
    background: #fff;
    border: 1px solid #d9dee8;
    border-radius: 10px;
    cursor: pointer;
}

.type-option:has(input:checked) {
    background: #eff6ff;
    border-color: #2563eb;
    color: #1d4ed8;
}

.type-option input {
    margin-right: 6px;
}

.transaction-mobile-list { display: none; }
.transaction-mobile-card { padding: 1rem 0; border-bottom: 1px solid #e7ebf0; }
.transaction-mobile-card:last-child { border-bottom: 0; padding-bottom: 0; }
.transaction-mobile-header { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.transaction-mobile-header span { display: block; margin-top: .15rem; color: #64748b; font-size: .82rem; }
.transaction-mobile-value { color: #172033; white-space: nowrap; }
.transaction-mobile-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem .8rem; margin: .9rem 0; }
.transaction-mobile-details div:last-child { grid-column: 1 / -1; }
.transaction-mobile-details dt { color: #64748b; font-size: .73rem; font-weight: 650; text-transform: uppercase; letter-spacing: .03em; }
.transaction-mobile-details dd { margin: .12rem 0 0; overflow-wrap: anywhere; font-size: .88rem; }
.transaction-mobile-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.transaction-mobile-actions form { margin: 0; }

#id_transaction_type {
    display: none;
}

/* Calendário */
.calendar-toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.eyebrow {
    margin-bottom: 6px;
    color: #697386;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.calendar-toolbar h1 {
    margin-bottom: 4px;
    font-weight: 700;
}

.calendar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.calendar-actions strong {
    min-width: 150px;
    font-size: 1.05rem;
    text-align: center;
}

.calendar-card,
.selected-day {
    overflow: hidden;
    background: #fff;
    border: 1px solid #e3e6eb;
    border-radius: 14px;
    box-shadow: 0 6px 18px #1522380b;
}

.weekdays,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekdays {
    background: #f8f9fb;
    border-bottom: 1px solid #e3e6eb;
}

.weekdays div {
    min-width: 0;
    padding: 15px 14px;
    color: #778092;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.calendar-day {
    position: relative;
    min-height: 132px;
    padding: 12px 14px;
    border-right: 1px solid #e6e8ed;
    border-bottom: 1px solid #e6e8ed;
    transition: background 0.15s;
}

.calendar-day:nth-child(7n) {
    border-right: 0;
}

.calendar-day:hover {
    background: #f8fbff;
}

.calendar-day.empty {
    background: #fafbfc;
}

.calendar-day.selected {
    background: #eff6ff;
}

.calendar-day.today {
    box-shadow: inset 0 0 0 2px #93c5fd;
    background: #eff6ff;
}

.calendar-day.today .day-number {
    color: #4c5668;
}

.day-number-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
}

.calendar-day.today .day-number-circle {
    background: #2563eb;
    border-radius: 50%;
    color: #fff;
}

.today-label {
    display: none !important;
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    display: block;
    color: #2563eb;
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    pointer-events: none;
}

.day-number {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    width: auto;
    height: auto;
    padding: 12px 14px;
    color: #4c5668;
    font-weight: 700;
    text-decoration: none;
}

.calendar-day.selected .day-number {
    color: #1d4ed8;
}

.event-dot {
    position: relative;
    z-index: 2;
    display: block;
    width: 7px;
    height: 7px;
    margin-top: 58px;
    background: #2563eb;
    border-radius: 50%;
    pointer-events: none;
}

.event-label {
    position: relative;
    z-index: 2;
    display: block;
    margin-top: 5px;
    color: #2563eb;
    font-size: 0.72rem;
    pointer-events: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selected-day {
    padding: 20px 24px;
}

.movement-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-top: 1px solid #edf0f4;
}

canvas {
    max-height: 200px !important;
}

/* Formulários de investimento */
.investment-form-page { padding: .5rem 0 2rem; }
.investment-form-card { width: min(100%, 850px); margin: 0 auto; padding: clamp(1.3rem, 4vw, 2.5rem); border: 1px solid #e6ebf2; border-radius: 18px; box-shadow: 0 14px 36px #15223812; }
.investment-back-link { display: inline-flex; align-items: center; gap: .4rem; color: #2563eb; font-size: .92rem; font-weight: 600; text-decoration: none; }
.investment-back-link:hover { color: #1d4ed8; text-decoration: underline; }
.investment-form-heading { margin: 1.3rem 0 1.8rem; }
.investment-form-heading h1 { margin: 0 0 .45rem; color: #172033; font-size: clamp(1.7rem, 3vw, 2.15rem); font-weight: 750; }
.investment-form-heading p { max-width: 650px; margin: 0; color: #64748b; }
.investment-form { display: grid; gap: 1.25rem; }
.investment-section { padding: 1.2rem; border: 1px solid #e5eaf1; border-radius: 14px; background: #fbfcfe; }
.investment-section[hidden], .investment-field[hidden] { display: none !important; }
.investment-section h2 { margin: 0 0 1rem; color: #334155; font-size: 1rem; font-weight: 700; }
.investment-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.1rem; }
.investment-grid-single { grid-template-columns: 1fr; }
.investment-field { min-width: 0; }
.investment-field[data-field='name'], .investment-field[data-field='ticker'], .investment-field[data-field='external_identifier'], .investment-field[data-field='notes'] { grid-column: 1 / -1; }
.investment-field label { display: block; margin-bottom: .43rem; color: #334155; font-size: .9rem; font-weight: 650; }
.investment-field label span { color: #dc2626; }
.investment-field input, .investment-field select, .investment-field textarea { display: block; width: 100%; min-height: 46px; padding: .68rem .8rem; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: #172033; transition: border-color .16s, box-shadow .16s, background .16s; }
.investment-field textarea { min-height: 102px; resize: vertical; }
.investment-field input:focus, .investment-field select:focus, .investment-field textarea:focus { border-color: #2563eb; outline: 0; box-shadow: 0 0 0 3px #2563eb22; }
.investment-help { margin-top: .4rem; color: #64748b; font-size: .78rem; line-height: 1.35; }
.investment-capital-confirmation { display: flex; align-items: flex-start; gap: .65rem; margin-top: 1rem; padding: .8rem .9rem; border: 1px solid #dbe5f1; border-radius: 10px; background: #fff; }
.investment-capital-confirmation input { width: 1rem; height: 1rem; margin: .18rem 0 0; accent-color: #2563eb; flex: 0 0 auto; }
.investment-capital-confirmation label { display: block; margin: 0; color: #334155; font-size: .88rem; font-weight: 650; cursor: pointer; }
.investment-capital-confirmation small { display: block; margin-top: .2rem; color: #64748b; font-size: .78rem; line-height: 1.35; }
.investment-error { margin-top: .4rem; color: #b91c1c; font-size: .82rem; font-weight: 600; }
.investment-form-alert { padding: .8rem .95rem; border: 1px solid #fecaca; border-radius: 10px; background: #fef2f2; color: #b91c1c; font-size: .9rem; }
.investment-update-info { display: flex; align-items: flex-start; gap: .7rem; margin-top: 1rem; padding: .85rem 1rem; border: 1px solid #bfdbfe; border-radius: 11px; background: #eff6ff; color: #1e40af; }
.investment-update-info > i { margin-top: .08rem; font-size: 1.05rem; }
.investment-update-info strong, .investment-update-info span { display: block; }
.investment-update-info strong { margin-bottom: .15rem; font-size: .9rem; }
.investment-update-info span { color: #475569; font-size: .82rem; line-height: 1.35; }
.investment-form-actions { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; padding-top: .25rem; }
.investment-form-actions .btn { min-height: 46px; padding: .65rem 1.1rem; border-radius: 10px; font-weight: 650; }
.investment-form-actions .btn-primary { background: #2563eb; border-color: #2563eb; }
.investment-form-actions .btn-primary:hover, .investment-form-actions .btn-primary:focus-visible { background: #1d4ed8; border-color: #1d4ed8; }

@media (max-width: 768px) {
    main.container { padding-right: .85rem; padding-left: .85rem; }
    h1 { font-size: clamp(1.65rem, 8vw, 2rem); }
    .card { min-width: 0; }
    .btn, .form-control, .form-select { min-height: 42px; }
    .table-responsive { -webkit-overflow-scrolling: touch; }
    .report-chart { height: 250px; }
    .report-chart-svg { overflow: visible; }
    .report-chart-svg svg { min-width: 0; }
    .mobile-only { display: block; }
    .desktop-only { display: none !important; }

    .dashboard-actions .btn { flex: 1 1 auto; }
    #dashboard-settings-panel { max-width: none !important; }
    #dashboard-settings-panel .form-select,
    #dashboard-settings-panel .form-control { max-width: none !important; flex: 1 1 130px; }
    #expenseChart, #investmentChart { max-height: 260px !important; }
    .navbar .container {
        gap: 0.75rem;
    }

    .navbar .container > div {
        gap: 0.6rem;
    }

    .controlefin-brand img { width: 190px; }
    .nav-toggle { display: inline-flex; align-items: center; justify-content: center; margin-left: auto; }
    .main-navigation { position: absolute; z-index: 20; top: 100%; right: 0; left: 0; display: flex; flex-direction: column; align-items: stretch; gap: .7rem; padding: .9rem 1rem 1rem; background: #212529; box-shadow: 0 8px 18px #0003; opacity: 0; visibility: hidden; transform: translateY(-8px); transition: opacity .18s, transform .18s, visibility .18s; }
    .main-navigation.is-open { opacity: 1; visibility: visible; transform: translateY(0); }
    .nav-links { display: flex; flex-direction: column; align-items: stretch; gap: .4rem; }
    .nav-link-item { justify-content: flex-start; width: 100%; }
    .nav-logout { width: 100%; }
    .site-navbar { position: relative; }

    .auth-page { min-height: calc(100vh - 100px); padding: 1rem 0; }
    .auth-card { padding: 1.5rem; border-radius: 14px; }

    .calendar-toolbar {
        display: block;
    }

    .calendar-actions {
        flex-wrap: wrap;
        margin-top: 18px;
    }

    .weekdays div {
        padding: 10px 4px;
        font-size: 0.58rem;
        text-align: center;
    }

    .calendar-card { overflow: visible; }

    .weekdays,
    .calendar-grid {
        width: 100%;
        min-width: 0;
    }

    .weekdays div,
    .calendar-day {
        min-width: 0;
        overflow: hidden;
    }

    .calendar-day {
        min-height: 88px;
        padding: 7px 5px;
    }

    .day-number {
        padding: 8px;
        font-size: 0.78rem;
    }

    .calendar-day.today .day-number {
        padding: 7px 5px;
    }

    .calendar-day.today .day-number-circle {
        min-width: 24px;
        height: 24px;
        font-size: 0.72rem;
    }

    .today-label {
        display: none !important;
    }

    .event-dot {
        width: 6px;
        height: 6px;
        margin-top: 49px;
    }

    .event-label {
        overflow: hidden;
        margin-top: 3px;
        font-size: 0.48rem;
        line-height: 1.1;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .calendar-actions strong {
        min-width: 120px;
    }

    .investment-form-card { padding: 1.15rem; border-radius: 14px; }
    .investment-grid { grid-template-columns: 1fr; gap: .9rem; }
    .investment-field[data-field='name'], .investment-field[data-field='ticker'], .investment-field[data-field='external_identifier'], .investment-field[data-field='notes'] { grid-column: auto; }
    .investment-section { padding: 1rem; }
    .investment-form-actions .btn { width: 100%; }

    .form-card { width: 100%; padding: 1.15rem; }
    .form-card .btn:not(.btn-sm) { min-height: 42px; }
    .list-group-item { align-items: flex-start !important; flex-direction: column; }
    .list-group-item > span:last-child { width: 100%; flex-wrap: wrap; }
    .selected-day { padding: 1rem; }
    .selected-day > .d-flex { align-items: flex-start !important; flex-direction: column; }
    .movement-row { gap: .75rem; align-items: flex-start; }
    .movement-row span { min-width: 0; overflow-wrap: anywhere; }
    .transaction-mobile-list { display: block; }
    .transaction-mobile-actions .btn { min-height: 38px; }
}
