/* Wandelstein Staff.
   Tom: calmo e legível. Quem usa isto está inseguro com imposto alemão — a
   interface não deve somar ansiedade. Nada de vermelho de alarme onde um
   âmbar resolve, nada de densidade de planilha, texto explicativo com espaço
   para respirar. */

/* Craftwork Grotesk — a mesma fonte de título do Staffboard da WeMinds.
   É ela que dá a identidade: sem ela, a tela cai na fonte do sistema e não
   se parece com o resto da casa por mais que o resto do layout coincida. */
@font-face {
  font-family: "Craftwork Grotesk";
  src: url("fonts/CraftworkGrotesk-Regular.otf") format("opentype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Craftwork Grotesk";
  src: url("fonts/CraftworkGrotesk-Medium.otf") format("opentype");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Craftwork Grotesk";
  src: url("fonts/CraftworkGrotesk-SemiBold.otf") format("opentype");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Craftwork Grotesk";
  src: url("fonts/CraftworkGrotesk-Bold.otf") format("opentype");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Craftwork Grotesk";
  src: url("fonts/CraftworkGrotesk-Heavy.otf") format("opentype");
  font-weight: 800; font-style: normal; font-display: swap;
}

:root {
  /* Mesma convenção do Staffboard: título na Craftwork, corpo na do sistema. */
  --font-head: "Craftwork Grotesk", "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --bg: #faf9f7;
  --panel: #ffffff;
  --panel-2: #f4f2ef;
  --panel-3: #ebe8e3;
  --border: #e2ded7;
  --text: #1f1d1a;
  --muted: #6f6a62;
  --faint: #9a948a;
  --accent: #2f5d50;
  --accent-soft: #e6efec;
  --warn: #9a6a1f;
  --warn-soft: #fbf2e2;
  --danger: #a33b30;
  --danger-soft: #fbeceb;
  --ok: #3d6b45;
  --ok-soft: #eaf2eb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(31,29,26,.05), 0 4px 16px rgba(31,29,26,.04);
}

/* Três estados: automático (segue o sistema), claro fixo, escuro fixo. O
   fixo existe porque um back office contábil que troca de tema sozinho às
   18h, no meio de uma conferência de números, é hostil. */
:root[data-theme="dark"] {
  --bg: #171614;
  --panel: #201f1c;
  --panel-2: #262522;
  --panel-3: #2e2c28;
  --border: #35332e;
  --text: #efece6;
  --muted: #a8a299;
  --faint: #7c766c;
  --accent: #7fb8a5;
  --accent-soft: #24352f;
  --warn: #d4a45c;
  --warn-soft: #33291a;
  --danger: #e08379;
  --danger-soft: #35211f;
  --ok: #86bb90;
  --ok-soft: #1f2c21;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171614;
    --panel: #201f1c;
    --panel-2: #262522;
    --panel-3: #2e2c28;
    --border: #35332e;
    --text: #efece6;
    --muted: #a8a299;
    --faint: #7c766c;
    --accent: #7fb8a5;
    --accent-soft: #24352f;
    --warn: #d4a45c;
    --warn-soft: #33291a;
    --danger: #e08379;
    --danger-soft: #35211f;
    --ok: #86bb90;
    --ok-soft: #1f2c21;
  }
}

* { box-sizing: border-box; }

/* O atributo `hidden` do HTML vale `display: none` só na folha do navegador,
   que perde para QUALQUER `display` declarado aqui. Como `.gate` e `#app` são
   grid, `hidden` não os escondia e a tela de login ficava desenhada por cima
   do app. Esta regra devolve ao atributo a autoridade que ele deveria ter. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand { font-family: var(--font-head); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 22px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }

/* ── login ─────────────────────────────────────────────────────────── */
/* Mesmo desenho do Staffboard da WeMinds. */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.05);
  text-align: center;
}
.login-illu {
  display: block;
  width: 100%;
  max-width: 180px;
  height: auto;
  margin: 0 auto 18px;
}
/* A arte é tinta monocromática (#231f20) sobre transparente — no card escuro
   ela praticamente some. Como não carrega cor nenhuma, um invert simples vira
   um desenho de linha claro que lê bem sobre a superfície escura. */
