/* ==========================================================================
   Quer Apanhar — Design System
   Implementa DESIGN_SYSTEM.md. Nao escreva CSS em paginas: adicione aqui.
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  /* Marca */
  --qa-blue: #2563EB;
  --qa-blue-dark: #1D4ED8;
  --qa-blue-light: #4C8DFF;
  --qa-blue-wash: #E8F0FE;
  --qa-navy: #172B54;
  --qa-yellow: #FFC01E;
  --qa-yellow-wash: #FFF4D6;

  /* Semantica */
  --qa-green: #10B981;
  --qa-green-wash: #DCFCE7;
  --qa-red: #EF4444;
  --qa-red-wash: #FEE2E2;
  --qa-amber: #F59E0B;
  --qa-amber-wash: #FEF3C7;
  /* "Tinta": a mesma cor, escura o bastante para TEXTO (AA, 4.5:1+). As de
     cima continuam para preenchimento (barra, check, botao). Valor de receita
     em --qa-green dava 2.5:1 — ilegivel no sol. */
  --qa-green-ink: #047857;
  --qa-red-ink: #B91C1C;
  --qa-amber-ink: #B45309;
  --qa-blue-ink: #1D4ED8;
  /* Fundo de aviso com texto branco: iguais nos dois temas (5.5:1 e 6.5:1).
     A tinta nao serve aqui porque clareia no escuro. */
  --qa-green-strong: #047857;
  --qa-red-strong: #B91C1C;

  /* Superficies */
  --qa-bg: #F5F7FB;
  --qa-surface: #FFFFFF;
  --qa-surface-2: #FAFBFE;
  --qa-line: #E4E9F2;
  /* Borda de campo e do check do mercado: precisa de 3:1 para ser vista. */
  --qa-line-strong: #8792AD;
  --qa-text: #172B54;
  --qa-muted: #5A6785;

  /* Espacamento */
  --qa-s1: 4px;  --qa-s2: 8px;  --qa-s3: 12px; --qa-s4: 16px;
  --qa-s5: 24px; --qa-s6: 32px; --qa-s7: 48px;

  /* Raio */
  --qa-r-sm: 10px; --qa-r: 16px; --qa-r-lg: 22px; --qa-r-full: 999px;

  /* Sombra */
  --qa-shadow-sm: 0 1px 2px rgba(23, 43, 84, .06), 0 2px 8px rgba(23, 43, 84, .05);
  --qa-shadow: 0 4px 12px rgba(23, 43, 84, .10), 0 12px 28px rgba(23, 43, 84, .08);
  --qa-shadow-blue: 0 6px 16px rgba(37, 99, 235, .32);

  --qa-ease: cubic-bezier(.2, .8, .2, 1);
  --qa-sidebar-w: 240px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --qa-bg: #0F1729;
    --qa-surface: #17203A;
    --qa-surface-2: #1D2745;
    --qa-line: #2A3557;
    --qa-line-strong: #6B7AA3;
    --qa-text: #E8EEFB;
    --qa-muted: #93A2C4;
    --qa-blue-wash: #1E2C52;
    --qa-yellow-wash: #3A2F12;
    --qa-green-wash: #123528;
    --qa-red-wash: #3A1A1C;
    --qa-amber-wash: #3A2C10;
    --qa-green-ink: #34D399;
    --qa-red-ink: #F87171;
    --qa-amber-ink: #FBBF24;
    --qa-blue-ink: #7DB3FF;
    --qa-shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --qa-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  }
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body {
  margin: 0;
  background: var(--qa-bg);
  color: var(--qa-text);
  font-family: Nunito, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p, figure { margin: 0; }
/* `hidden` vence qualquer display de componente (o JS liga e desliga assim). */
[hidden] { display: none !important; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
a { color: var(--qa-blue-ink); text-decoration: none; }
button { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--qa-blue-light);
  outline-offset: 2px;
  border-radius: var(--qa-r-sm);
}

/* ---------- 3. Tipografia ---------- */
.qa-display { font-size: 32px; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.qa-h1 { font-size: 24px; font-weight: 800; line-height: 1.25; letter-spacing: -.01em; }
.qa-h2 { font-size: 19px; font-weight: 700; line-height: 1.3; }
.qa-body { font-size: 15px; font-weight: 500; }
.qa-small { font-size: 13px; font-weight: 600; }
.qa-tiny {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
}
.qa-muted { color: var(--qa-muted); }
.qa-money { font-variant-numeric: tabular-nums; font-weight: 800; }
.qa-green { color: var(--qa-green-ink); }
.qa-red { color: var(--qa-red-ink); }
.qa-amber { color: var(--qa-amber-ink); }
.qa-center { text-align: center; }
.qa-right { text-align: right; }

/* ---------- 4. Layout ---------- */
.qa-app { min-height: 100dvh; }

.qa-topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--qa-s3);
  padding: var(--qa-s3) var(--qa-s4);
  padding-top: calc(var(--qa-s3) + env(safe-area-inset-top));
  background: var(--qa-surface);
  border-bottom: 1px solid var(--qa-line);
}
.qa-topbar__logo { height: 34px; width: auto; }
.qa-topbar__title { font-size: 18px; font-weight: 800; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-topbar__avatar {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--qa-r-full);
  background: var(--qa-blue-wash);
  font-size: 18px; border: none; cursor: pointer;
}

