@font-face { font-family: 'Poppins PFM'; font-weight: 700; font-style: normal; font-display: swap; src: url('../fonts/poppins-bold-latin.woff') format('woff'); }
:root {
  --md-sys-color-primary: #1a73e8;
  --md-sys-color-surface: #fdfbff;
  font-family: Roboto, system-ui, sans-serif;
}
body { margin: 0; background: var(--md-sys-color-surface); color: #1b1b1f; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 24px; background: #e8f0fe; }
.privacy { color: #44474e; flex: 1; text-align: right; }
main { max-width: 960px; margin: 24px auto; padding: 0 16px; display: grid; gap: 24px; }
.dropzone { border: 2px dashed #747780; border-radius: 28px; padding: 40px 16px; text-align: center; display: grid; gap: 8px; justify-items: center; transition: background .15s; }
.dropzone.over { background: #d3e3fd; border-color: var(--md-sys-color-primary); }
.big { font-size: 48px; color: var(--md-sys-color-primary); }
.card { background: #f1f3f9; border-radius: 16px; padding: 16px; }
.card > h3 { margin: 0 0 12px; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #e0e2ec; }
.neg { color: #1e8e3e; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.status p { margin: 4px 0; }

.muted { color: #44474e; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pills:empty { display: none; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 4px 4px 4px 14px; border-radius: 16px; background: #d3e3fd; font-size: 14px; }
.pill-v { font-weight: 500; }
.pill-x { border: 0; background: transparent; width: 24px; height: 24px; border-radius: 50%; font-size: 18px; line-height: 1; cursor: pointer; color: #44474e; }
.pill-x:hover, .pill-x:focus-visible { background: rgba(0,0,0,.12); }
.summary { display: grid; gap: 16px; }
.summary:empty, .subs:empty { display: none; }
.total { display: grid; gap: 4px; }

.logo { flex: none; width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; overflow: hidden; font-size: 13px; font-weight: 700; }
.logo svg { width: 20px; height: 20px; }
.logo-cat { background: color-mix(in srgb, var(--c, #80868b) 16%, white); color: var(--c, #80868b); }
.logo-cat .material-symbols-outlined { font-size: 20px; }

.cat { border-bottom: 1px solid #e0e2ec; }
.cat:last-child { border-bottom: 0; }
.cat summary { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; list-style: none; }
.cat summary::-webkit-details-marker { display: none; }
.cat-main { flex: 1; min-width: 0; display: grid; gap: 6px; }
.cat-name { font-weight: 500; }
.bar { display: block; height: 6px; border-radius: 3px; background: #e0e2ec; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--c); }
.cat-val { text-align: right; display: grid; font-weight: 500; white-space: nowrap; }
.cat-val small, .tx small { color: #44474e; font-weight: 400; }
.cat[open] summary { border-bottom: 0; }
.tx { display: flex; align-items: center; gap: 12px; padding: 8px 4px; }
.tx-main { flex: 1; min-width: 0; display: grid; }
.tx-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-val { white-space: nowrap; }
.tx .logo { width: 32px; height: 32px; }

.danger { --md-text-button-label-text-color: #b3261e; --md-text-button-icon-color: #b3261e; --md-text-button-hover-label-text-color: #b3261e; --md-text-button-hover-icon-color: #b3261e; --md-text-button-focus-label-text-color: #b3261e; --md-text-button-focus-icon-color: #b3261e; --md-text-button-pressed-label-text-color: #b3261e; --md-text-button-pressed-icon-color: #b3261e; }

/* Lançamentos da categoria: bandeja clara (surface-container-lowest) sobre o card, com filete na cor da categoria */
.cat-items { background: #fff; border-radius: 12px; border-left: 4px solid var(--c); padding: 4px 12px; margin: 0 0 12px 48px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.cat-items .tx + .tx { border-top: 1px solid #eef0f6; }
@media (max-width: 520px) { .cat-items { margin-left: 0; } }
.cat-val { min-width: 112px; }

/* Ampulheta animada enquanto lê (OCR demora) */
.hourglass { font-size: 20px; vertical-align: -4px; animation: flip 1.6s ease-in-out infinite; }
@keyframes flip { 0%, 40% { transform: rotate(0); } 60%, 100% { transform: rotate(180deg); } }
@media (prefers-reduced-motion: reduce) { .hourglass { animation: none; } }

/* Modal de senha (md-dialog) */
.pwd-content { display: grid; gap: 16px; min-width: min(320px, 70vw); }
.pwd-content p { margin: 0; }

/* Linha selecionável / editável */
.tx { cursor: pointer; border-radius: 8px; transition: background .15s; }
.tx:hover { background: #f4f6fb; }
.tx.selected { background: #d3e3fd; }
.tx:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: -2px; }
.tx-edit { flex: none; width: 0; height: 32px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--md-sys-color-primary); overflow: hidden; opacity: 0; cursor: pointer; display: grid; place-items: center; transition: width .18s ease, opacity .18s ease, margin .18s ease; margin-left: -12px; }
.tx.selected .tx-edit { width: 32px; opacity: 1; margin-left: 0; }
.tx-edit:hover, .tx-edit:focus-visible { background: rgba(26,115,232,.14); }
.tx-edit .material-symbols-outlined { font-size: 20px; }
@media (prefers-reduced-motion: reduce) { .tx, .tx-edit { transition: none; } }

/* Modal de edição */
.ed-content { display: grid; gap: 12px; min-width: min(360px, 78vw); margin: 0; }
.ed-top { display: flex; align-items: center; gap: 16px; }
.ed-top md-outlined-text-field { flex: 1; }
.ed-icon { position: relative; flex: none; width: 56px; height: 56px; border: 0; padding: 0; background: transparent; cursor: pointer; border-radius: 50%; }
.ed-icon .logo { width: 56px; height: 56px; }
.ed-icon .logo svg { width: 30px; height: 30px; }
.ed-icon .logo .material-symbols-outlined { font-size: 30px; }
.ed-pencil { position: absolute; top: -2px; right: -2px; width: 22px; height: 22px; border-radius: 50%; background: var(--md-sys-color-primary); color: #fff; font-size: 14px; display: grid; place-items: center; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.ed-icon:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: 2px; }
.ed-orig, #edOrig { margin: 0; }
.ed-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; max-height: 176px; overflow: auto; padding: 8px; background: #f1f3f9; border-radius: 12px; }
.ed-picker[hidden] { display: none; }
.ed-pick { height: 44px; border: 2px solid transparent; border-radius: 12px; background: #fff; cursor: pointer; display: grid; place-items: center; color: #44474e; }
.ed-pick:hover, .ed-pick:focus-visible { background: #e8f0fe; }
.ed-pick[aria-pressed="true"] { border-color: var(--md-sys-color-primary); color: var(--md-sys-color-primary); }
.ed-pick-default { font-size: 11px; font-weight: 500; line-height: 1.1; }
.ed-cat { display: grid; gap: 4px; }
.ed-cat-row { display: flex; gap: 8px; align-items: center; }
.ed-cat input { flex: 1; min-width: 0; font: inherit; padding: 14px 16px; border: 1px solid #747780; border-radius: 4px; background: transparent; color: inherit; }
.ed-cat input:focus { outline: 2px solid var(--md-sys-color-primary); outline-offset: -1px; border-color: transparent; }
.ed-add { flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--md-sys-color-primary); color: #fff; cursor: pointer; display: grid; place-items: center; }
.ed-add[hidden] { display: none; }

.ed-combo { position: relative; flex: 1; min-width: 0; }
.ed-combo input { width: 100%; box-sizing: border-box; padding-right: 44px; }
.ed-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; cursor: pointer; display: grid; place-items: center; color: #44474e; }
.ed-toggle:hover { background: rgba(0,0,0,.08); }
.ed-list { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px 0; list-style: none; max-height: 200px; overflow: auto; background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.ed-list[hidden] { display: none; }
.ed-list li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; cursor: pointer; }
.ed-list li:hover, .ed-list li[aria-selected="true"] { background: #e8f0fe; }
.ed-list .material-symbols-outlined { font-size: 20px; }
.ed-toggle { overflow: hidden; } .ed-toggle .material-symbols-outlined { width: 24px; overflow: hidden; }

.app-version { max-width: 960px; margin: 0 auto 16px; padding: 0 16px; text-align: right; color: #747780; }

/* Marca: só o ícone no celular; ícone + nome no computador */
.brand { margin: 0; font: inherit; }
.brand a { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: #0b3a8c; }
.brand img { display: block; width: 36px; height: 36px; border-radius: 9px; }
.brand-name { font-family: 'Poppins PFM', Poppins, system-ui, sans-serif; font-weight: 700; font-size: 26px; letter-spacing: .5px; line-height: 1; }
/* Fora de vista mas lido por leitores de tela: o h1 sempre tem o nome completo */
.sr-hide { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 599px) { .brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } }

/* Lista de categorias: na camada superior (popover), então não é cortada pelo modal */
.ed-list { position: fixed; inset: auto; margin: 0; z-index: 10; border: 0; box-sizing: border-box; }
.ed-list:not(:popover-open):not(.inline-open) { display: none; }
.ed-list.inline-open { position: static; display: block; width: auto !important; margin-top: 4px; }
@supports not selector(:popover-open) { .ed-list:not(.inline-open) { display: none; } }

/* Histórico por mês */
.months:empty { display: none; }
.months h3 { margin: 0 0 12px; }
.month-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.month { flex: none; scroll-snap-align: start; min-width: 104px; display: grid; gap: 6px; padding: 10px 12px; border: 1px solid #c4c6d0; border-radius: 12px; background: #fff; cursor: pointer; font: inherit; color: inherit; text-align: left; }
.month:hover { background: #f4f6fb; }
.month[aria-pressed="true"] { background: #d3e3fd; border-color: var(--md-sys-color-primary); }
.month small { color: #44474e; }
.month b { font-weight: 500; white-space: nowrap; }
.month .bar { height: 6px; }
.month .bar i { background: var(--md-sys-color-primary); }

/* Gráficos */
.charts:empty { display: none; }
.charts { display: grid; gap: 16px; }
.charts h3 { margin: 0 0 12px; }
.donut { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px; }
.donut-svg { width: 200px; height: 200px; flex: none; margin: 0 auto; }
.donut-lbl { font-size: 11px; fill: #44474e; }
.donut-tot { font-size: 16px; font-weight: 500; fill: #1b1b1f; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; flex: 1; min-width: 180px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend i { flex: none; width: 12px; height: 12px; border-radius: 3px; }
.legend span { flex: 1; }
.legend-inline { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; flex: none; }
.legend-inline span { flex: none; font-size: 13px; }
.chart-scroll { overflow-x: auto; }
.chart-svg { display: block; }
.chart-lbl { font-size: 11px; fill: #44474e; }
.chart-val { font-size: 10px; fill: #1b1b1f; }
.bar-col { cursor: pointer; }
.bar-col:hover rect:not([fill="transparent"]), .bar-col.sel rect:not([fill="transparent"]) { opacity: .8; }
.bar-col.sel .chart-lbl { font-weight: 700; fill: var(--md-sys-color-primary); }
.bar-col:focus-visible { outline: 2px solid var(--md-sys-color-primary); }
.month.current { border-width: 2px; border-color: var(--md-sys-color-primary); padding: 9px 11px; }
.month.current small { color: var(--md-sys-color-primary); font-weight: 500; }
.brand-full { font-family: 'Poppins PFM', Poppins, system-ui, sans-serif; font-weight: 500; font-size: 19px; letter-spacing: 0; margin-left: -6px; }
@media (max-width: 859px) { .brand-full { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } }

/* Desktop: os dois gráficos lado a lado */
.charts .card { min-width: 0; }
.charts .donut .legend { max-width: 300px; }
.chart-svg { margin: 0; }
@media (min-width: 860px) {
  .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
  .charts > .card:only-child { grid-column: 1 / -1; }
  .charts .donut { flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 16px 24px; }
  .charts .donut-svg { margin: 0; width: 190px; height: 190px; }
}
/* Legenda da pizza: cor | nome | % colados, em colunas alinhadas */
.donut .legend { grid-template-columns: 12px auto auto; justify-content: start; align-items: center; gap: 6px 10px; flex: none; }
.donut .legend li { display: contents; }
.donut .legend span { flex: none; }
.donut .legend b { font-weight: 500; text-align: right; }

/* Mobile: a rolagem do histórico fica dentro do cartão (que não passa da largura da tela); % da legenda à direita */
main > * { min-width: 0; }
.months .card { min-width: 0; max-width: 100%; box-sizing: border-box; }
.month-list { max-width: 100%; }
@media (max-width: 859px) {
  .donut .legend, .charts .donut .legend { grid-template-columns: 12px 1fr auto; width: 100%; max-width: none; flex: 1 1 100%; }
}

/* Destaque da fatia (hover no desktop, toque no celular) */
.slice { transition: transform .15s ease, opacity .15s ease; transform-origin: 100px 100px; cursor: pointer; }
.slices:has(.hl) .slice:not(.hl) { opacity: .55; }
.slice.hl { transform: scale(1.07); }
.donut .leg { cursor: pointer; border-radius: 6px; }
.donut .leg.hl span, .donut .leg.hl b { font-weight: 700; }
.donut .leg:focus-visible { outline: 2px solid var(--md-sys-color-primary); }
@media (prefers-reduced-motion: reduce) { .slice { transition: none; } }

/* Valor gasto da categoria selecionada: abaixo do nome, alinhado ao texto, menor e mais fino */
.donut .leg-val { display: none; grid-column: 2 / -1; margin-top: -4px; font-size: 12px; font-weight: 300; color: #44474e; }
.donut .leg.sel .leg-val { display: block; }

/* Faturas recolhidas (mais de 6) */
.pills:has(.inv-group) { display: block; }
.inv-group { background: #f1f3f9; border-radius: 16px; padding: 4px 12px; }
.inv-group summary { display: flex; align-items: center; gap: 6px; padding: 8px 0; cursor: pointer; list-style: none; font-weight: 500; }
.inv-group summary::-webkit-details-marker { display: none; }
.inv-group summary .material-symbols-outlined { transition: transform .15s; }
.inv-group[open] summary .material-symbols-outlined { transform: rotate(180deg); }
.inv-pills { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0 12px; }
@media (prefers-reduced-motion: reduce) { .inv-group summary .material-symbols-outlined { transition: none; } }
