/* ── Native-feel layer: scrollbars, dialogs, merged business dashboard ───────────── */

/* Styled scrollbars (modals, dialogs, menus and alerts). */
:root { --scroll-thumb: rgba(100, 116, 139, .38); --scroll-thumb-active: rgba(100, 116, 139, .6); }
[data-theme="dark"] { --scroll-thumb: rgba(148, 163, 184, .28); --scroll-thumb-active: rgba(148, 163, 184, .5); }
.modal, .financial-account-dialog, .tutorial-dialog, .app-menu-dropdown, .app-dialog .malert-content {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
    overscroll-behavior: contain;
}
.modal::-webkit-scrollbar, .financial-account-dialog::-webkit-scrollbar, .tutorial-dialog::-webkit-scrollbar,
.app-menu-dropdown::-webkit-scrollbar, .app-dialog .malert-content::-webkit-scrollbar { width: 5px; height: 5px; }
.modal::-webkit-scrollbar-track, .financial-account-dialog::-webkit-scrollbar-track, .tutorial-dialog::-webkit-scrollbar-track,
.app-menu-dropdown::-webkit-scrollbar-track, .app-dialog .malert-content::-webkit-scrollbar-track { background: transparent; margin: 18px 0; }
.modal::-webkit-scrollbar-thumb, .financial-account-dialog::-webkit-scrollbar-thumb, .tutorial-dialog::-webkit-scrollbar-thumb,
.app-menu-dropdown::-webkit-scrollbar-thumb, .app-dialog .malert-content::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 99px; }
.modal::-webkit-scrollbar-thumb:active, .financial-account-dialog::-webkit-scrollbar-thumb:active,
.app-menu-dropdown::-webkit-scrollbar-thumb:active { background: var(--scroll-thumb-active); }
.modal::-webkit-scrollbar-button, .financial-account-dialog::-webkit-scrollbar-button,
.app-menu-dropdown::-webkit-scrollbar-button { display: none; height: 0; }

/* New / updated entry highlight in the list. */
@keyframes entry-flash { 0%, 35% { box-shadow: 0 0 0 2px var(--accent-blue); background: var(--accent-blue-soft); } 100% { box-shadow: var(--shadow-sm); } }
.transaction-item.just-added { animation: entry-flash 1.8s ease-out; }
@media (prefers-reduced-motion: reduce) { .transaction-item.just-added { animation: none; outline: 2px solid var(--accent-blue); } }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Merged business dashboard (replaces the month balance card in business mode) ──
   Same light-blue gradient and colours as the app's balance card. */
body.business-mode, [data-theme="dark"] body.business-mode { background: var(--bg-primary); }
body.business-mode .balance-card.monthly-card { display: none; }
body .business-dashboard {
    --dash-text: var(--text-primary); --dash-muted: var(--text-secondary);
    --dash-glass: rgba(255, 255, 255, .62); --dash-line: rgba(37, 99, 235, .14); --dash-track: rgba(37, 99, 235, .12);
    position: relative; overflow: hidden; color: var(--dash-text);
    background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 60%, #e0e7ff 100%);
    border: 0; border-radius: var(--radius-xl); padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow-md);
}
[data-theme="dark"] body .business-dashboard {
    --dash-glass: rgba(255, 255, 255, .05); --dash-line: rgba(255, 255, 255, .08); --dash-track: rgba(255, 255, 255, .1);
    background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 60%, #1e1a3f 100%);
}
body .business-dashboard::before {
    content: ''; position: absolute; top: -40%; right: -20%; width: 60%; height: 120%; pointer-events: none;
    background: radial-gradient(ellipse, rgba(255, 255, 255, .15) 0%, transparent 70%);
}
body .business-dashboard > * { position: relative; }
body .business-dashboard[hidden] { display: none; }
.business-dashboard .business-heading { align-items: flex-start; margin-bottom: 6px; }
.business-dashboard .business-eyebrow { color: var(--accent-blue); letter-spacing: .14em; }
.business-dashboard .business-heading h2 { font-size: .75rem; text-transform: uppercase; letter-spacing: 1.2px; font-weight: 600; color: var(--dash-muted); }
.business-dashboard .business-date { color: var(--dash-muted); font-size: .68rem; }
body .business-dashboard #businessWorkDate {
    width: 140px; min-height: 38px; padding: 6px 10px; font-size: .8rem; border-radius: 10px;
    background: var(--dash-glass); color: var(--dash-text); border: 1px solid var(--dash-line);
}
.business-profit-amount { font-family: 'Space Mono', monospace; font-size: 2rem; font-weight: 700; line-height: 1.1; margin: 4px 0 18px; overflow-wrap: anywhere; }
.business-profit-amount.positive { color: var(--accent-green); }
.business-profit-amount.negative { color: var(--accent-red); }