.qa-page {
  max-width: 720px; margin: 0 auto;
  padding: var(--qa-s4);
  /* espaco para a bottom nav + area segura do iPhone */
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.qa-section { margin-bottom: var(--qa-s5); }
.qa-section__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--qa-s3); margin-bottom: var(--qa-s3);
}

.qa-grid { display: grid; gap: var(--qa-s3); }
/* Dentro de grade o espaco e o gap: o margin de ".qa-card + .qa-card"
   desalinhava o segundo cartao ("Entrou" x "Saiu"). */
.qa-grid > .qa-card + .qa-card, .qa-grid-2 > .qa-card + .qa-card { margin-top: 0; }
.qa-grid-2 { display: grid; gap: var(--qa-s3); grid-template-columns: repeat(2, 1fr); }
.qa-row { display: flex; align-items: center; gap: var(--qa-s3); }
.qa-row-wrap { display: flex; align-items: center; gap: var(--qa-s2); flex-wrap: wrap; }
.qa-spacer { flex: 1; }
.qa-stack { display: grid; gap: var(--qa-s3); }
.qa-mt { margin-top: var(--qa-s4); }
.qa-mb { margin-bottom: var(--qa-s4); }

/* Utilitarias de layout — cobrem os casos que apareceriam como style="" inline. */
.qa-fill { flex: 1; min-width: 0; }          /* cresce e deixa o texto truncar */
.qa-dim { opacity: .85; }
.qa-center-row { justify-content: center; }
.qa-inline-form { display: inline; }
.qa-bullets { display: grid; gap: var(--qa-s2); }

/* ---------- 5. Navegacao ---------- */
.qa-bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--qa-surface);
  border-top: 1px solid var(--qa-line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 20px rgba(23, 43, 84, .07);
}
.qa-bottomnav__item {
  display: grid; justify-items: center; gap: 2px;
  padding: var(--qa-s2) var(--qa-s1) var(--qa-s3);
  min-height: 56px;
  color: var(--qa-muted);
  font-size: 11.5px; font-weight: 700;
  transition: color .16s var(--qa-ease);
}
.qa-bottomnav__item span:first-child { font-size: 21px; line-height: 1.1; }
.qa-bottomnav__item.is-active { color: var(--qa-blue-ink); }
/* Pilula atras do icone ativo: o estado nao depende so da cor. */
.qa-bottomnav__item.is-active span:first-child {
  background: var(--qa-blue-wash); border-radius: var(--qa-r-full);
  padding: 0 14px;
  transform: translateY(-2px) scale(1.08);
  transition: transform .2s var(--qa-ease);
}

.qa-sidebar { display: none; }

/* Abas de segundo nivel dentro de uma area */
.qa-subnav {
  display: flex; gap: var(--qa-s2);
  overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(var(--qa-s4) * -1) var(--qa-s4);
  padding: 0 var(--qa-s4) var(--qa-s1);
}
.qa-subnav::-webkit-scrollbar { display: none; }
/* Degrade nas bordas: avisa que ha mais abas para o lado (a barra e escondida). */
.qa-subnav {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 calc(100% - 28px), transparent 100%);
}
.qa-subnav__item {
  flex: none;
  display: inline-flex; align-items: center; min-height: 44px;
  padding: 0 var(--qa-s4);
  border-radius: var(--qa-r-full);
  background: var(--qa-surface);
  border: 1px solid var(--qa-line);
  color: var(--qa-muted);
  font-size: 13.5px; font-weight: 700;
  white-space: nowrap;
  transition: all .16s var(--qa-ease);
}
.qa-subnav__item.is-active {
  background: var(--qa-blue); border-color: var(--qa-blue);
  color: #fff; box-shadow: var(--qa-shadow-blue);
}

/* ---------- 6. Cartoes ---------- */
.qa-card {
  background: var(--qa-surface);
  border: 1px solid var(--qa-line);
  border-radius: var(--qa-r-lg);
  padding: var(--qa-s4);
  box-shadow: var(--qa-shadow-sm);
}
.qa-card + .qa-card { margin-top: var(--qa-s3); }
/* Cartao inteiro clicavel: nao pode herdar o azul de <a>. */
a.qa-card { display: block; color: inherit; transition: transform .12s var(--qa-ease); }
a.qa-card:active { transform: scale(.99); }
.qa-card.is-flat { box-shadow: none; background: var(--qa-surface-2); }
.qa-card.is-accent {
  background: linear-gradient(135deg, var(--qa-blue) 0%, var(--qa-blue-light) 100%);
  border-color: transparent; color: #fff;
}
.qa-card.is-accent .qa-muted,
.qa-card.is-accent .qa-tiny { color: rgba(255, 255, 255, .78); }