:root[data-theme="dark"] .login-illu { filter: invert(1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .login-illu { filter: invert(1); }
}
.login-brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 2px;
}
.login-tool {
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.login-card input { width: 100%; margin-bottom: 12px; }
.login-card button.primary { width: 100%; padding: 11px; }
.mfa-hint {
  text-align: left;
  line-height: 1.55;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}
.mfa-hint span { color: var(--text); font-weight: 600; }
.login-back {
  background: none; border: 0;
  text-decoration: underline; cursor: pointer;
  margin-top: 8px; font-size: 13px; opacity: .7;
  color: inherit; font-family: inherit;
}
.login-back:hover { opacity: 1; }
/* Campo de código: monoespaçado e espaçado, para conferir dígito a dígito. */
.code-input {
  text-align: center;
  font-size: 24px;
  letter-spacing: 0.42em;
  text-indent: 0.42em;   /* compensa o espaço que o letter-spacing põe no fim */
  font-variant-numeric: tabular-nums;
  padding: 12px 10px;
}

/* ── layout ────────────────────────────────────────────────────────── */
#app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 0 10px 20px;
  font-weight: 600;
}
.brand-mark {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  border-radius: 7px; font-size: 13px;
}
.nav {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  background: none; border: 0; border-radius: var(--radius-sm);
  color: var(--muted);
  font: inherit; font-size: 14px;
  text-align: left; cursor: pointer; width: 100%;
}
.nav:hover { background: var(--panel-2); color: var(--text); }
.nav[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav-ico { width: 16px; text-align: center; opacity: .75; font-size: 13px; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.nav-quiet { font-size: 13px; }

.main { padding: 28px 32px 80px; max-width: 940px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
.page-head p { margin: 3px 0 0; font-size: 13px; }

/* ── cartões ───────────────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h3 { margin-bottom: 4px; }
.card-sub { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; }
  .brand, .sidebar-foot { display: none; }
  .two-col { grid-template-columns: 1fr; }
  .main { padding: 20px 16px 60px; }
}

/* ── o número grande ───────────────────────────────────────────────── */
/* Âmbar quando você deve, verde quando o Finanzamt devolve. Nunca
   vermelho: dever imposto no prazo não é uma emergência. */
.hero-card {
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.hero-card.is-due { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.hero-card.is-refund { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.hero-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.hero-value {
  font-size: 40px; font-weight: 650; letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.hero-detail { margin: 14px 0 0; font-size: 14px; white-space: pre-line; max-width: 62ch; }
.hero-term { margin-top: 12px; font-size: 12px; color: var(--faint); font-style: italic; }

/* ── a conta aberta ────────────────────────────────────────────────── */
.line {
  display: grid; grid-template-columns: 1fr auto;
  gap: 16px; align-items: start;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.line:last-child { border-bottom: 0; padding-bottom: 0; }
.line-label { font-weight: 500; margin-bottom: 3px; }
.line-detail { font-size: 13px; color: var(--muted); max-width: 58ch; white-space: pre-line; }
.line-term { margin-top: 6px; font-size: 11.5px; color: var(--faint); font-style: italic; }
.line-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600; white-space: nowrap;
}
.line.is-plus .line-value { color: var(--warn); }
.line.is-minus .line-value { color: var(--ok); }

/* ── prazos ────────────────────────────────────────────────────────── */
.deadline {
  display: grid; grid-template-columns: 92px 1fr;
  gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--border);
}
.deadline:last-child { border-bottom: 0; padding-bottom: 0; }
.deadline-date { font-variant-numeric: tabular-nums; }
.deadline-date strong { display: block; font-size: 14px; }
.deadline-when { font-size: 11.5px; color: var(--muted); }
.deadline.is-soon .deadline-when { color: var(--warn); font-weight: 600; }
.deadline.is-late .deadline-when { color: var(--danger); font-weight: 600; }
.deadline-title { font-weight: 500; }
.deadline-what { font-size: 13px; color: var(--muted); margin-top: 2px; max-width: 52ch; }
.deadline-where { margin-top: 5px; font-size: 12.5px; color: var(--accent); }

/* ── reserva ───────────────────────────────────────────────────────── */
.reserve-big {
  font-size: 34px; font-weight: 650; letter-spacing: -0.02em;
  color: var(--accent); line-height: 1.1;
}
.reserve-split {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  margin: 6px 0 12px; font-size: 12.5px; color: var(--muted);
}

/* ── caixinhas do ELSTER ───────────────────────────────────────────── */
/* Cada uma copia sozinha. O objetivo é reduzir um formulário em alemão a
   sete cliques. */
.kz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.kz {
  text-align: left; cursor: pointer;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px; font: inherit; color: inherit;
  transition: border-color .15s, background .15s;
}
.kz:hover { border-color: var(--accent); background: var(--accent-soft); }
.kz.copied { border-color: var(--ok); background: var(--ok-soft); }
.kz.copied::after { content: " copiado ✓"; font-size: 11px; color: var(--ok); }
.kz-num { font-size: 11px; font-weight: 700; color: var(--accent); letter-spacing: .04em; }
.kz-label { font-size: 12.5px; margin: 3px 0; }
.kz-value { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kz-hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.45; }

/* ── listas ────────────────────────────────────────────────────────── */
.row {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: 14px; align-items: center;
  padding: 13px 0; border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }
.row-title { font-weight: 500; }
.row-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.row-value { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.locked { color: var(--faint); }

.pill {
  font-size: 11.5px; padding: 3px 9px; border-radius: 999px;
  background: var(--panel-3); color: var(--muted); white-space: nowrap;
}
.pill-paid { background: var(--ok-soft); color: var(--ok); }
.pill-booked { background: var(--accent-soft); color: var(--accent); }
.pill-overdue { background: var(--danger-soft); color: var(--danger); }
.pill-draft { background: var(--panel-3); color: var(--muted); }
.pill-cancelled { text-decoration: line-through; }

.empty { padding: 26px 0; text-align: center; }
.empty p { max-width: 46ch; margin: 0 auto 6px; font-size: 13.5px; }

/* ── avisos ────────────────────────────────────────────────────────── */
.banner {
  border-radius: var(--radius-sm);
  padding: 14px 16px; margin-bottom: 16px; font-size: 13.5px;
}
.banner-warn { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.banner-ok { background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ok); }
.blocker { margin-top: 8px; font-size: 13px; line-height: 1.5; }
.warn-inline {
  margin-top: 10px; padding: 9px 12px;
  background: var(--warn-soft); border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--warn);
}
.error { color: var(--danger); font-size: 13px; }
.feedback {
  padding: 10px 14px; margin-bottom: 14px;
  background: var(--panel-2); border-radius: var(--radius-sm); font-size: 13px;
}
.todo { padding: 11px 0; border-bottom: 1px solid var(--border); }
.todo:last-child { border-bottom: 0; padding-bottom: 0; }
.todo-what { font-weight: 500; margin-bottom: 2px; }

/* ── formulários ───────────────────────────────────────────────────── */
input, select, textarea {
  width: 100%; padding: 9px 11px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 14px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

button.primary {
  padding: 9px 18px;
  background: var(--accent); color: #fff;
  border: 0; border-radius: var(--radius-sm);
  font: inherit; font-weight: 500; font-size: 14px; cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }
button.ghost {
  padding: 6px 12px;
  background: none; color: var(--muted);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
button.ghost:hover { color: var(--accent); border-color: var(--accent); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-wide { grid-column: 1 / -1; }
.field-label { font-size: 12.5px; font-weight: 500; }
.field-hint { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.form-grid button { grid-column: 1 / -1; justify-self: start; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.period-picker { display: flex; gap: 8px; }
.period-picker select { width: auto; font-size: 13px; }

/* ── dropzone ──────────────────────────────────────────────────────── */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 34px; margin-bottom: 16px;
  background: var(--panel);
  border: 1.5px dashed var(--border); border-radius: var(--radius);
  cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-ico { font-size: 26px; }
.dropzone .muted { font-size: 12.5px; }

/* ── painel de explicação ──────────────────────────────────────────── */
.explain-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(31,29,26,.10);
  padding: 26px 24px; overflow-y: auto;
  transform: translateX(100%); transition: transform .22s ease;
  z-index: 50;
}
.explain-panel.open { transform: translateX(0); }
.explain-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: 0; font-size: 24px;
  color: var(--muted); cursor: pointer; line-height: 1;
}
.explain-panel h3 { margin: 8px 0 14px; font-size: 17px; }
.explain-panel p { font-size: 14px; line-height: 1.6; }
.legal-note {
  margin-top: 16px; padding: 12px 14px;
  background: var(--panel-2); border-radius: var(--radius-sm);
}
.legal-note-label { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.legal-note code { font-size: 12.5px; word-break: break-word; }

/* ── editor de documento ───────────────────────────────────────────── */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }
.editor-main { min-width: 0; }
.editor-side { display: flex; flex-direction: column; gap: 16px; }
.side-panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.side-panel h4 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: 12px;
}
.side-panel .field { margin-bottom: 12px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 900px) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-side { order: -1; }
}

/* Linhas do documento. Colunas fixas para os números alinharem verticalmente
   — uma tabela de itens desalinhada é onde erro de digitação se esconde. */
/* A descrição ocupa a linha inteira e os campos numéricos vêm abaixo.
   A versão em uma linha só parecia melhor no papel: com a barra lateral de
   300px e as cinco colunas fixas, sobravam ~25px para o nome do item —
   inutilizável justamente no campo que mais recebe texto. */
/* Qtd · Unidade · Preço · Total · remover. A folga vai para o seletor de
   unidade, que é quem tem texto variável; os números têm largura previsível. */
.lines-head, .line-edit {
  display: grid;
  grid-template-columns: 76px minmax(90px, 1fr) 118px 110px 32px;
  gap: 8px; align-items: center;
}
.line-edit-name { grid-column: 1 / -1; }
.lines-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.lines-head span { text-align: right; }
.lines-head span:first-child { text-align: left; }
.lines-head span:last-child { text-align: center; }
.line-edit { padding: 10px 0; border-bottom: 1px solid var(--border); }
.line-edit-name { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.line-edit input, .line-edit select { padding: 7px 9px; font-size: 13.5px; }
.line-edit .l-qty, .line-edit .l-price { text-align: right; font-variant-numeric: tabular-nums; }
.l-total {
  text-align: right; font-variant-numeric: tabular-nums;
  font-weight: 600; font-size: 13.5px;
}
.l-del { padding: 5px 8px; }
#ed-add-line { margin-top: 12px; }
@media (max-width: 620px) {
  .lines-head { display: none; }
  .line-edit { grid-template-columns: 1fr 1fr; }
}

/* Preview de IVA — a peça mais didática do editor. Verde quando é tributado
   (o normal), âmbar quando NÃO é, porque a ausência de imposto é o caso que
   precisa de explicação. */
.vat-preview {
  margin-top: 14px; padding: 14px 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  font-size: 13px;
}
.vat-preview.is-taxed { background: var(--panel-2); }
.vat-preview.is-exempt {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 28%, transparent);
}
.vat-preview-head { font-weight: 600; margin-bottom: 7px; }
.vat-preview p { margin: 0 0 8px; line-height: 1.58; max-width: 60ch; }
.vat-preview p:last-child { margin-bottom: 0; }

.totals { display: flex; flex-direction: column; gap: 8px; }
.total-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13.5px;
}
.total-row strong { font-variant-numeric: tabular-nums; }
.total-gross {
  padding-top: 9px; margin-top: 3px; border-top: 1px solid var(--border);
  font-size: 15px;
}
.total-gross strong { font-size: 19px; font-weight: 650; }

/* O campo que a lei exige e todo mundo esquece. */
.field-required .field-label::after {
  content: " obrigatório";
  font-size: 10px; font-weight: 600; letter-spacing: .04em;
  color: var(--warn); text-transform: uppercase; margin-left: 5px;
}

.row-clickable { cursor: pointer; }
.row-clickable:hover { background: var(--panel-2); }
.overdue-tag { color: var(--danger); font-weight: 600; }
.chain-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 5px 0; }
.danger-btn:hover { color: var(--danger); border-color: var(--danger); }
textarea { resize: vertical; font-family: inherit; }

/* ── comprovantes ──────────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter { width: auto; font-size: 13px; padding: 7px 10px; }
.filter-count { font-size: 12.5px; color: var(--muted); }
.filter-count.is-pending { color: var(--warn); font-weight: 600; }
.warn-text { color: var(--warn); }
.rc-tag {
  font-size: 11px; padding: 1px 6px; border-radius: 4px;
  background: var(--panel-3); color: var(--muted);
}

/* Imagem à esquerda, formulário à direita. A imagem gruda no scroll: a
   pessoa desce pelos campos sem perder o documento de vista, que é o ponto
   inteiro desta tela. */
.receipt-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px; }
.receipt-image .card { position: sticky; top: 20px; }
.rec-preview {
  width: 100%; max-height: 68vh; object-fit: contain;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel-2); display: block;
}
iframe.rec-preview { height: 68vh; }
@media (max-width: 1000px) {
  .receipt-grid { grid-template-columns: 1fr; }
  .receipt-image .card { position: static; }
  iframe.rec-preview { height: 50vh; }
}

/* ── diálogo ───────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 18, 15, .45);
  display: grid; place-items: center; padding: 24px;
  animation: fade-in .12s ease;
}
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: 100%; max-width: 420px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  box-shadow: 0 12px 48px rgba(20, 18, 15, .28);
}
.modal h3 { font-size: 16px; margin-bottom: 8px; }
.modal p { font-size: 13.5px; color: var(--muted); line-height: 1.6; margin-bottom: 16px; }
.modal-input { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-actions button { width: auto; }
/* Botão de ação destrutiva: vermelho sólido, para não ser confundido com o
   verde de "seguir em frente".
   Seletor `button.primary.danger-solid` e não `.danger-solid`: `button.primary`
   é elemento+classe e ganha de uma classe sozinha — o botão saía verde. */
button.primary.danger-solid { background: var(--danger); }

/* ── avisos passageiros ────────────────────────────────────────────── */
.toast-host {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 110; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none; width: min(520px, calc(100vw - 32px));
}
.toast {
  padding: 12px 18px; border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg);
  font-size: 13.5px; line-height: 1.5; text-align: center;
  box-shadow: 0 6px 24px rgba(20, 18, 15, .22);
  animation: toast-in .2s ease;
  max-width: 100%;
}
.toast-error { background: var(--danger); color: #fff; }
.toast.is-leaving { opacity: 0; transition: opacity .2s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .toast { animation: none; }
}

/* ── esqueleto de carregamento ─────────────────────────────────────── */
/* Uma tela em branco durante uma query pesada (o cockpit faz várias, a EÜR
   faz um cálculo inteiro) é indistinguível de uma tela quebrada. */
.skeleton { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.skel-row {
  height: 15px; border-radius: 4px;
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--panel-3) 37%, var(--panel-2) 63%);
  background-size: 400% 100%;
  animation: skel 1.3s ease-in-out infinite;
}
.skel-row:nth-child(2n) { width: 78%; }
.skel-row:nth-child(3n) { width: 55%; }
@keyframes skel { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }
@media (prefers-reduced-motion: reduce) { .skel-row { animation: none } }

/* ── declaração anual, cobrança e banco ────────────────────────────── */
.euer-line {
  display: grid; grid-template-columns: 1fr auto; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.euer-line:last-child { border-bottom: 0; }
.euer-line-label { min-width: 0; }
.euer-kz {
  margin-left: 7px; font-size: 10.5px; color: var(--faint);
  padding: 1px 5px; background: var(--panel-2); border-radius: 4px;
}
.euer-line-value { font-variant-numeric: tabular-nums; white-space: nowrap; }
.euer-total {
  margin-top: 6px; padding-top: 11px;
  border-top: 1.5px solid var(--border); border-bottom: 0;
  font-weight: 650; font-size: 14px;
}

.bwa-row {
  display: grid; grid-template-columns: 64px 1fr 96px;
  gap: 10px; align-items: center; padding: 5px 0; font-size: 12.5px;
}
.bwa-month { color: var(--muted); }
.bwa-track { height: 14px; background: var(--panel-3); border-radius: 4px; overflow: hidden; }
.bwa-fill { height: 100%; background: var(--ok); border-radius: 4px; }
.bwa-fill.is-neg { background: var(--danger); }
.bwa-value { text-align: right; font-variant-numeric: tabular-nums; }

.dunning-advice {
  margin-top: 6px; font-size: 12.5px; color: var(--muted);
  line-height: 1.5; max-width: 62ch;
}
.match-hint {
  margin-top: 5px; font-size: 12.5px; color: var(--accent);
}
.row-value.is-out { color: var(--danger); }
.row-value.is-in { color: var(--ok); }

.banner-info {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  line-height: 1.6;
}
.plan-years {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
}
.plan-years span {
  padding: 5px 10px; background: var(--panel); border-radius: var(--radius-sm);
  font-size: 12.5px; font-variant-numeric: tabular-nums;
}

.file-missing {
  padding: 16px; border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  font-size: 13px;
}
.file-missing p { margin: 6px 0 0; line-height: 1.55; color: var(--muted); }

.checkbox-field {
  flex-direction: row; align-items: flex-start; gap: 10px;
  padding: 12px; background: var(--panel-2); border-radius: var(--radius-sm);
}
.checkbox-field input { width: auto; margin-top: 2px; flex: none; }
.checkbox-field > span { display: flex; flex-direction: column; gap: 4px; }

/* A caixa que responde "quanto desta nota volta para mim?" */
.vorsteuer-box {
  margin-top: 14px; padding: 13px 15px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--panel-2); font-size: 13px;
}
.vorsteuer-box p { margin: 5px 0 0; line-height: 1.55; max-width: 58ch; }
.vorsteuer-box.is-back {
  background: var(--ok-soft);
  border-color: color-mix(in srgb, var(--ok) 28%, transparent);
}
.vorsteuer-box.is-rc {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 28%, transparent);
}

/* Alertas da leitura automática. `action` = precisa fazer algo antes de
   lançar; `warning` = o lançamento muda; `info` = só explica uma regra. */
.flag {
  padding: 12px 15px; margin-bottom: 10px;
  border-radius: var(--radius-sm); border-left: 3px solid var(--border);
  background: var(--panel);
}
.flag-title { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.flag-msg { font-size: 13px; color: var(--muted); line-height: 1.55; max-width: 70ch; }
.flag-action { border-left-color: var(--danger); background: var(--danger-soft); }
.flag-warning { border-left-color: var(--warn); background: var(--warn-soft); }
.flag-info { border-left-color: var(--accent); background: var(--accent-soft); }

/* ── aba "como funciona" ───────────────────────────────────────────── */
.learn h3 { margin-bottom: 16px; font-size: 16px; }
.learn-item {
  display: grid; grid-template-columns: 30px 1fr;
  gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--border);
}
.learn-item:last-child { border-bottom: 0; padding-bottom: 0; }
.learn-badge {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 50%; font-size: 13px; font-weight: 600;
}
.learn-warn .learn-badge { background: var(--warn-soft); color: var(--warn); }
.learn-item h4 { font-size: 14.5px; margin-bottom: 7px; }
.learn-item p { font-size: 13.5px; line-height: 1.62; max-width: 64ch; }
.de {
  font-weight: 400; font-size: 12.5px; color: var(--faint);
  font-style: italic; margin-left: 5px;
}
.learn-key {
  margin-top: 10px; padding: 10px 13px;
  background: var(--panel-2); border-left: 2.5px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
}
.learn-list { margin: 0; padding-left: 20px; }
.learn-list li { margin-bottom: 12px; font-size: 13.5px; line-height: 1.6; max-width: 66ch; }