.business-dashboard .business-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.business-dashboard .business-metric {
    display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px; border-radius: 14px;
    background: var(--dash-glass); border: 1px solid var(--dash-line); color: var(--dash-text);
}
.business-dashboard .business-metric > div { display: grid; gap: 2px; min-width: 0; }
.business-dashboard .business-metric span:not(.business-metric-icon) { font-size: .66rem; color: var(--dash-muted); line-height: 1.25; }
.business-dashboard .business-metric strong { font-family: 'Space Mono', monospace; font-size: .86rem; overflow-wrap: anywhere; line-height: 1.25; }
.business-metric-icon { flex: 0 0 28px; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-size: .72rem; }
.business-metric.income .business-metric-icon { background: var(--accent-green-soft); color: var(--accent-green); }
.business-metric.expense .business-metric-icon { background: var(--accent-red-soft); color: var(--accent-red); }
.business-metric.count .business-metric-icon { background: var(--accent-blue-soft); color: var(--accent-blue); }

.business-dashboard .business-goal { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--dash-line); border-radius: 14px; background: var(--dash-glass); }
.business-dashboard .goal-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.business-dashboard .goal-heading h3 { font-size: .78rem; color: var(--dash-text); }
.business-dashboard .goal-heading strong { font-family: 'Space Mono', monospace; font-size: .8rem; color: var(--dash-text); }
.business-dashboard .business-goal.empty .goal-heading strong { font-family: inherit; font-weight: 500; color: var(--dash-muted); }
.goal-track { height: 8px; border-radius: 99px; background: var(--dash-track); overflow: hidden; margin-top: 10px; }
.goal-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent-blue), var(--accent-green)); transition: width .5s ease; }
.business-goal.reached .goal-track span { background: var(--accent-green); }
body .business-dashboard .goal-status { margin: 8px 0 0; font-size: .74rem; color: var(--dash-muted); }
.business-goal.reached .goal-status { color: var(--accent-green); font-weight: 700; }

.business-month { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--dash-line); }
.business-month-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.business-month-heading span { font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; font-weight: 600; color: var(--dash-muted); }
.business-month-heading strong { font-family: 'Space Mono', monospace; font-size: 1.05rem; }
.business-month-heading strong.positive { color: var(--accent-green); }
.business-month-heading strong.negative { color: var(--accent-red); }

body .business-dashboard .quick-access-title { color: var(--dash-text); font-size: .8rem; margin-top: 16px; }
body .business-dashboard .business-shortcuts button {
    overflow-wrap: normal; word-break: normal; hyphens: auto; line-height: 1.25; padding: 8px 6px;
    background: var(--dash-glass); color: var(--accent-blue); border: 1px solid var(--dash-line); border-radius: 12px; min-height: 44px; font-size: .76rem; font-weight: 700;
}
body .business-dashboard .business-shortcuts button:hover { background: var(--accent-blue-soft); border-color: var(--accent-blue); }
body .business-dashboard .business-note { color: var(--dash-muted); font-size: .7rem; line-height: 1.6; }
@media (max-width: 360px) {
    body .business-dashboard { padding: 16px; }
    .business-dashboard .business-metrics { grid-template-columns: 1fr 1fr; }
    .business-dashboard .business-metric.count { grid-column: 1 / -1; }
    .business-profit-amount { font-size: 1.7rem; }
}

/* Goal field inside the account dialog. */
#financialGoalGroup[hidden] { display: none; }
#financialGoalGroup { margin-top: 4px; padding: 14px; border-radius: 14px; background: var(--accent-blue-soft); border: 1px solid var(--border-color); }
#financialGoalGroup label { margin-top: 10px; font-weight: 600; }
.account-goal-title { font-size: .95rem; margin-bottom: 2px; }
.account-goal-hint { font-size: .78rem; color: var(--text-secondary); line-height: 1.5; margin-top: 8px; }
.account-goal-status { font-size: .78rem; font-weight: 600; color: var(--accent-green); min-height: 1.2em; margin-top: 4px; }
.account-goal-status.error { color: var(--accent-red); }
.account-goal-status:empty { display: none; }