.qa-stat { display: grid; gap: 2px; }
.qa-stat__label { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--qa-muted); }
.qa-stat__value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- 7. Listas ---------- */
.qa-list {
  background: var(--qa-surface);
  border: 1px solid var(--qa-line);
  border-radius: var(--qa-r-lg);
  overflow: hidden;
  box-shadow: var(--qa-shadow-sm);
}
.qa-list-item {
  display: flex; align-items: center; gap: var(--qa-s3);
  padding: var(--qa-s3) var(--qa-s4);
  min-height: 60px;
  /* border: 0 primeiro: <button class="qa-list-item"> herdaria a borda
     "outset" do navegador nos outros tres lados. */
  border: 0; border-bottom: 1px solid var(--qa-line);
  background: none; width: 100%; text-align: left;
  font: inherit; color: inherit;
}
.qa-list-item:last-child { border-bottom: none; }
a.qa-list-item, button.qa-list-item { cursor: pointer; transition: background .14s var(--qa-ease); }
a.qa-list-item:active, button.qa-list-item:active { background: var(--qa-surface-2); }
.qa-list-item__icon {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--qa-r-full);
  background: var(--qa-blue-wash);
  font-size: 19px;
}
/* grid em qualquer tag: com spans inline dentro, titulo e subtitulo saiam na
   mesma linha e as reticencias nao funcionavam. */
