/**
 * DescomplicaJá — mobile-first; tema escuro “futurista” + claro refinado.
 */
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,200..800;1,200..800&display=swap");

:root {
    --radius: 18px;
    --radius-sm: 14px;
    --radius-pill: 999px;
    --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", monospace;
    --space: clamp(14px, 4vw, 22px);
    --space-section: clamp(24px, 5vw, 40px);
    --touch-min: 44px;
    --content-max: 1320px;
    --bottom-nav-h: 76px;
    --bottom-nav-fab-size: 48px;
    --bottom-nav-icon-slot: 48px;
    --sidebar-w: 268px;
    --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
}

/* ——— Tema escuro: fundo profundo, vidro, acentos neon ——— */
html.theme-dark {
    --bg-deep: #020617;
    --bg: #050810;
    --bg-elevated: #0b1220;
    --surface: rgba(17, 24, 39, 0.58);
    --surface2: rgba(30, 41, 59, 0.45);
    --surface-hover: rgba(51, 65, 85, 0.5);
    --text: #f8fafc;
    --text-secondary: #94a3b8;
    --muted: #64748b;
    --line: rgba(148, 163, 184, 0.14);
    --line-strong: rgba(148, 163, 184, 0.26);
    --line-glass: rgba(255, 255, 255, 0.07);
    --accent: #8b5cf6;
    --accent-hover: #a78bfa;
    --accent-muted: rgba(139, 92, 246, 0.28);
    --income: #34d399;
    --income-bg: rgba(52, 211, 153, 0.16);
    --expense: #fb7185;
    --expense-bg: rgba(251, 113, 133, 0.16);
    --warn: #fbbf24;
    --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 0 0 1px var(--line-glass), 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 0 80px rgba(99, 102, 241, 0.14);
    --glow-primary: 0 0 40px rgba(139, 92, 246, 0.35);
    --glow-soft: 0 0 24px rgba(6, 182, 212, 0.12);
}