/* ── MAlert as a native-looking dialog ───────────────────────────────────── */
.app-dialog { background: rgba(15, 23, 42, .5) !important; font-family: 'DM Sans', system-ui, sans-serif !important; -webkit-tap-highlight-color: transparent; }
.app-dialog .mAlertModal {
    background: var(--bg-card) !important; color: var(--text-primary) !important;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .28) !important; border-radius: 24px !important;
    width: min(340px, calc(100vw - 48px)) !important; max-width: none !important;
    padding: 24px 22px 16px !important; text-align: left !important; font-size: 15px !important;
}
.app-dialog .mAlertModal h2 { color: var(--text-primary) !important; font-family: inherit; font-size: 1.15rem !important; font-weight: 700 !important; margin-bottom: 4px !important; overflow-wrap: anywhere; }
.app-dialog .malert-content { text-align: left !important; color: var(--text-secondary) !important; margin: 6px 0 14px !important; padding-right: 2px !important; }
.app-dialog-message { font-size: .95rem; line-height: 1.55; color: var(--text-secondary); overflow-wrap: anywhere; }
.app-dialog .malert-buttons { justify-content: flex-end !important; gap: 8px !important; margin-top: 4px !important; }
.app-dialog .malert-btn {
    font-family: inherit !important; font-size: .9rem !important; font-weight: 700; min-height: 44px; padding: 10px 18px !important;
    border-radius: 99px !important; border: 0 !important; transition: background .15s ease, transform .1s ease !important; opacity: 1 !important;
}
.app-dialog .malert-btn:active { transform: scale(.97); }
.app-dialog .app-dialog-secondary { background: transparent !important; color: var(--accent-blue) !important; }
.app-dialog .app-dialog-secondary:hover { background: var(--accent-blue-soft) !important; }
.app-dialog .app-dialog-primary { background: var(--accent-blue) !important; color: #fff !important; }
.app-dialog .app-dialog-danger { background: var(--accent-red) !important; color: #fff !important; }
.app-dialog .malert-btn:focus-visible { outline: 3px solid var(--accent-blue) !important; outline-offset: 2px; }

/* ── App icon (assets/images/ic.png) ─────────────────────────────────── */
img.app-logo { display: block; width: 84px; height: 84px; object-fit: contain; margin: 0 auto 10px; font-size: 0; }
.startup-screen img.app-logo { margin-bottom: 0; }
img.brand-symbol { display: inline-block; vertical-align: middle; width: 36px; height: 36px; object-fit: contain; background: none; border-radius: 0; margin: -6px 4px 0 -4px; padding: 0; }

/* ── Signed-in user, shown only inside the menu ───────────────────────── */
#appMenuDropdown #userBadge.menu-user, .app-menu-dropdown .menu-user {
    justify-content: flex-start; max-width: none !important;
    display: flex; align-items: center; gap: 10px; width: 100%; margin: 0 0 6px; padding: 12px;
    border: 0; border-radius: 12px; box-shadow: none; background: var(--bg-elevated);
    color: var(--text-primary); font-size: .92rem; font-weight: 700; max-width: none;
}
.app-menu-dropdown .menu-user i {
    display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent-blue-soft); color: var(--accent-blue); font-size: .85rem;
}
.app-menu-dropdown .menu-user #userName { max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Category grid: "show more" (no collapse) ───────────────────────── */
.category-more-btn {
    grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
    border: 1px dashed var(--border-color); border-radius: var(--radius-md); background: transparent;
    color: var(--accent-blue); font: inherit; font-size: .82rem; font-weight: 700; cursor: pointer;
}
.category-more-btn:hover { background: var(--accent-blue-soft); }

/* ── Monthly view: "Transações" | "Despesas" switch below the balance/business card ── */
.month-panel-tabs {
    display: flex; gap: 4px; padding: 4px; margin: 4px 0 14px;
    background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 99px;
}
.month-panel-tab {
    flex: 1; min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 7px;
    border: 0; border-radius: 99px; background: transparent; color: var(--text-secondary);
    font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer; transition: background .2s, color .2s, box-shadow .2s;
}
.month-panel-tab i { font-size: .8rem; }
.month-panel-tab.active { background: var(--bg-card); color: var(--accent-blue); box-shadow: var(--shadow-sm); }
.month-panel-tab:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 2px; }
.month-panel[hidden] { display: none; }
.income-ranking .ranking-bar span, .income-ranking .ranking-bar > span { background: var(--accent-green) !important; }
.month-panel .month-category-title { margin-top: 18px; }
.month-panel-tab { font-size: .8rem; gap: 5px; padding: 0 6px; }

/* ── One standard for every modal <dialog> (tutorial, account settings) ─────
   The global "* { margin: 0 }" reset removed the browser's centring, so the
   tutorial opened in the top-left corner. Both dialogs now share this style. */