.qa-list-item__body { flex: 1; min-width: 0; display: grid; }
/* O corpo da linha tambem pode ser um botao (abrir a edicao sem engolir o check). */
button.qa-list-item__body {
  display: grid; justify-items: stretch;
  padding: 0; border: none; background: none;
  text-align: left; cursor: pointer;
}
.qa-list-item__title {
  font-weight: 700; font-size: 14.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Descricao que pode quebrar em ate duas linhas (lancamentos): o nome do
   lojista e o que diferencia um do outro, cortar em uma linha esconde demais. */
.qa-list-item__title.is-wrap {
  white-space: normal; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.qa-list-item__sub { font-size: 12.5px; color: var(--qa-muted); font-weight: 600; }
.qa-list-item__amount { font-weight: 800; font-variant-numeric: tabular-nums; flex: none; white-space: nowrap; }
.qa-money { white-space: nowrap; }
.qa-list-item.is-done .qa-list-item__title { text-decoration: line-through; }
.qa-list-item.is-done { opacity: .55; }

/* ---------- 8. Chips e badges ---------- */
.qa-chip {
  display: inline-flex; align-items: center; gap: var(--qa-s1);
  min-height: 44px; padding: 0 var(--qa-s4);
  border-radius: var(--qa-r-full);
  background: var(--qa-surface); border: 1px solid var(--qa-line);
  color: var(--qa-muted);
  font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all .16s var(--qa-ease);
}
.qa-chip.is-active { background: var(--qa-blue-wash); border-color: var(--qa-blue); color: var(--qa-blue-ink); }

.qa-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px var(--qa-s2);
  border-radius: var(--qa-r-full);
  background: var(--qa-blue-wash); color: var(--qa-blue-ink);
  font-size: 11px; font-weight: 800;
}
.qa-badge.is-green { background: var(--qa-green-wash); color: var(--qa-green-ink); }
.qa-badge.is-red { background: var(--qa-red-wash); color: var(--qa-red-ink); }
.qa-badge.is-amber { background: var(--qa-amber-wash); color: var(--qa-amber-ink); }

/* ---------- 9. Barra de progresso ---------- */
.qa-progress {
  position: relative;
  height: 10px; border-radius: var(--qa-r-full);
  background: var(--qa-line); overflow: hidden;
}
/* Marca de "hoje": quanto do mes ja passou. Barra alem da marca = acima do ritmo. */
.qa-progress__mark {
  position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px;
  background: var(--qa-text); opacity: .55;
}
.qa-progress__bar {
  height: 100%; border-radius: var(--qa-r-full);
  background: var(--qa-green);
  transition: width .4s var(--qa-ease);
}
.qa-progress[data-level="warn"] .qa-progress__bar { background: var(--qa-amber); }
.qa-progress[data-level="over"] .qa-progress__bar { background: var(--qa-red); }

/* ---------- 10. Formularios ---------- */
.qa-field { display: grid; gap: 6px; margin-bottom: var(--qa-s3); }
.qa-label { font-size: 12px; font-weight: 700; color: var(--qa-muted);
  text-transform: uppercase; letter-spacing: .04em; }

.qa-input, .qa-select, .qa-textarea {
  width: 100%;
  padding: 13px var(--qa-s4);
  border: 1.5px solid var(--qa-line-strong);
  border-radius: var(--qa-r);
  background: var(--qa-surface);
  color: var(--qa-text);
  font-family: inherit;
  font-size: 16px; /* 16px evita o zoom automatico do Safari no iPhone */
  font-weight: 600;
  transition: border-color .16s var(--qa-ease), box-shadow .16s var(--qa-ease);
}
.qa-textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.qa-input:focus, .qa-select:focus, .qa-textarea:focus {
  outline: none;
  border-color: var(--qa-blue);
  /* blue-wash sumia no escuro (1.2:1); o azul claro aparece nos dois temas. */
  box-shadow: 0 0 0 3px var(--qa-blue-light);
}
.qa-input::placeholder, .qa-textarea::placeholder { color: var(--qa-muted); font-weight: 500; }
.qa-select { appearance: none; padding-right: var(--qa-s6);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B7A99' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; }

.qa-select.is-sm {
  min-width: 150px;
  padding: 8px var(--qa-s6) 8px var(--qa-s3);
  /* 16px mesmo no compacto: abaixo disso o iPhone da zoom ao tocar. */
  font-size: 16px; border-radius: var(--qa-r-sm);
  background-position: right 12px center;
}

.qa-inline { display: grid; grid-template-columns: 1fr 1fr; gap: var(--qa-s3); }
.qa-inline > .qa-field { margin-bottom: 0; }

.qa-money-input { position: relative; }
.qa-money-input::before {
  content: "R$"; position: absolute; left: var(--qa-s4); top: 50%;
  transform: translateY(-50%);
  font-weight: 800; color: var(--qa-muted); pointer-events: none;
}
.qa-money-input .qa-input { padding-left: 44px; }

.qa-switch { display: flex; align-items: center; gap: var(--qa-s3); cursor: pointer; }
.qa-switch input { position: absolute; opacity: 0; }
.qa-switch__track {
  width: 48px; height: 28px; flex: none;
  border-radius: var(--qa-r-full);
  background: var(--qa-line);
  transition: background .18s var(--qa-ease);
  position: relative;
}
.qa-switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: var(--qa-shadow-sm);
  transition: transform .18s var(--qa-ease);
}
.qa-switch input:checked + .qa-switch__track { background: var(--qa-blue); }
.qa-switch input:checked + .qa-switch__track::after { transform: translateX(20px); }

/* Checkbox redondo das listas de mercado.
   O botao tem 44px (o dedo, de pe, com a sacola na outra mao); o circulo
   desenhado continua com 28px, no ::before. */
.qa-check {
  position: relative;
  width: 44px; height: 44px; flex: none; margin: -8px;
  border: none; border-radius: 50%; background: none;
  display: grid; place-items: center;
  cursor: pointer; padding: 0;
}
.qa-check::before {
  content: ""; position: absolute; inset: 8px;
  border-radius: 50%;
  border: 2.5px solid var(--qa-line-strong);
  background: var(--qa-surface);
  transition: all .16s var(--qa-ease);
}
.qa-check::after {
  content: "✓"; position: relative; color: #fff; font-size: 15px; font-weight: 900;
  opacity: 0; transform: scale(.5);
  transition: all .16s var(--qa-ease);
}
.qa-check.is-checked::before { background: var(--qa-green); border-color: var(--qa-green); }
.qa-check.is-checked::after { opacity: 1; transform: scale(1); }

/* ---------- 11. Botoes ---------- */
.qa-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--qa-s2);
  min-height: 46px;
  padding: 0 var(--qa-s5);
  border: 1.5px solid var(--qa-line);
  border-radius: var(--qa-r);
  background: var(--qa-surface);
  color: var(--qa-text);
  font-size: 14.5px; font-weight: 800;
  cursor: pointer;
  transition: transform .12s var(--qa-ease), box-shadow .16s var(--qa-ease),
              background .16s var(--qa-ease);
}
.qa-btn:active { transform: scale(.96); }
.qa-btn.is-primary {
  background: var(--qa-blue); border-color: var(--qa-blue);
  color: #fff; box-shadow: var(--qa-shadow-blue);
}
.qa-btn.is-primary:hover { background: var(--qa-blue-dark); }
.qa-btn.is-accent {
  background: var(--qa-yellow); border-color: var(--qa-yellow); color: #4A3200;
  box-shadow: 0 6px 16px rgba(255, 192, 30, .35);
}
.qa-btn.is-ghost { background: transparent; border-color: transparent; color: var(--qa-muted); }
.qa-btn.is-danger { background: var(--qa-red-wash); border-color: transparent; color: var(--qa-red-ink); }
.qa-btn.is-block { width: 100%; }
.qa-btn.is-sm { min-height: 44px; padding: 0 var(--qa-s3); font-size: 13px; border-radius: var(--qa-r-sm); }
.qa-btn.is-icon { padding: 0; width: 46px; flex: none; }
.qa-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
/* Enviando: o botao trava ate a proxima pagina (app.js, bindBusySubmit). */
.qa-btn.is-busy { opacity: .7; pointer-events: none; }
.qa-btn.is-busy::after {
  content: ""; width: 14px; height: 14px; flex: none;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: qa-spin .7s linear infinite;
}
@keyframes qa-spin { to { transform: rotate(360deg); } }

.qa-fab {
  position: fixed; right: var(--qa-s4);
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 35;
  width: 58px; height: 58px;
  border: none; border-radius: var(--qa-r-full);
  background: var(--qa-blue); color: #fff;
  font-size: 27px; line-height: 1;
  box-shadow: var(--qa-shadow-blue);
  cursor: pointer;
  transition: transform .14s var(--qa-ease);
}
.qa-fab:active { transform: scale(.92); }

