:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: #192534;
  background: #f6f8fa;
  --ink: #192534;
  --muted: #536273;
  --line: #dfe6ed;
  --accent: #176452;
  --accent-dark: #084c3e;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.9rem, 5vw, 2.65rem); letter-spacing: -.045em; line-height: 1.12; }
h2 { font-size: 1.12rem; letter-spacing: -.02em; }
button, input, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #258a77; outline-offset: 3px; }
.frame { width: min(1120px, calc(100% - 40px)); margin-inline: auto; }
.top { background: #fff; border-bottom: 1px solid var(--line); }
.brand { font-size: 1rem; margin-block: 0; height: 66px; display: flex; align-items: center; gap: 10px; font-weight: 750; letter-spacing: -.025em; }
.logo { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 10px; background: #e5f2ed; color: var(--accent); }
.logo svg { width: 23px; }
.page-head { display: flex; flex-wrap: wrap; gap: 9px; justify-content: flex-end; margin: 20px 0 16px; }
#export-month:disabled { opacity: .55; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; }
button, input, select { min-height: 44px; border-radius: 9px; }
input, select { width: 100%; background: white; color: var(--ink); border: 1px solid #ccd7e1; padding: 8px 11px; min-width: 0; }
select { appearance: none; padding-right: 32px; background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23536273' stroke-width='1.6'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; }
.primary, .secondary { padding: 0 15px; font-weight: 650; }
.primary { background: var(--accent); color: white; border: 1px solid transparent; }
.primary:hover { background: var(--accent-dark); }
.secondary { background: white; color: var(--ink); border: 1px solid #ccd7e1; }
#notice { margin-bottom: 15px; color: var(--accent-dark); }
.overview, .charts { display: grid; gap: 14px; margin-bottom: 15px; }
.overview { grid-template-columns: 1.2fr 1fr 1fr; }
.charts { grid-template-columns: 1fr 1fr; }
.card { min-width: 0; background: white; border: 1px solid var(--line); border-radius: 15px; padding: 20px; }
.overview p { font-size: .875rem; color: var(--muted); margin-bottom: 7px; }
.overview strong { display: block; font-size: clamp(1.2rem, 3.2vw, 1.8rem); letter-spacing: -.035em; overflow-wrap: anywhere; }
.overview small { display: block; color: var(--muted); margin-top: 4px; font-size: .875rem; }
.overview small:empty { display: none; }
.total-card { background: #124b40; border-color: #124b40; color: #fff; }
.total-card p { color: #d1e8e0; }
.total-card strong { font-size: clamp(1.65rem, 4vw, 2.2rem); }
.chart-card h2 { margin-bottom: 16px; }
.category-chart { display: grid; gap: 10px; }
.category-row { display: grid; gap: 4px; font-size: .875rem; }
.category-label { display: flex; justify-content: space-between; gap: 8px; }
.category-label strong { white-space: nowrap; }
.track { height: 6px; border-radius: 10px; background: #edf2f0; overflow: hidden; }
.fill { display: block; height: 100%; border-radius: inherit; background: #2e816c; }
.timeline { display: flex; gap: 8px; align-items: stretch; }
.week { min-width: 0; flex: 1; text-align: center; display: grid; grid-template-rows: auto 106px auto; align-items: end; gap: 7px; }
.week-value { font-size: .875rem; font-weight: 650; overflow-wrap: anywhere; }
.column { display: flex; align-items: end; height: 100%; background: #eef4f1; border-radius: 7px; overflow: hidden; }
.column .fill { width: 100%; }
.week-label { color: var(--muted); font-size: .875rem; white-space: nowrap; }
.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
#results, .empty { color: var(--muted); font-size: .875rem; }
.filters { display: grid; grid-template-columns: 1fr minmax(170px, 230px); gap: 8px; margin-bottom: 10px; }
.expenses { list-style: none; padding: 0; margin: 0; }
.expense { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.expense-name { display: block; font-weight: 650; overflow-wrap: anywhere; }
.expense-meta { color: var(--muted); font-size: .875rem; }
.expense-amount { font-weight: 720; text-align: right; overflow-wrap: anywhere; }
.row-actions { display: flex; }
.icon-btn { width: 44px; color: var(--muted); background: transparent; border: 0; display: grid; place-items: center; font-size: 1.5rem; padding: 0; }
.icon-btn:hover { background: #edf3f3; color: var(--accent-dark); }
.icon-btn svg { width: 18px; height: 18px; }
li.empty { padding: 16px 0 2px; }
dialog { width: min(460px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 20px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); }
dialog::backdrop { background: #14273180; }
form { display: grid; gap: 14px; }
form label { display: grid; gap: 5px; font-size: .875rem; font-weight: 650; min-width: 0; }
form input, form select { font-size: 1rem; font-weight: 400; }
.modal-head, .modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modal-actions { justify-content: flex-end; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.error { color: #a22532; font-size: .875rem; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 680px) {
  .frame { width: calc(100% - 28px); }
  .brand { height: 56px; }
  .page-head { margin: 14px 0; }
  #export-month { width: 100%; }
  .actions { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .overview { grid-template-columns: 1fr 1fr; gap: 8px; }
  .total-card { grid-column: 1 / -1; }
  .charts { grid-template-columns: 1fr; }
  .card { padding: 15px; }
  .filters { grid-template-columns: 1fr; }
  .expense { grid-template-columns: minmax(0, 1fr) minmax(0, auto); gap: 2px 10px; }
  .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .week-value, .week-label { font-size: .8125rem; }
}
@media (max-width: 340px) {
  .actions, .form-grid { grid-template-columns: 1fr; }
}

/* Mantém controles e conteúdo dentro da área segura do iPhone. */
.top { padding-top: env(safe-area-inset-top, 0px); }
.frame { max-width: calc(100% - 28px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)); }
main { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
.offline-status { margin-top: 12px; font-size: .875rem; color: var(--muted); }
@media (max-width: 680px) {
  #import-csv { width: 100%; }
}