dialog.tutorial-dialog, dialog.financial-account-dialog {
    position: fixed; inset: 0; margin: auto; height: fit-content; box-sizing: border-box;
    width: min(440px, calc(100vw - 32px)); max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px);
    padding: 24px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: 24px;
    background: var(--bg-card); color: var(--text-primary); box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
}
dialog.tutorial-dialog[open], dialog.financial-account-dialog[open] { animation: app-dialog-in .2s ease-out; }
dialog.tutorial-dialog::backdrop, dialog.financial-account-dialog::backdrop { background: rgba(15, 23, 42, .5); }
@keyframes app-dialog-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { dialog.tutorial-dialog[open], dialog.financial-account-dialog[open] { animation: none; } }
dialog.tutorial-dialog h2, dialog.financial-account-dialog h2 { font-size: 1.25rem; font-weight: 700; margin: 8px 0 12px; }
dialog.tutorial-dialog p { color: var(--text-secondary); line-height: 1.6; margin-bottom: 22px; }
dialog.tutorial-dialog [data-progress] { color: var(--text-muted); font-size: .8rem; font-weight: 600; }
.tutorial-actions { gap: 10px; }
dialog.tutorial-dialog .tutorial-actions button, dialog.financial-account-dialog .account-dialog-actions button {
    min-height: 44px; padding: 10px 18px; border-radius: 99px; font: inherit; font-weight: 700; cursor: pointer;
}
dialog.tutorial-dialog [data-back] { background: transparent; color: var(--accent-blue); border: 1px solid var(--border-color); }
dialog.tutorial-dialog [data-next], body dialog.financial-account-dialog [data-create] { background: var(--accent-blue); color: #fff; border: 1px solid transparent; }
body dialog.financial-account-dialog [data-cancel] { background: transparent; color: var(--accent-blue); border: 1px solid var(--border-color); }
dialog.tutorial-dialog [data-skip] { background: transparent; color: var(--text-secondary); border: 0; padding: 10px; min-height: 44px; }
dialog.tutorial-dialog button:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 2px; }

/* ── History tab: search + filters ─────────────────────────────────── */
.history-search { margin-bottom: 22px; }
.history-search-bar {
    display: flex; align-items: center; gap: 10px; padding: 0 6px 0 16px; min-height: 52px;
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 99px; box-shadow: var(--shadow-sm);
}
.history-search-bar:focus-within { border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--accent-blue-soft); }
.history-search-bar > i { color: var(--text-muted); }
body .history-search-bar input {
    flex: 1; min-width: 0; border: 0 !important; background: transparent !important; box-shadow: none !important;
    padding: 12px 0 !important; font-size: 16px; color: var(--text-primary); outline: none;
}
.history-search-bar input::-webkit-search-cancel-button { display: none; }
body .history-search-bar input:focus-visible { outline: none; }
.history-search-clear { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--bg-elevated); color: var(--text-secondary); cursor: pointer; }
.history-search-clear[hidden] { display: none; }
.history-toolbar { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.history-filter-toggle {
    display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 8px 16px; border-radius: 99px;
    border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.history-filter-toggle[aria-expanded="true"] { border-color: var(--accent-blue); color: var(--accent-blue); background: var(--accent-blue-soft); }
.history-filter-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent-blue); color: #fff; font-size: .7rem; }
.history-filter-count[hidden] { display: none; }
.history-sort { margin-left: auto; }
body .history-sort select { min-height: 42px; border-radius: 99px; padding: 8px 14px; font-size: .85rem; width: auto; }
.history-filters {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; padding: 16px;
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 18px; box-shadow: var(--shadow-sm);
}
.history-filters[hidden] { display: none; }
.history-filters label { display: grid; gap: 6px; min-width: 0; font-size: .78rem; font-weight: 600; color: var(--text-secondary); }
.history-filters input, .history-filters select { width: 100%; min-width: 0; }
.history-wide { grid-column: 1 / -1; }
.history-reset { min-height: 44px; border-radius: 99px; border: 1px solid var(--border-color); background: transparent; color: var(--accent-blue); font: inherit; font-weight: 700; cursor: pointer; }
.history-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.history-chips:empty { display: none; }
.history-chip {
    display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 6px 12px; border-radius: 99px;
    border: 0; background: var(--accent-blue-soft); color: var(--accent-blue); font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer;
}
.history-summary { margin: 14px 2px 10px; font-size: .8rem; color: var(--text-secondary); line-height: 1.6; }
.history-summary strong { color: var(--text-primary); }
.history-summary .income { color: var(--accent-green); font-weight: 700; }
.history-summary .expense { color: var(--accent-red); font-weight: 700; }
.history-more { width: 100%; min-height: 46px; margin-top: 10px; border-radius: 99px; border: 1px dashed var(--border-color); background: transparent; color: var(--accent-blue); font: inherit; font-weight: 700; cursor: pointer; }
.history-more[hidden] { display: none; }
.history-years-title { margin-top: 8px; }
.history-filter-toggle:focus-visible, .history-chip:focus-visible, .history-more:focus-visible, .history-reset:focus-visible, .history-search-clear:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 2px; }
@media (max-width: 340px) { .history-filters { grid-template-columns: 1fr; } }
.history-search-hint { margin: 8px 6px 0; font-size: .74rem; color: var(--text-muted); line-height: 1.5; }
.share-link-box { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--bg-elevated); color: var(--accent-blue); font-weight: 700; font-size: .9rem; word-break: break-all; user-select: all; -webkit-user-select: all; }