/* ---------- 12. Estado vazio ---------- */
.qa-empty { text-align: center; padding: var(--qa-s6) var(--qa-s4); }
.qa-empty__emoji { font-size: 52px; line-height: 1; margin-bottom: var(--qa-s3); }
.qa-empty__title { font-size: 17px; font-weight: 800; margin-bottom: var(--qa-s1); }
.qa-empty__text { color: var(--qa-muted); font-size: 14px; margin-bottom: var(--qa-s4); }

/* ---------- 13. Flash / toast ---------- */
.qa-flash-area {
  position: fixed; z-index: 60;
  top: calc(var(--qa-s3) + env(safe-area-inset-top));
  left: var(--qa-s4); right: var(--qa-s4);
  display: grid; gap: var(--qa-s2);
  pointer-events: none;
}
.qa-flash {
  margin: 0 auto; max-width: 480px; width: 100%;
  display: flex; align-items: center; gap: var(--qa-s2);
  padding: var(--qa-s3) var(--qa-s4);
  border-radius: var(--qa-r);
  background: var(--qa-navy); color: #fff;
  font-size: 14px; font-weight: 700;
  box-shadow: var(--qa-shadow);
  animation: qa-slide-down .24s var(--qa-ease);
  pointer-events: auto;
}
/* Fundo escuro fixo (e nao o tom claro): texto branco em cima precisa de 4.5:1. */
.qa-flash.is-success { background: var(--qa-green-strong); }
.qa-flash.is-error, .qa-flash.is-danger { background: var(--qa-red-strong); }
.qa-flash.is-warning { background: var(--qa-amber); color: #3A2C10; }
.qa-flash__close {
  flex: none; width: 44px; height: 44px; margin: -12px -12px -12px 0;
  border: none; background: none; color: inherit; opacity: .8;
  font-size: 15px; cursor: pointer; border-radius: var(--qa-r-full);
}
.qa-flash.is-out { animation: qa-fade-out .3s var(--qa-ease) forwards; }

/* ---------- 14. Sheet / modal ---------- */
.qa-sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(23, 43, 84, .5);
  backdrop-filter: blur(2px);
  display: none;
}
.qa-sheet-backdrop.is-open { display: block; animation: qa-fade-in .18s var(--qa-ease); }

.qa-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
  max-height: 88dvh; overflow-y: auto;
  padding: var(--qa-s5) var(--qa-s4) calc(var(--qa-s5) + env(safe-area-inset-bottom));
  background: var(--qa-surface);
  border-radius: var(--qa-r-lg) var(--qa-r-lg) 0 0;
  box-shadow: var(--qa-shadow);
  display: none;
}
.qa-sheet.is-open { display: block; animation: qa-slide-up .26s var(--qa-ease); }
.qa-sheet__handle {
  width: 44px; height: 5px; border-radius: var(--qa-r-full);
  background: var(--qa-line); margin: 0 auto var(--qa-s4);
}
.qa-sheet__title { font-size: 19px; font-weight: 800; margin-bottom: var(--qa-s4); }

/* ---------- 15. Tabela (usada na previa da importacao) ---------- */
.qa-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.qa-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.qa-table th {
  text-align: left; padding: var(--qa-s2) var(--qa-s3);
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .05em; color: var(--qa-muted);
  border-bottom: 1.5px solid var(--qa-line); white-space: nowrap;
}
.qa-table td {
  padding: var(--qa-s3); border-bottom: 1px solid var(--qa-line);
  vertical-align: middle;
}
.qa-table tr:last-child td { border-bottom: none; }
.qa-table tr.is-dup { opacity: .5; }

/* ---------- 15a. Navegador de periodo (mes / semana) ---------- */
.qa-periodnav {
  display: flex; align-items: center; gap: var(--qa-s2);
  margin-bottom: var(--qa-s4);
}
.qa-periodnav__label {
  flex: 1; text-align: center;
  font-size: 15px; font-weight: 800;
}
.qa-periodnav__btn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--qa-line); border-radius: var(--qa-r-full);
  background: var(--qa-surface); color: var(--qa-muted);
  font-size: 17px; font-weight: 800; cursor: pointer;
  transition: transform .12s var(--qa-ease);
}
.qa-periodnav__btn:active { transform: scale(.9); }

/* ---------- 15b. Cardapio: um cartao por dia ---------- */
.qa-day { margin-bottom: var(--qa-s3); }
.qa-day__head {
  display: flex; align-items: baseline; gap: var(--qa-s2);
  margin-bottom: var(--qa-s2); padding: 0 var(--qa-s1);
}
.qa-day__name { font-size: 15px; font-weight: 800; }
.qa-day.is-today .qa-day__name { color: var(--qa-blue-ink); }
.qa-slot {
  display: flex; align-items: center; gap: var(--qa-s3);
  width: 100%; text-align: left;
  padding: var(--qa-s3) var(--qa-s4);
  border: none; border-bottom: 1px solid var(--qa-line);
  background: none; color: inherit; cursor: pointer;
  min-height: 56px;
  transition: background .14s var(--qa-ease);
}
.qa-slot:last-child { border-bottom: none; }
.qa-slot:active { background: var(--qa-surface-2); }
.qa-slot__emoji { font-size: 18px; flex: none; width: 26px; }
.qa-slot__body { flex: 1; min-width: 0; }
.qa-slot__label { font-size: 11px; font-weight: 700; color: var(--qa-muted);
  text-transform: uppercase; letter-spacing: .05em; }