/* ——— Tema claro: contraste suave, sombras definidas ——— */
html.theme-light {
    --bg-deep: #eef2f7;
    --bg: #f4f6fb;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --surface2: #f1f5f9;
    --surface-hover: #e8edf5;
    --text: #0f172a;
    --text-secondary: #475569;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --line-glass: rgba(15, 23, 42, 0.06);
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-muted: rgba(99, 102, 241, 0.14);
    --income: #059669;
    --income-bg: rgba(5, 150, 105, 0.11);
    --expense: #dc2626;
    --expense-bg: rgba(220, 38, 38, 0.09);
    --warn: #d97706;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 8px 32px rgba(15, 23, 42, 0.09);
    --shadow-lg: 0 20px 56px rgba(15, 23, 42, 0.11);
    --glow-primary: 0 8px 28px rgba(99, 102, 241, 0.22);
    --glow-soft: 0 4px 20px rgba(14, 165, 233, 0.12);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html.theme-dark,
html.theme-light {
    font-family: var(--font);
    color: var(--text);
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

html.theme-dark {
    background-color: var(--bg-deep);
    background-image:
        radial-gradient(ellipse 110% 80% at 50% -35%, rgba(99, 102, 241, 0.22), transparent 58%),
        radial-gradient(ellipse 50% 45% at 100% 10%, rgba(6, 182, 212, 0.12), transparent 52%),
        radial-gradient(ellipse 45% 40% at 0% 90%, rgba(168, 85, 247, 0.16), transparent 55%);
    background-attachment: fixed;
}

html.theme-light {
    background-color: var(--bg);
    background-image: radial-gradient(ellipse 100% 55% at 50% 0%, rgba(99, 102, 241, 0.1), transparent 58%);
    background-attachment: fixed;
}

@media (prefers-reduced-motion: reduce) {
    html.theme-dark,
    html.theme-light {
        scroll-behavior: auto;
    }
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.55;
    font-size: 1rem;
    background: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Espaço para barra inferior no celular */
@media (max-width: 899px) {
    .app-body:has(.bottom-nav) {
        padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    }
}

a {
    color: var(--accent-hover);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.nav-toggle:focus-visible,
.bottom-nav__link:focus-visible {
    outline: 2px solid var(--accent-hover);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 8px;
    background: var(--surface);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    z-index: 100;
    font-weight: 600;
}

.skip-link:focus {
    left: max(8px, env(safe-area-inset-left));
}

/* ——— Layout: sidebar (desktop) + shell ——— */
.app-body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
}

.sidebar {
    display: none;
}

.app-shell {
    display: block;
    min-width: 0;
}

@media (min-width: 900px) {
    .app-body {
        display: flex;
        flex-direction: row;
        align-items: stretch;
    }

    .sidebar {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: var(--sidebar-w);
        z-index: 55;
        background: color-mix(in srgb, var(--surface) 96%, transparent);
        backdrop-filter: blur(20px) saturate(1.1);
        -webkit-backdrop-filter: blur(20px) saturate(1.1);
        border-right: 1px solid var(--line);
        padding: 18px 14px 24px;
        padding-top: max(18px, env(safe-area-inset-top));
        transition: transform 0.28s var(--ease-out);
    }

    html.theme-dark .sidebar {
        background: color-mix(in srgb, rgba(15, 23, 42, 0.82) 94%, transparent);
        border-right-color: var(--line-glass);
    }

    html.theme-light .sidebar {
        background: color-mix(in srgb, var(--surface) 98%, transparent);
    }

    .app-body.sidebar-off .sidebar {
        transform: translateX(-100%);
        pointer-events: none;
    }

    .sidebar__head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-bottom: 22px;
    }

    .sidebar__hide-btn {
        flex-shrink: 0;
        width: 42px;
        height: 42px;
        border: 1px solid var(--line);
        background: var(--surface2);
        color: var(--text);
        border-radius: var(--radius-sm);
        cursor: pointer;
        font-size: 0.875rem;
        font-weight: 600;
    }

    .sidebar__hide-btn:hover {
        background: var(--surface-hover);
    }

    .sidebar__nav {
        display: flex;
        flex-direction: column;
        gap: 4px;
        overflow-y: auto;
        flex: 1;
        padding-bottom: 8px;
    }

    .sidebar__nav .nav-main__link {
        display: block;
        padding: 11px 14px;
        border-radius: var(--radius-sm);
        font-size: 0.9375rem;
        font-weight: 500;
        color: var(--text-secondary);
        text-decoration: none;
        line-height: 1.35;
    }

    .sidebar__nav .nav-main__link:hover {
        background: var(--surface2);
        color: var(--text);
        text-decoration: none;
    }

    .sidebar__nav .nav-main__link--cta {
        background: linear-gradient(135deg, #6d28d9 0%, var(--accent) 50%, #6366f1 100%);
        color: #fff !important;
        font-weight: 600;
        text-align: center;
        box-shadow: var(--shadow-sm), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
    }

    .sidebar__nav .nav-main__link--cta:hover {
        filter: brightness(1.06);
        color: #fff !important;
    }

    .app-shell {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-width: 0;
        min-height: 100vh;
        min-height: 100dvh;
        margin-left: var(--sidebar-w);
        transition: margin-left 0.28s var(--ease-out);
    }

    .app-shell > .main {
        flex: 1 0 auto;
        width: 100%;
        min-width: 0;
    }

    .app-body.sidebar-off .app-shell {
        margin-left: 0;
    }

    .topbar__sidebar-open {
        display: none;
        align-items: center;
        justify-content: center;
        min-width: var(--touch-min);
        min-height: var(--touch-min);
        border: 1px solid var(--line);
        background: var(--surface2);
        color: var(--text);
        border-radius: var(--radius-sm);
        cursor: pointer;
        font-size: 1.1rem;
        font-weight: 600;
        margin-right: 4px;
    }

    .topbar__sidebar-open:hover {
        background: var(--surface-hover);
    }

    .app-body.sidebar-off .topbar__sidebar-open {
        display: inline-flex;
    }

    .brand--mobile {
        display: none !important;
    }

    .topbar .nav-toggle,
    .topbar .nav {
        display: none !important;
    }

    .app-body:not(.sidebar-off) .topbar {
        display: none;
    }
}

@media (max-width: 899px) {
    .sidebar__hide-btn,
    .topbar__sidebar-open {
        display: none !important;
    }
}

.field--disabled {
    opacity: 0.55;
}

/* ——— Topbar ——— */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border-bottom: 1px solid var(--line);
    padding-top: env(safe-area-inset-top, 0px);
}

html.theme-dark .topbar {
    background: color-mix(in srgb, rgba(15, 23, 42, 0.85) 90%, transparent);
    border-bottom-color: var(--line-glass);
}

html.theme-light .topbar {
    background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.topbar__inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 12px var(--space);
    padding-left: max(var(--space), env(safe-area-inset-left));
    padding-right: max(var(--space), env(safe-area-inset-right));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

@media (min-width: 900px) {
    .topbar__inner {
        padding-top: 14px;
        padding-bottom: 14px;
    }
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-size: clamp(1.1rem, 3.5vw, 1.25rem);
    color: var(--text);
    text-decoration: none;
}

.brand__logo {
    width: 190px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 10px;
}

.brand__name {
    line-height: 1.15;
}

.brand:hover {
    text-decoration: none;
    color: var(--accent-hover);
}

.brand:hover .brand__logo {
    filter: brightness(1.05);
}

.auth-brand {
    text-align: center;
    margin: 0 0 16px;
}

.auth-brand img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 14px;
    vertical-align: middle;
}

.nav {
    display: none;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: stretch;
    width: 100%;
    padding-top: 8px;
    border-top: 1px solid var(--line);
    margin-top: 8px;
}

.nav.is-open {
    display: flex;
}

@media (min-width: 900px) {
    .topbar .nav {
        display: none !important;
    }
}

.nav .nav-main__link {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    padding: 12px 14px;
    min-height: var(--touch-min);
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 899px) {
    .nav .nav-main__link {
        display: flex;
        width: 100%;
        justify-content: flex-start;
    }
}

@media (min-width: 900px) {
    .nav .nav-main__link {
        padding: 10px 12px;
        min-height: auto;
    }
}

.nav .nav-main__link:hover {
    background: var(--surface2);
    text-decoration: none;
    color: var(--text);
}

.nav__highlight {
    background: linear-gradient(135deg, #6d28d9 0%, var(--accent) 50%, #6366f1 100%);
    color: #fff !important;
    font-weight: 600;
    padding: 12px 16px !important;
    box-shadow: var(--shadow-sm), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

@media (min-width: 900px) {
    .nav__highlight {
        padding: 10px 16px !important;
    }
}

.nav__highlight:hover {
    filter: brightness(1.08);
    color: #fff !important;
}

.nav-toggle {
    border: 1px solid var(--line);
    background: var(--surface2);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    min-height: var(--touch-min);
    min-width: var(--touch-min);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
}

@media (min-width: 900px) {
    .nav-toggle {
        display: none;
    }
}

/* ——— Conteúdo principal ——— */
/* width:100% evita coluna estreita quando .main é filho flex (margin:auto + stretch). */
.main {
    width: 100%;
    max-width: var(--content-max);
    margin-left: auto;
    margin-right: auto;
    padding: var(--space-section) var(--space);
    padding-left: max(var(--space), env(safe-area-inset-left));
    padding-right: max(var(--space), env(safe-area-inset-right));
    padding-bottom: calc(var(--space-section) + 8px);
}

@media (min-width: 900px) {
    .main {
        padding-top: clamp(28px, 4vw, 40px);
        padding-bottom: calc(var(--space-section) + 32px);
    }
}

/* ——— Barra inferior (mobile) ——— */
.bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 45;
    justify-content: space-around;
    align-items: center;
    gap: 0;
    padding: 8px 4px calc(10px + env(safe-area-inset-bottom, 0px));
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    min-height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(20px) saturate(1.15);
    -webkit-backdrop-filter: blur(20px) saturate(1.15);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
}

.theme-light .bottom-nav {
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    box-shadow: 0 -2px 20px rgba(15, 15, 18, 0.06);
}

html.theme-dark .bottom-nav {
    background: color-mix(in srgb, rgba(15, 23, 42, 0.92) 92%, transparent);
    border-top-color: var(--line-glass);
}

.bottom-nav--five .bottom-nav__link {
    font-size: 0.6rem;
    letter-spacing: 0.03em;
    padding: 4px 1px 2px;
}

.bottom-nav__link {
    flex: 1 1 0;
    min-width: 0;
    max-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: var(--touch-min);
    padding: 4px 2px 2px;
    text-align: center;
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-decoration: none;
    line-height: 1.1;
    transition: color 0.15s var(--ease-out), background 0.15s var(--ease-out);
}

.bottom-nav__label {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Área fixa: ícones SVG alinhados ao mesmo eixo óptico */
.bottom-nav__icon-slot {
    width: var(--bottom-nav-icon-slot);
    height: var(--bottom-nav-icon-slot);
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.bottom-nav__icon-svg {
    display: block;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    overflow: visible;
    pointer-events: none;
}

.bottom-nav__link:hover {
    text-decoration: none;
    color: var(--text-secondary);
    background: var(--surface2);
}

.bottom-nav__link--primary {
    background: transparent;
    color: var(--accent);
    box-shadow: none;
}

.bottom-nav__link--primary:hover {
    color: var(--accent-hover);
    background: transparent;
    filter: none;
}

.bottom-nav__link--primary:hover .bottom-nav__fab {
    filter: brightness(1.06);
    box-shadow: 0 6px 28px rgba(124, 58, 237, 0.45);
}

.bottom-nav__fab {
    box-sizing: border-box;
    width: var(--bottom-nav-fab-size);
    height: var(--bottom-nav-fab-size);
    min-width: var(--bottom-nav-fab-size);
    min-height: var(--bottom-nav-fab-size);
    max-width: var(--bottom-nav-fab-size);
    max-height: var(--bottom-nav-fab-size);
    flex: 0 0 var(--bottom-nav-fab-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(155deg, #6d28d9, var(--accent));
    color: #fff;
    box-shadow:
        0 3px 14px rgba(124, 58, 237, 0.35),
        0 0 0 1px rgba(255, 255, 255, 0.12) inset;
    transition:
        filter 0.15s var(--ease-out),
        box-shadow 0.15s var(--ease-out), transform 0.15s var(--ease-out);
}

.bottom-nav__icon-svg--fab {
    width: 22px;
    height: 22px;
    color: #fff;
}

@media (prefers-reduced-motion: no-preference) {
    .bottom-nav__link--primary:active .bottom-nav__fab {
        transform: scale(0.96);
    }
}

@media (min-width: 900px) {
    .bottom-nav {
        display: none;
    }
}

.footer {
    text-align: center;
    padding: max(24px, var(--space)) var(--space);
    padding-bottom: max(24px, var(--space));
    color: var(--muted);
    font-size: 0.8125rem;
    border-top: 1px solid var(--line);
}

html.theme-dark .footer {
    border-top-color: var(--line-glass);
}

.screen-title {
    font-size: clamp(1.5rem, 5vw, 1.875rem);
    margin: 0 0 10px;
    letter-spacing: -0.035em;
    font-weight: 700;
    line-height: 1.2;
}

.dash-user-greeting {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.dash-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
    background: var(--surface2);
    border: 1px solid var(--line-glass, var(--line));
}

.dash-user-avatar--sm {
    width: 26px;
    height: 26px;
}

.screen-sub {
    color: var(--text-secondary);
    margin: 0 0 clamp(20px, 4vw, 28px);
    font-size: clamp(0.9375rem, 2.8vw, 1.0625rem);
    max-width: 42em;
    line-height: 1.5;
}

.grid {
    display: grid;
    gap: var(--space);
}

@media (min-width: 720px) {
    .grid--2 {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid--3 {
        grid-template-columns: repeat(3, 1fr);
    }
    .grid--4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 900px) {
    .grid {
        gap: clamp(18px, 2vw, 24px);
    }
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: clamp(16px, 4vw, 20px);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

html.theme-dark .card {
    background: linear-gradient(160deg, rgba(30, 41, 59, 0.44) 0%, rgba(15, 23, 42, 0.58) 100%);
    border-color: var(--line-glass);
    backdrop-filter: blur(20px) saturate(1.25);
    -webkit-backdrop-filter: blur(20px) saturate(1.25);
    box-shadow: var(--shadow-md), var(--glow-soft);
}

html.theme-light .card {
    box-shadow: var(--shadow-md);
}

@media (min-width: 900px) {
    .card:hover {
        border-color: var(--line-strong);
        box-shadow: var(--shadow-md);
    }

    html.theme-dark .card:hover {
        border-color: rgba(167, 139, 250, 0.35);
        box-shadow: var(--shadow-md), 0 0 48px rgba(99, 102, 241, 0.12);
    }
}

.card--soft {
    background: var(--surface2);
    box-shadow: none;
}

html.theme-dark .card--soft {
    background: linear-gradient(160deg, rgba(30, 41, 59, 0.32), rgba(15, 23, 42, 0.42));
}

@media (min-width: 900px) {
    .card--soft:hover {
        box-shadow: var(--shadow-sm);
    }

    html.theme-dark .card--soft:hover {
        box-shadow: 0 0 32px rgba(6, 182, 212, 0.08);
    }
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat__label {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.stat__value {
    font-size: clamp(1.35rem, 4vw, 1.65rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.stat__value--income {
    color: var(--income);
}

.stat__value--expense {
    color: var(--expense);
}

/* Resumo do painel: cartões com aura e valores em “badge” verde / vermelho */
.stat--tone-neutral {
    border-color: var(--line-glass, var(--line));
}

html.theme-dark .stat--tone-neutral {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04) inset, 0 12px 40px rgba(0, 0, 0, 0.25);
}

.stat--tone-income {
    border-color: var(--line-glass, var(--line));
    box-shadow: var(--shadow-sm);
}

html.theme-dark .stat--tone-income {
    border-color: rgba(148, 163, 184, 0.12);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

.stat--tone-expense {
    border-color: var(--line-glass, var(--line));
    box-shadow: var(--shadow-sm);
}

html.theme-dark .stat--tone-expense {
    border-color: rgba(148, 163, 184, 0.12);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

/* Cartões do painel (Economia / Entradas / Saídas): mesmo “vidro” + tinta rgb(… / ~33%) suave — alinhado aos pills */
html.theme-dark .card.stat.stat--tone-income {
    background:
        linear-gradient(145deg, rgb(42 249 42 / 28%) 0%, rgb(42 249 42 / 12%) 38%, transparent 62%),
        linear-gradient(160deg, rgba(30, 41, 59, 0.44) 0%, rgba(15, 23, 42, 0.58) 100%);
    border-color: rgba(74, 222, 128, 0.24);
    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.28),
        0 0 0 1px rgb(42 249 42 / 12%) inset;
}

html.theme-dark .card.stat.stat--tone-expense {
    background:
        linear-gradient(145deg, rgb(255 70 90 / 28%) 0%, rgb(255 70 90 / 12%) 38%, transparent 62%),
        linear-gradient(160deg, rgba(30, 41, 59, 0.44) 0%, rgba(15, 23, 42, 0.58) 100%);
    border-color: rgba(251, 113, 133, 0.24);
    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.28),
        0 0 0 1px rgb(255 70 90 / 12%) inset;
}

html.theme-light .card.stat.stat--tone-income {
    border-color: color-mix(in srgb, rgb(34 197 94) 32%, var(--line));
}

html.theme-light .card.stat.stat--tone-expense {
    border-color: color-mix(in srgb, rgb(220 38 38) 32%, var(--line));
}

html.theme-dark .card.stat.stat--tone-income .stat__label {
    color: #a7f3d0;
}

html.theme-dark .card.stat.stat--tone-expense .stat__label {
    color: #fecdd3;
}

html.theme-light .card.stat.stat--tone-income .stat__label {
    color: #166534;
}

html.theme-light .card.stat.stat--tone-expense .stat__label {
    color: #991b1b;
}

html.theme-dark .card.stat.stat--tone-income .hint,
html.theme-dark .card.stat.stat--tone-expense .hint {
    color: rgba(226, 232, 240, 0.82);
}

html.theme-light .card.stat.stat--tone-income .hint,
html.theme-light .card.stat.stat--tone-expense .hint {
    color: rgba(30, 41, 59, 0.75);
}

.stat--flat {
    box-shadow: var(--shadow-sm) !important;
}

html.theme-dark .stat--flat.stat--tone-income {
    border-color: rgba(74, 222, 128, 0.22);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.22),
        0 0 0 1px rgb(42 249 42 / 10%) inset !important;
}

html.theme-dark .stat--flat.stat--tone-expense {
    border-color: rgba(251, 113, 133, 0.22);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.22),
        0 0 0 1px rgb(255 70 90 / 10%) inset !important;
}

html.theme-dark .stat--flat.stat--tone-insight {
    border-color: rgba(148, 163, 184, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.22) !important;
}

.stat--tone-insight {
    border-color: rgba(167, 139, 250, 0.35);
    box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.1) inset, 0 10px 36px rgba(99, 102, 241, 0.1);
}

html.theme-dark .stat--tone-insight {
    border-color: rgba(167, 139, 250, 0.4);
    box-shadow:
        0 0 0 1px rgba(139, 92, 246, 0.12) inset,
        0 0 28px rgba(99, 102, 241, 0.12),
        0 12px 40px rgba(0, 0, 0, 0.3);
}

.stat__value--pill {
    align-self: flex-start;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    font-size: clamp(1.25rem, 3.8vw, 1.55rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

/* Pills: fundo semitransparente; texto claro no dark, escuro no light */
.stat__value--pill.stat__value--income {
    color: #ecfdf5;
    background-color: rgb(42 249 42 / 33%);
    border: 1px solid rgb(42 249 42 / 48%);
    box-shadow: none;
    text-shadow: none;
}

html.theme-light .stat__value--pill.stat__value--income {
    color: #14532d;
    background-color: rgb(42 249 42 / 33%);
    border: 1px solid rgb(22 163 74 / 35%);
}

.stat__value--pill.stat__value--expense {
    color: #ffe4e6;
    background-color: rgb(255 70 90 / 33%);
    border: 1px solid rgb(255 70 90 / 48%);
    box-shadow: none;
    text-shadow: none;
}

html.theme-light .stat__value--pill.stat__value--expense {
    color: #7f1d1d;
    background-color: rgb(255 70 90 / 33%);
    border: 1px solid rgb(220 38 38 / 35%);
}

.stat--tone-neutral .stat__value--pill {
    color: var(--text);
    background: var(--surface2);
    border: 1px solid var(--line-glass, var(--line));
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

html.theme-dark .stat--tone-neutral .stat__value--pill {
    background: linear-gradient(145deg, rgba(51, 65, 85, 0.4), rgba(30, 41, 59, 0.35));
    border-color: rgba(148, 163, 184, 0.2);
    box-shadow: 0 0 20px rgba(148, 163, 184, 0.08);
}

.stat__insight-text {
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

html.theme-dark .stat__insight-text {
    color: #cbd5e1;
}

.dash-insight__icon {
    display: inline-block;
    vertical-align: -3px;
    margin-right: 6px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    min-height: var(--touch-min);
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    text-decoration: none;
    color: #fff;
    background: var(--accent);
    transition: transform 0.12s var(--ease-out), filter 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 8px var(--accent-muted);
}

@media (min-width: 900px) {
    .btn {
        padding: 12px 20px;
        min-height: 44px;
    }
}

.btn:hover {
    filter: brightness(1.06);
    text-decoration: none;
    color: #fff;
}

.btn:active {
    transform: scale(0.98);
}

.btn--block {
    width: 100%;
}

.btn--ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
    box-shadow: none;
}

.btn--ghost:hover {
    background: var(--surface2);
    color: var(--text);
}

.btn--income {
    color: #ecfdf5;
    background-color: rgb(42 249 42 / 33%);
    border: 1px solid rgb(42 249 42 / 48%);
    box-shadow: none !important;
}

.btn--expense {
    color: #ffe4e6;
    background-color: rgb(255 70 90 / 33%);
    border: 1px solid rgb(255 70 90 / 48%);
    box-shadow: none !important;
}

html.theme-dark .btn:not(.btn--ghost):not(.btn--income):not(.btn--expense) {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 45%, #a855f7 100%);
    box-shadow: 0 4px 24px rgba(99, 102, 241, 0.4), var(--glow-primary);
}

html.theme-dark .btn:not(.btn--ghost):not(.btn--income):not(.btn--expense):hover {
    filter: brightness(1.08);
    box-shadow: 0 6px 32px rgba(139, 92, 246, 0.5);
}

html.theme-light .btn:not(.btn--ghost):not(.btn--income):not(.btn--expense) {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 48%, #7c3aed 100%);
    box-shadow: var(--glow-primary);
}

html.theme-light .btn:not(.btn--ghost):not(.btn--income):not(.btn--expense):hover {
    filter: brightness(1.05);
}

.btn--xl {
    font-size: 1.0625rem;
    padding: 16px 22px;
    min-height: 52px;
    border-radius: var(--radius);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: clamp(14px, 3vw, 18px);
}

.field label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 14px 16px;
    min-height: var(--touch-min);
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface2);
    color: var(--text);
    font-size: 16px; /* evita zoom iOS em foco */
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent-hover);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

@media (min-width: 900px) {
    .field input,
    .field select,
    .field textarea {
        font-size: 1rem;
        padding: 12px 14px;
        min-height: 44px;
    }
    .field textarea {
        min-height: 100px;
    }
}

.field textarea {
    min-height: 96px;
    resize: vertical;
}

/* Interruptor (modo escuro / ajustes) — não usa o estilo “campo gigante” */
.theme-form .btn {
    margin-top: 8px;
}

.theme-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(12px, 3vw, 20px);
    padding: 8px 0 4px;
    margin-bottom: 4px;
}

.theme-toggle-row__copy {
    flex: 1;
    min-width: 0;
}

.theme-toggle-row__title {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    letter-spacing: -0.02em;
}

.theme-toggle-row__hint {
    display: block;
    margin-top: 4px;
    font-size: 0.8125rem;
    color: var(--muted);
    line-height: 1.45;
    max-width: 36em;
}

.toggle-switch {
    position: relative;
    width: 56px;
    height: 32px;
    flex-shrink: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.toggle-switch__input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.toggle-switch__slider {
    display: block;
    position: absolute;
    inset: 0;
    background: var(--surface2);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    transition: background 0.2s var(--ease-out), border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.theme-light .toggle-switch__slider {
    background: #e8e8ed;
}

.toggle-switch__slider::after {
    content: "";
    position: absolute;
    width: 26px;
    height: 26px;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface);
    border-radius: 50%;
    box-shadow: var(--shadow-sm), 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.22s var(--ease-out), background 0.2s ease;
}

.theme-light .toggle-switch__slider::after {
    background: #fff;
}

.toggle-switch__input:checked + .toggle-switch__slider {
    background: linear-gradient(135deg, #6d28d9, var(--accent));
    border-color: transparent;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.toggle-switch__input:checked + .toggle-switch__slider::after {
    transform: translate(24px, -50%);
    background: #fff;
}

.toggle-switch__input:focus-visible + .toggle-switch__slider {
    outline: 2px solid var(--accent-hover);
    outline-offset: 3px;
}

.toggle-switch__input:disabled + .toggle-switch__slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Cartões de conta (lista + desativar) */
.account-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 100%;
}

.account-card--inactive {
    opacity: 0.92;
    border-style: dashed;
    background: color-mix(in srgb, var(--surface2) 65%, var(--surface));
}

.theme-light .account-card--inactive {
    background: color-mix(in srgb, var(--surface2) 80%, var(--surface));
}

.account-card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.account-card__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.pill--muted {
    background: var(--surface2);
    color: var(--muted);
    border: 1px solid var(--line);
}

.account-card__actions {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.account-card__form {
    margin: 0;
}

.goal-add__row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
}

.goal-add__row input {
    flex: 1;
    min-width: 6.5rem;
}

.goal-edit summary {
    font-weight: 600;
    color: var(--text-secondary);
}

.goal-edit[open] summary {
    margin-bottom: 4px;
}

.btn--sm {
    padding: 10px 14px;
    min-height: 40px;
    font-size: 0.875rem;
    width: 100%;
}

/* Histórico: botão “Editar” menor (evita esticar por causa de width:100% em .btn--sm) */
.tx-item [data-edit-tx] {
    width: auto !important;
    min-width: 0 !important;
    padding: 7px 12px !important;
    min-height: 34px !important;
    font-size: 0.82rem !important;
    white-space: nowrap;
}

@media (min-width: 480px) {
    .btn--sm {
        width: auto;
        min-width: 120px;
    }
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 18px 0;
    align-items: stretch;
}

.row-actions .btn {
    flex: 1 1 auto;
    min-width: min(100%, 140px);
}

.flash {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    border: 1px solid var(--line);
    font-size: 0.9375rem;
}

.flash--ok {
    border-color: color-mix(in srgb, var(--income) 45%, var(--line));
    background: var(--income-bg);
}

html.theme-dark .flash--ok {
    border-color: rgba(74, 222, 128, 0.45);
    background: linear-gradient(145deg, rgba(22, 163, 74, 0.28), rgba(21, 128, 61, 0.14));
    box-shadow: 0 0 28px rgba(52, 211, 153, 0.12);
    color: #ecfdf5;
}

.flash--err {
    border-color: color-mix(in srgb, var(--expense) 45%, var(--line));
    background: var(--expense-bg);
}

.tx-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tx-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    transition: border-color 0.15s ease;
}

.tx-item:hover {
    border-color: var(--line-strong);
}

html.theme-dark .tx-item {
    background: linear-gradient(160deg, rgba(30, 41, 59, 0.35), rgba(15, 23, 42, 0.48));
    border-color: var(--line-glass);
    backdrop-filter: blur(12px) saturate(1.1);
    -webkit-backdrop-filter: blur(12px) saturate(1.1);
}

html.theme-dark .tx-item:hover {
    border-color: rgba(167, 139, 250, 0.28);
}

.tx-item__meta {
    color: var(--muted);
    font-size: 0.8125rem;
}

.tx-item__amount--income {
    color: var(--income);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tx-item__amount--expense {
    color: var(--expense);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.pill {
    display: inline-block;
    padding: 5px 11px;
    border-radius: var(--radius-pill);
    font-size: 0.6875rem;
    font-weight: 600;
    background: var(--surface2);
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.chart {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chart__row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: center;
}

@media (min-width: 520px) {
    .chart__row {
        grid-template-columns: 1fr auto;
    }
}

.chart__bar-wrap {
    height: 11px;
    grid-column: 1 / -1;
    background: var(--surface2);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

@media (min-width: 520px) {
    .chart__bar-wrap {
        grid-column: auto;
        min-width: 100px;
    }
}

.chart__bar {
    height: 100%;
    border-radius: var(--radius-pill);
    transition: width 0.35s var(--ease-out);
}

.alert-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface2);
    font-size: 0.9375rem;
    line-height: 1.45;
}

.alert--warn {
    border-color: color-mix(in srgb, var(--warn) 50%, var(--line));
    background: color-mix(in srgb, var(--warn) 10%, var(--surface2));
}

.auth-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space);
    padding-bottom: max(var(--space), env(safe-area-inset-bottom));
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

.auth-card h1 {
    margin-top: 0;
}

.hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.divider {
    height: 1px;
    background: var(--line);
    margin: 24px 0;
}

/* Comparativo (dois meses ou dois anos) */
.compare-form-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr;
}

@media (min-width: 520px) {
    .compare-form-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.compare-fieldset {
    margin: 0;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface2);
}

.compare-legend {
    padding: 0 8px;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.compare-card__title {
    margin: 0 0 4px;
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.compare-card__hint {
    margin: 0 0 14px;
    font-size: 0.8125rem;
    color: var(--muted);
}

.compare-metrics {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.compare-metrics li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.compare-metrics li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.compare-metrics li:first-child {
    padding-top: 0;
}

.compare-metrics__k {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.compare-metrics__v {
    font-weight: 700;
    font-size: 1.05rem;
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
    margin-top: 8px;
}

.compare-table th,
.compare-table td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.compare-table thead th {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    border-bottom: 2px solid var(--line-strong);
}

.compare-table tbody th {
    font-weight: 600;
    color: var(--text);
}

.compare-table__num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.compare-delta--good {
    color: var(--income);
    font-weight: 600;
}

.compare-delta--bad {
    color: var(--expense);
    font-weight: 600;
}

.compare-delta--neutral {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Modal de confirmação (substitui alert/confirm nativo) */
.modal[hidden] {
    display: none !important;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space);
    padding-left: max(var(--space), env(safe-area-inset-left));
    padding-right: max(var(--space), env(safe-area-inset-right));
    padding-bottom: max(var(--space), env(safe-area-inset-bottom));
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal__box {
    position: relative;
    width: 100%;
    max-width: 400px;
    max-height: min(90vh, 100dvh);
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: clamp(18px, 4vw, 24px);
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.22s var(--ease-out);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .modal__box {
        animation: none;
    }
}

.modal__title {
    margin: 0 0 10px;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1.3;
}

.modal__body {
    margin: 0 0 20px;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.modal__actions {
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
}

@media (min-width: 420px) {
    .modal__actions {
        flex-direction: row;
        justify-content: flex-end;
    }
    .modal__actions .btn {
        flex: 0 0 auto;
        min-width: 120px;
    }
}

.modal__actions .btn[data-modal-ok].modal__btn--danger {
    background: linear-gradient(135deg, #b91c1c, var(--expense));
    box-shadow: 0 2px 12px var(--expense-bg);
}

.modal__actions .btn[data-modal-ok].modal__btn--danger:hover {
    filter: brightness(1.06);
}

/* ——— Dashboard: fundo do painel, calendário, donuts ——— */
.dashboard-main {
    position: relative;
    isolation: isolate;
}

.dashboard-main::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    /* Evita que o dashboard fique com fundo diferente das outras páginas */
    display: none;
}

html.theme-light .dashboard-main::before { display: none; }

.dashboard-main > * {
    position: relative;
    z-index: 1;
}

.dash-hero {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 16px;
    align-items: start;
}

@media (min-width: 960px) {
    .dash-hero {
        grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
        gap: 20px;
    }
}

.dash-hero__stats {
    min-width: 0;
}

/* Espaço entre os cards do topo (Entradas/Saídas/Insight) e "Agenda e lembretes" */
.dash-hero__stats .dash-agenda-wrap {
    margin-top: 14px;
}

.dash-hero__cal {
    min-width: 0;
    padding: 14px 12px 16px;
}

@media (min-width: 900px) {
    /* Insight deve ocupar a largura do grid (lado a lado com o calendário) */
    .dash-hero__insight {
        grid-column: 1 / -1;
    }

    /* Reduz fontes do calendário no desktop (compacto) para alinhar com os cards ao lado */
    .dash-hero__cal .dash-cal__wd {
        font-size: 0.55rem !important;
        letter-spacing: 0.04em;
    }

    .dash-hero__cal button.dash-cal__day {
        font-size: 0.62rem !important;
    }

    .dash-hero__cal .dash-cal--compact .dash-cal__day--compact .dash-cal__num {
        font-size: 0.70rem !important;
    }

    .dash-hero__cal .dash-cal__dot-more {
        font-size: 0.44rem !important;
    }

    .dash-hero__cal .dash-cal__ev-text {
        font-size: 0.52rem !important;
    }

    .dash-hero__cal button.dash-cal__day--compact {
        min-height: 44px !important;
        padding: 3px !important;
        gap: 4px !important;
    }
}

.dash-hero__cal-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 2px;
}

.dash-hero__cal-titles {
    min-width: 0;
}

.dash-cal-add-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: -4px -4px 0 0;
    padding: 0;
    border: 1px solid var(--line-glass, var(--line));
    border-radius: 12px;
    background: var(--surface2);
    color: var(--accent-hover, var(--accent));
    cursor: pointer;
    transition: background 0.15s ease, transform 0.12s var(--ease-out), border-color 0.15s ease;
}

.dash-cal-add-btn:hover {
    background: var(--surface);
    border-color: var(--accent-muted, var(--accent));
    transform: scale(1.04);
}

.dash-cal-add-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

html.theme-dark .dash-cal-add-btn {
    background: rgba(51, 65, 85, 0.45);
    border-color: rgba(148, 163, 184, 0.25);
    color: #a5b4fc;
}

.dash-hero__cal-title {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.dash-hero__cal-hint {
    margin: 0 0 10px;
    font-size: 0.8rem;
}

.dash-cal-legend--inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 10px;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--muted);
}

.dash-cal-legend--inline span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.dash-cal-legend--inline .dash-cal-dot {
    margin-right: 0;
    width: 6px;
    height: 6px;
}

.dash-fab {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 48;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-decoration: none;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 45%, #a855f7 100%);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
    transition: transform 0.15s var(--ease-out), filter 0.15s ease, box-shadow 0.2s ease;
}

.dash-fab:hover {
    filter: brightness(1.08);
    transform: scale(1.05);
    text-decoration: none;
    color: #fff;
    box-shadow: 0 12px 40px rgba(139, 92, 246, 0.5);
}

@media (max-width: 899px) {
    .app-body:has(.bottom-nav) .dash-fab {
        bottom: calc(var(--bottom-nav-h) + 14px + env(safe-area-inset-bottom, 0px));
    }
}

@media (min-width: 900px) {
    .dash-fab {
        right: max(24px, env(safe-area-inset-right));
        bottom: max(28px, env(safe-area-inset-bottom));
    }
}

.dash-day-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space);
}

.dash-day-modal[hidden] {
    display: none;
}

.dash-day-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
}

.dash-day-modal__box {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    max-height: min(80vh, 520px);
    overflow: auto;
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--line-glass, var(--line));
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

html.theme-dark .dash-day-modal__box {
    background: linear-gradient(160deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
}

.dash-day-modal__title {
    margin: 0 0 14px;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.dash-day-modal__list {
    list-style: none;
    margin: 0 0 18px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dash-day-modal__item {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-glass, var(--line));
    background: var(--surface2);
}

.dash-day-modal__tipo {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 4px;
}

.dash-day-modal__titulo {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.dash-day-modal__valor {
    font-size: 1rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.dash-agenda-modal__box {
    max-width: min(440px, 100%);
    max-height: min(90vh, 640px);
}

.dash-agenda-modal__actions {
    grid-column: 1 / -1;
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr 1fr;
    margin-top: 4px;
}

@media (max-width: 420px) {
    .dash-agenda-modal__actions {
        grid-template-columns: 1fr;
    }
}

.dash-cal-card .dash-cal-head {
    margin-bottom: 12px;
}

.dash-cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 20px;
    margin-bottom: 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
}

.dash-cal-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    box-shadow: 0 0 8px currentColor;
}

.dash-cal-dot--sub {
    background: #38bdf8;
    color: #38bdf8;
}

.dash-cal-dot--rec {
    background: #fb923c;
    color: #fb923c;
}

.dash-cal-dot--in {
    background: #4ade80;
    color: #4ade80;
}

.dash-cal-dot--plan {
    background: #a78bfa;
    color: #a78bfa;
}

.dash-cal {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.dash-cal__wd {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    padding: 6px 2px;
}

.dash-cal__pad {
    min-height: 1px;
}

button.dash-cal__day {
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    cursor: pointer;
    width: 100%;
    min-height: 72px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-glass, var(--line));
    background: var(--surface2);
    padding: 6px;
    font-size: 0.75rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    color: inherit;
}

button.dash-cal__day:hover {
    border-color: rgba(167, 139, 250, 0.4);
}

button.dash-cal__day:focus-visible {
    outline: 2px solid var(--accent-hover);
    outline-offset: 2px;
}

html.theme-dark button.dash-cal__day {
    background: linear-gradient(160deg, rgba(30, 41, 59, 0.35), rgba(15, 23, 42, 0.45));
}

.dash-cal--compact {
    gap: 4px;
}

.dash-cal--compact .dash-cal__wd {
    padding: 4px 1px;
    font-size: 0.6rem;
}

.dash-cal__day--compact {
    min-height: 48px !important;
    padding: 4px !important;
    gap: 4px;
}

.dash-cal__day--compact .dash-cal__num {
    font-size: 0.75rem;
    margin-bottom: 0;
}

.dash-cal__dots {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    align-items: center;
    justify-content: center;
}

.dash-cal__dots .dash-cal-dot {
    margin-right: 0;
    width: 5px;
    height: 5px;
    flex-shrink: 0;
}

.dash-cal__dot-more {
    font-size: 0.55rem;
    font-weight: 800;
    color: var(--accent-hover);
    line-height: 1;
}

.dash-cal__day--today {
    border-color: rgba(167, 139, 250, 0.55);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.15);
}

.dash-cal__num {
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--text);
    display: block;
    margin: 0;
    line-height: 1;
    text-align: center;
}

.dash-cal__events {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.dash-cal__ev {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.dash-cal__ev .dash-cal-dot {
    flex-shrink: 0;
    margin-right: 0;
    width: 6px;
    height: 6px;
    box-shadow: 0 0 6px currentColor;
}

.dash-cal__ev-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.65rem;
    color: var(--text-secondary);
    line-height: 1.2;
}

.dash-cal__more {
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--accent-hover);
    margin-top: 2px;
}

.dash-agenda-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
}

@media (min-width: 560px) {
    .dash-agenda-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.dash-agenda-list {
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dash-donut-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: clamp(12px, 3vw, 22px);
    margin-top: 8px;
}

.donut-wrap {
    flex: 0 0 auto;
}

.donut {
    position: relative;
    width: min(122px, 45vw);
    height: min(122px, 45vw);
}

.donut--empty {
    color: var(--muted);
}

.donut__svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: none;
}

.donut__segment {
    filter: none;
}

.donut__center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
    padding: 16%;
}

.donut__center-main {
    /* mais espaço interno quando o anel fica fino */
    font-size: clamp(0.74rem, 2.05vw, 0.88rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--text);
}

.donut__center-sub {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.donut__center-muted {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
}

.donut-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    min-width: min(100%, 140px);
}

.donut-legend__row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line-glass, var(--line));
    font-size: 0.875rem;
}

.donut-legend__row:last-child {
    border-bottom: none;
}

.donut-legend__swatch {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.2);
}

.donut-legend__name {
    flex: 1;
    min-width: 0;
    color: var(--text-secondary);
}

.donut-legend__pct {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.dash-chart-card {
    min-width: 0;
}

/* ——— Dashboard: Metas (Goals) ——— */
.dash-goals__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.dash-goals__left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.dash-goals__trophy {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    color: var(--accent-hover);
}

.dash-goals__trophy-img {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    display: block;
    object-fit: contain;
}

/* Troféu: preferir o SVG do arquivo (img) sobre qualquer SVG inline */
section.dash-goals-wrap .dash-goals__left > svg.dash-goals__trophy {
    display: none;
}

.dash-goals-grid {
    width: 100%;
    gap: 12px;
}

.dash-goal-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface2);
    padding: 14px 16px;
    box-shadow: none;
}

html.theme-dark .dash-goal-card {
    background: linear-gradient(160deg, rgba(30, 41, 59, 0.25), rgba(15, 23, 42, 0.35));
    border-color: var(--line-glass);
}

.dash-goal-title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.shop-item--done {
    opacity: 0.55;
}

.shop-item__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.shop-list-root .shop-save-state {
    min-height: 1.25em;
    margin: 0 0 10px;
    font-size: 0.8125rem;
    color: var(--muted);
}

.shop-save-state--err {
    color: #ef4444;
}

html.theme-dark .shop-save-state--err {
    color: #f87171;
}

.shop-add-grid {
    display: grid;
    gap: 12px;
    align-items: end;
    grid-template-columns: 1fr;
}

@media (min-width: 560px) {
    .shop-add-grid {
        grid-template-columns: minmax(140px, 2fr) minmax(72px, 0.55fr) minmax(120px, 1fr) auto;
    }
}

.shop-add-actions {
    display: flex;
    align-items: flex-end;
}

.tx-item.shop-row {
    align-items: flex-start;
}

.shop-row__main {
    flex: 1;
    min-width: 0;
}

.shop-row__fields {
    display: grid;
    gap: 10px;
    align-items: end;
    margin-top: 8px;
    grid-template-columns: minmax(64px, 0.9fr) minmax(100px, 1.1fr) auto;
}

.shop-row__fields .field {
    margin-bottom: 0;
}

.shop-field label {
    font-size: 0.75rem;
}

.shop-line-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 2px;
    text-align: right;
    min-width: 5.5rem;
}

.shop-line-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.shop-line-total {
    font-weight: 800;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.shop-items .shop-empty {
    list-style: none;
}

@media (max-width: 540px) {
    .shop-row__fields {
        grid-template-columns: 1fr 1fr;
    }

    .shop-line-wrap {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        text-align: left;
    }

    .tx-item.shop-row {
        flex-direction: column;
        align-items: stretch;
    }

    .shop-item__actions {
        justify-content: flex-start;
    }
}

/* ——— Painel admin (/admin/*): menu lateral + conteúdo em largura total ——— */
.app-body.admin-panel {
    --admin-sidebar-w: 268px;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: 100vh;
    min-height: 100dvh;
}

.admin-sidebar__backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 54;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.admin-sidebar__backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.admin-sidebar {
    width: var(--admin-sidebar-w);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background: color-mix(in srgb, rgba(15, 23, 42, 0.94) 92%, transparent);
    border-right: 1px solid var(--line-glass, var(--line));
    padding: 16px 14px 20px;
    padding-top: max(16px, env(safe-area-inset-top));
    box-sizing: border-box;
    z-index: 56;
}

html.theme-light .admin-sidebar {
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    border-right-color: var(--line);
}

.admin-sidebar__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 22px;
}

.admin-sidebar__brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-decoration: none;
    color: var(--text);
    min-width: 0;
}

.admin-sidebar__brand:hover {
    color: var(--accent);
}

.admin-sidebar__brand-name {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.admin-sidebar__brand-badge {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    opacity: 0.95;
}

.admin-sidebar__close-btn {
    display: none;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    background: var(--surface2);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.admin-sidebar__close-btn:hover {
    background: var(--surface-hover);
}

.admin-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.admin-sidebar__link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.admin-sidebar__link svg {
    flex-shrink: 0;
    opacity: 0.88;
}

.admin-sidebar__link:hover {
    background: var(--surface2);
    color: var(--text);
    text-decoration: none;
}

.admin-sidebar__link--secondary {
    font-weight: 450;
    opacity: 0.92;
}

.admin-sidebar__footer {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-sidebar__profile {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.admin-sidebar__avatar {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 35%, var(--surface2)), var(--surface2));
    border: 1px solid var(--line);
    color: var(--accent);
}

.admin-sidebar__avatar-svg {
    width: 26px;
    height: 26px;
}

.admin-sidebar__profile-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.admin-sidebar__profile-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.admin-sidebar__profile-email {
    font-size: 0.82rem;
    color: var(--text);
    word-break: break-word;
}

.admin-sidebar__logout {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin: 0;
}

.admin-shell {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.admin-topbar {
    display: none;
    align-items: center;
    gap: 14px;
    padding: 12px max(var(--space), env(safe-area-inset-right)) 12px max(var(--space), env(safe-area-inset-left));
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
}

.admin-topbar__menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    background: var(--surface2);
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.admin-topbar__menu-btn:hover {
    background: var(--surface-hover);
}

.admin-topbar__title {
    font-weight: 650;
    font-size: 1.05rem;
    color: var(--text);
}

.app-body.admin-panel .admin-panel__main {
    max-width: none;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
    flex: 1;
    padding-top: 20px;
    padding-bottom: 48px;
    padding-left: clamp(18px, 2.5vw, 40px);
    padding-right: clamp(18px, 2.5vw, 40px);
}

.app-body.admin-panel .main .card {
    max-width: none;
}

.app-body.admin-panel .admin-panel__form {
    max-width: 42rem;
}

@media (min-width: 1200px) {
    .app-body.admin-panel .admin-panel__form {
        max-width: 48rem;
    }
}

@media (max-width: 899px) {
    .admin-sidebar__backdrop.is-visible {
        display: block;
    }

    .admin-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.26s var(--ease-out, ease-out);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
    }

    .admin-sidebar.is-open {
        transform: translateX(0);
    }

    .admin-sidebar__close-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .admin-topbar {
        display: flex;
    }

    body.admin-sidebar-open {
        overflow: hidden;
    }
}

/* ——— Coach financeiro (Gemini): FAB + painel ——— */
/* Mesmo canto inferior direito do dash-fab; no dashboard, empilhado acima do "+" */
.finance-coach__fab {
    position: fixed;
    z-index: 47;
    right: max(16px, env(safe-area-inset-right, 0px));
    left: auto;
    bottom: max(20px, env(safe-area-inset-bottom, 0px));
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
    background: linear-gradient(145deg, #0ea5e9 0%, #6366f1 52%, #8b5cf6 100%);
    color: #fff;
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.15s var(--ease-out), filter 0.15s ease, box-shadow 0.2s ease;
}

.finance-coach__fab:hover {
    filter: brightness(1.06);
    transform: scale(1.05);
}

.finance-coach__fab:active {
    transform: scale(0.98);
}

@media (max-width: 899px) {
    .app-body:has(.bottom-nav) .finance-coach__fab {
        bottom: calc(var(--bottom-nav-h) + 14px + env(safe-area-inset-bottom, 0px));
    }

    /* Dashboard: acima do FAB "+" (mesma coluna à direita) */
    .app-body:has(.bottom-nav):has(.dash-fab) .finance-coach__fab {
        bottom: calc(var(--bottom-nav-h) + 14px + env(safe-area-inset-bottom, 0px) + 58px + 12px);
    }
}

@media (min-width: 900px) {
    .finance-coach__fab {
        right: max(24px, env(safe-area-inset-right, 0px));
        bottom: max(28px, env(safe-area-inset-bottom, 0px));
    }

    .app-body:has(.dash-fab) .finance-coach__fab {
        bottom: calc(max(28px, env(safe-area-inset-bottom, 0px)) + 58px + 12px);
    }
}

.finance-coach__backdrop {
    position: fixed;
    inset: 0;
    z-index: 88;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.finance-coach.is-open .finance-coach__backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.finance-coach__panel {
    position: fixed;
    z-index: 90;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(100%, 420px);
    max-width: 100%;
    background: var(--surface);
    border-left: 1px solid var(--line-glass, var(--line));
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px) 0;
    transform: translateX(104%);
    transition: transform 0.28s var(--ease-out);
    overflow: hidden;
}

html.theme-dark .finance-coach__panel {
    background: linear-gradient(165deg, rgba(30, 41, 59, 0.55), rgba(15, 23, 42, 0.92));
    backdrop-filter: blur(16px) saturate(1.1);
    -webkit-backdrop-filter: blur(16px) saturate(1.1);
}

.finance-coach.is-open .finance-coach__panel {
    transform: translateX(0);
}

body.finance-coach-lock {
    overflow: hidden;
}

.finance-coach__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--line-glass, var(--line));
    flex-shrink: 0;
}

.finance-coach__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.finance-coach__sub {
    margin: 6px 0 0;
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.45;
}

.finance-coach__close {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.finance-coach__quota {
    margin: 0;
    padding: 10px 16px 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

.finance-coach__actions {
    padding: 12px 16px;
    flex-shrink: 0;
}

.finance-coach__output {
    flex: 1;
    overflow: auto;
    padding: 8px 16px 20px;
    -webkit-overflow-scrolling: touch;
}

.finance-coach__pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text);
}

.finance-coach__chat {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    max-width: 100%;
}

.finance-coach__bubble {
    max-width: 100%;
    border-radius: 14px 14px 14px 4px;
    padding: 12px 14px;
    background: var(--surface2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.finance-coach__bubble--assistant {
    align-self: flex-start;
}

.finance-coach__typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px 0 8px;
    min-height: 28px;
}

.finance-coach__typing-indicator.is-hidden {
    display: none;
}

.finance-coach__typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
    opacity: 0.45;
    animation: finance-coach-dot 1.1s ease-in-out infinite;
}

.finance-coach__typing-indicator span:nth-child(2) {
    animation-delay: 0.15s;
}

.finance-coach__typing-indicator span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes finance-coach-dot {
    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    40% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

.finance-coach__typing-pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--text);
}

.finance-coach__bubble-body {
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--text);
}

.finance-coach__bubble-inner > *:first-child {
    margin-top: 0;
}

.finance-coach__bubble-inner > *:last-child {
    margin-bottom: 0;
}

.finance-coach__title {
    margin: 0 0 10px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.finance-coach__section {
    margin: 14px 0 8px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.finance-coach__section:first-child {
    margin-top: 0;
}

.finance-coach__para {
    margin: 0 0 10px;
}

.finance-coach__list {
    margin: 0 0 6px;
    padding-left: 1.15rem;
}

.finance-coach__list li {
    margin: 0 0 6px;
}

.finance-coach__feedback {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.finance-coach__feedback[hidden] {
    display: none !important;
}

.finance-coach__feedback-label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-right: 4px;
}

.finance-coach__fb-btn {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: var(--surface);
    border-radius: 10px;
    padding: 6px 12px;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease;
}

.finance-coach__fb-btn:hover:not(:disabled) {
    background: var(--surface2);
    transform: scale(1.05);
}

.finance-coach__fb-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.finance-coach__feedback-thanks {
    font-size: 0.82rem;
    color: var(--muted);
    width: 100%;
}

.finance-coach__feedback.is-sent .finance-coach__feedback-label {
    display: none;
}

@media print {
    .admin-sidebar,
    .admin-sidebar__backdrop,
    .admin-topbar,
    .topbar,
    .sidebar,
    .topbar__sidebar-open,
    .footer,
    .bottom-nav,
    .nav-toggle,
    .no-print,
    .skip-link,
    .modal,
    .dash-fab,
    .dash-day-modal,
    .finance-coach {
        display: none !important;
    }
    .app-shell {
        margin-left: 0 !important;
    }
    body {
        padding-bottom: 0 !important;
        background: #fff;
        color: #000;
    }
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