.qa-slot__title { font-size: 14.5px; font-weight: 700; }
.qa-slot.is-empty .qa-slot__title { color: var(--qa-muted); font-weight: 600; font-style: italic; }

/* ---------- 15c. Tela de login ---------- */
.qa-login {
  min-height: 100dvh;
  display: grid; align-content: center; justify-items: center; gap: var(--qa-s4);
  padding: var(--qa-s5) var(--qa-s4) calc(var(--qa-s5) + env(safe-area-inset-bottom));
  background:
    radial-gradient(1100px 480px at 50% -18%, var(--qa-blue-wash) 0%, transparent 62%),
    var(--qa-bg);
}
.qa-login__card {
  width: min(400px, 100%);
  padding: var(--qa-s6) var(--qa-s5);
  background: var(--qa-surface);
  border: 1px solid var(--qa-line);
  border-radius: var(--qa-r-lg);
  box-shadow: var(--qa-shadow);
}
.qa-login__logo { width: min(230px, 78%); margin: 0 auto var(--qa-s3); height: auto; }
.qa-login__hello {
  text-align: center; color: var(--qa-muted);
  font-size: 14.5px; font-weight: 600; line-height: 1.45;
  margin-bottom: var(--qa-s5);
}
.qa-login__foot { text-align: center; }

/* No escuro a logo tem fundo branco: um cartao claro atras resolve. */
@media (prefers-color-scheme: dark) {
  .qa-login__logo, .qa-topbar__logo, .qa-sidebar__brand img {
    background: #fff; border-radius: var(--qa-r); padding: 6px;
  }
}

/* ---------- 15d. Linha da previa de importacao ---------- */
/* Cada lancamento do CSV vira um bloco: em cima o resumo, embaixo os dois
   seletores (tipo e categoria). No celular eles empilham; no desktop ficam
   lado a lado. */
.qa-import-row {
  padding: var(--qa-s3) 0;
  border-bottom: 1px solid var(--qa-line);
}
.qa-import-row:last-child { border-bottom: none; }
.qa-import-row.is-dup { opacity: .45; }

.qa-import-row__head {
  display: flex; align-items: center; gap: var(--qa-s3);
  min-width: 0;
}
/* O bloco do meio precisa empilhar titulo e subtitulo e poder encolher; sem o
   min-width:0 o texto longo empurra o valor para fora da tela. */
.qa-import-row__head > .qa-fill { display: grid; min-width: 0; }
.qa-import-row__head > .qa-fill > * {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qa-import-row__head > .qa-money { flex: none; white-space: nowrap; }
.qa-import-row__head > .qa-small { flex: none; }
.qa-import-row__head input[type="checkbox"] {
  width: 24px; height: 24px; flex: none; accent-color: var(--qa-blue);
}
.qa-import-row__fields {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--qa-s2); margin-top: var(--qa-s2);
}
.qa-import-row__fields .qa-select { min-width: 0; }
.qa-import-row__fields .qa-select:disabled { opacity: .45; }

@media (max-width: 420px) {
  .qa-import-row__fields { grid-template-columns: 1fr; }
}

/* ---------- 15d2. Resumo e filtros de lancamentos ---------- */
.qa-summary {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--qa-s2) var(--qa-s4);
  padding: var(--qa-s3) var(--qa-s4);
  background: var(--qa-surface); border: 1px solid var(--qa-line); border-radius: var(--qa-r);
  font-size: 13px; font-weight: 700; color: var(--qa-muted);
}
.qa-summary strong { font-size: 16px; margin-left: var(--qa-s1); }
/* Fileira de chips que rola de lado no celular, sem barra de rolagem. */
.qa-chip-row {
  display: flex; gap: var(--qa-s2); align-items: center;
  overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(var(--qa-s4) * -1); padding: 2px var(--qa-s4);
}
.qa-chip-row::-webkit-scrollbar { display: none; }
.qa-chip-row > * { flex: none; }
/* Select com cara de chip: o filtro ocupa so o tamanho do texto. */
.qa-select.is-chip {
  width: auto; min-height: 44px; padding: 0 var(--qa-s6) 0 var(--qa-s4);
  border: 1px solid var(--qa-line); border-radius: var(--qa-r-full);
  font-size: 16px; font-weight: 700; color: var(--qa-muted);
  background-position: right 14px center;
}
.qa-select.is-chip.is-active { border-color: var(--qa-blue); color: var(--qa-blue-ink); background-color: var(--qa-blue-wash); }
/* a.qa-card e display:block; o atalho precisa ser uma linha so. */
a.qa-callout { display: flex; align-items: center; gap: var(--qa-s3); color: inherit; }
a.qa-callout .qa-fill { display: grid; }
/* Rotulo so para leitor de tela. */
.qa-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 15d3. Triagem e escolha de categoria ---------- */
.qa-triage__desc { margin-top: var(--qa-s2); overflow-wrap: anywhere; }
/* Grade de categorias: alvos grandes, um toque ja salva. */
.qa-catgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--qa-s2); }
.qa-catgrid__item {
  display: grid; justify-items: center; align-content: center; gap: 2px;
  min-height: 72px; padding: var(--qa-s2);
  border: 1.5px solid var(--qa-line); border-radius: var(--qa-r);
  background: var(--qa-surface); color: var(--qa-text);
  font: inherit; font-size: 13px; font-weight: 700; text-align: center;
  cursor: pointer; transition: transform .12s var(--qa-ease);
}
.qa-catgrid__item:active { transform: scale(.95); }
.qa-catgrid__item.is-hint { border-color: var(--qa-blue); background: var(--qa-blue-wash); }
.qa-catgrid__emoji { font-size: 24px; line-height: 1.1; }
.qa-summary-toggle { min-height: 44px; display: flex; align-items: center; font-weight: 800; cursor: pointer; }
/* Atalhos de emoji para categoria nova. */
.qa-emoji-row { display: flex; flex-wrap: wrap; gap: var(--qa-s1); margin-top: var(--qa-s2); }
.qa-emoji-row__item {
  width: 44px; height: 44px; border: 1px solid var(--qa-line); border-radius: var(--qa-r-sm);
  background: var(--qa-surface); font-size: 20px; cursor: pointer;
}
.qa-emoji-row__item.is-active { border-color: var(--qa-blue); background: var(--qa-blue-wash); }

/* ---------- 15e. Orcamento (linha com barra e ritmo) ---------- */
.qa-budget { display: grid; gap: var(--qa-s2); padding: var(--qa-s3) 0; border-bottom: 1px solid var(--qa-line); }
.qa-budget:first-child { padding-top: 0; }
.qa-budget:last-child { border-bottom: none; padding-bottom: 0; }
.qa-budget a { color: inherit; }
/* Na tela de Orcamentos cada linha leva os botoes de editar/remover embaixo. */
.qa-budget-wrap { padding-bottom: var(--qa-s2); margin-bottom: var(--qa-s3); border-bottom: 1px solid var(--qa-line); }
.qa-budget-wrap:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: none; }
.qa-budget-wrap .qa-budget { padding: 0; border-bottom: none; }

/* ---------- 15f. Detalhe do lancamento (no sheet de edicao) ---------- */
/* O texto inteiro, sem corte: e daqui que se le o extrato para decidir a categoria. */
.qa-detail {
  display: grid; gap: var(--qa-s2);
  padding: var(--qa-s3) var(--qa-s4); margin-bottom: var(--qa-s4);
  background: var(--qa-surface-2); border-radius: var(--qa-r);
  font-size: 14px; font-weight: 600; overflow-wrap: anywhere;
}
.qa-detail__label { font-size: 11px; font-weight: 800; color: var(--qa-muted);
  text-transform: uppercase; letter-spacing: .05em; }
.qa-detail__raw { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  font-weight: 500; color: var(--qa-muted); }
.qa-hint-line { font-size: 12.5px; font-weight: 700; color: var(--qa-blue-ink); min-height: 18px; }

/* ---------- 15g. Selecao em lote ---------- */
/* Modo selecao da lista de lancamentos: cada linha ganha uma caixinha e a
   barra de acoes fica presa acima da bottom nav. */
.qa-pick {
  width: 24px; height: 24px; flex: none; margin: 0;
  accent-color: var(--qa-blue);
}
.qa-pick-row { display: flex; align-items: center; border-bottom: 1px solid var(--qa-line); }
.qa-pick-row:last-child { border-bottom: none; }
.qa-pick-row > .qa-list-item { flex: 1; min-width: 0; border-bottom: none; }
.qa-pick-row > .qa-pick { margin-left: var(--qa-s4); }
[data-pickable]:not(.is-picking) .qa-pick { display: none; }
.qa-pick-row.is-picked { background: var(--qa-blue-wash); }
.qa-bulkbar {
  position: fixed; left: var(--qa-s4); right: var(--qa-s4); z-index: 45;
  bottom: calc(72px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: var(--qa-s3);
  padding: var(--qa-s3) var(--qa-s4);
  background: var(--qa-navy); color: #fff;
  border-radius: var(--qa-r); box-shadow: var(--qa-shadow);
  animation: qa-fade-up .2s var(--qa-ease) both;
}
.qa-bulkbar__count { flex: 1; font-weight: 800; }
.qa-bulkbar .qa-btn.is-ghost { color: #fff; }
@media (min-width: 900px) {
  .qa-bulkbar { left: calc(var(--qa-sidebar-w) + var(--qa-s5)); right: auto; width: min(560px, 60vw); bottom: var(--qa-s5); }
}

/* ---------- 15h. Convite para instalar o app ---------- */
/* Aparece no topo da pagina enquanto o app nao esta instalado (pwa.js). */
.qa-install {
  display: flex; align-items: flex-start; gap: var(--qa-s3);
  padding: var(--qa-s3) var(--qa-s3) var(--qa-s3) var(--qa-s4);
  margin-bottom: var(--qa-s4);
  background: var(--qa-blue-wash);
  border: 1px solid var(--qa-line);
  border-radius: var(--qa-r);
  animation: qa-fade-up .26s var(--qa-ease) both;
}
.qa-install__icon { width: 44px; height: 44px; flex: none; border-radius: var(--qa-r-sm); }
.qa-install__title { font-size: 15px; font-weight: 800; }
.qa-install__text { font-size: 13.5px; font-weight: 600; color: var(--qa-muted); line-height: 1.45; }
.qa-install__text strong { color: var(--qa-text); }
.qa-install__glyph {
  display: inline-block; width: 17px; height: 17px; vertical-align: -3px;
  fill: none; stroke: var(--qa-blue); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.qa-install__cta { margin-top: var(--qa-s2); }
.qa-install__close {
  flex: none; width: 44px; height: 44px; margin: calc(-1 * var(--qa-s2)) calc(-1 * var(--qa-s2)) 0 0;
  border: none; background: transparent; color: var(--qa-muted);
  font-size: 16px; cursor: pointer; border-radius: var(--qa-r-full);
}
@media (min-width: 900px) {
  /* No computador nao faz sentido insistir: o convite e para o celular. */
  .qa-install { display: none !important; }
}

/* ---------- 16. Animacoes ---------- */
@keyframes qa-slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes qa-slide-down { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes qa-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes qa-fade-out { to { opacity: 0; transform: translateY(-10px); } }
@keyframes qa-fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.qa-animate { animation: qa-fade-up .26s var(--qa-ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* ---------- 17. Desktop (>= 900px) ---------- */
@media (min-width: 900px) {
  .qa-app { display: grid; grid-template-columns: var(--qa-sidebar-w) 1fr; }

  .qa-bottomnav, .qa-fab { display: none; }

  .qa-sidebar {
    display: flex; flex-direction: column; gap: var(--qa-s1);
    position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    padding: var(--qa-s4) var(--qa-s3);
    background: var(--qa-surface);
    border-right: 1px solid var(--qa-line);
  }
  .qa-sidebar__brand {
    display: flex; align-items: center; gap: var(--qa-s2);
    padding: var(--qa-s2) var(--qa-s3) var(--qa-s5);
  }
  .qa-sidebar__brand img { height: 40px; width: auto; }
  .qa-sidebar__item {
    display: flex; align-items: center; gap: var(--qa-s3);
    padding: 11px var(--qa-s3);
    border-radius: var(--qa-r);
    color: var(--qa-muted); font-weight: 700; font-size: 14.5px;
    transition: all .16s var(--qa-ease);
  }
  .qa-sidebar__item:hover { background: var(--qa-surface-2); color: var(--qa-text); }
  .qa-sidebar__item.is-active { background: var(--qa-blue-wash); color: var(--qa-blue-ink); }
  .qa-sidebar__item span:first-child { font-size: 19px; }
  .qa-sidebar__sub {
    display: grid; gap: 2px;
    margin: 2px 0 var(--qa-s2) 42px;
  }
  .qa-sidebar__sub a {
    padding: 7px var(--qa-s3); border-radius: var(--qa-r-sm);
    font-size: 13.5px; font-weight: 700; color: var(--qa-muted);
  }
  .qa-sidebar__sub a:hover { color: var(--qa-text); background: var(--qa-surface-2); }
  .qa-sidebar__sub a.is-active { color: var(--qa-blue-ink); background: var(--qa-blue-wash); }
  .qa-sidebar__foot { margin-top: auto; }

  .qa-topbar { background: transparent; border-bottom: none; padding: var(--qa-s5) var(--qa-s5) 0; }
  .qa-topbar__logo { display: none; }
  .qa-topbar__title { font-size: 26px; }

  .qa-page { max-width: 860px; padding: var(--qa-s4) var(--qa-s5) var(--qa-s7); }
  .qa-subnav { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }

  .qa-sheet {
    left: 50%; top: 50%; right: auto; bottom: auto;
    transform: translate(-50%, -50%);
    width: min(520px, 92vw);
    border-radius: var(--qa-r-lg);
    padding-bottom: var(--qa-s5);
  }
  .qa-sheet.is-open { animation: qa-fade-in .2s var(--qa-ease); }
  .qa-sheet__handle { display: none; }

  .qa-grid-2 { grid-template-columns: repeat(2, 1fr); }
  .qa-grid-3 { display: grid; gap: var(--qa-s3); grid-template-columns: repeat(3, 1fr); }
}

/* Somente no celular */
@media (max-width: 899px) {
  .qa-desktop-only { display: none !important; }
}
@media (min-width: 900px) {
  .qa-mobile-only { display: none !important; }
}
