/* cond — one stylesheet for the site and the app. Plain on purpose: this is a
   book of accounts, and it should read like one. */

:root {
  color-scheme: light dark;
  --ink: #1d2328;
  --bg: #f7f4ee;
  --paper: #ffffff;
  --line: #e2ddd2;
  --muted: #5f6870;
  --brand: #1f4e5f;
  --brand-ink: #f4efe6;
  --accent: #b86e1f;
  --good: #1d7a4f;
  --bad: #b23b3b;
  --warn-bg: #fff4dc;
  --warn-line: #ecc77a;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8e4dc; --bg: #12171a; --paper: #1a2125; --line: #2c363c; --muted: #9aa5ad;
    --brand: #6fb0c4; --brand-ink: #0d1316; --accent: #e0a458; --good: #4cc08a; --bad: #ef7d7d;
    --warn-bg: #2d2717; --warn-line: #6d5a2c;
  }
}

* { box-sizing: border-box; }
/* Classes that set display (.claim, .btn, .card…) must not win over hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--brand); }
h1 { font-size: clamp(28px, 4.6vw, 42px); letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 12px; }
h2 { font-size: 22px; letter-spacing: -0.01em; margin: 32px 0 10px; }
h3 { font-size: 17px; margin: 20px 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small, .hint { font-size: 14px; }
.hint { color: var(--muted); margin-top: 6px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.debt { color: var(--bad); font-weight: 650; }
.credit { color: var(--good); font-weight: 650; }
.error { color: var(--bad); min-height: 1em; }
.ok { color: var(--good); }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; background: var(--paper); padding: 8px 12px; z-index: 10; }

main { max-width: 780px; margin: 0 auto; padding: 36px 20px 64px; }
main.wide { max-width: 1120px; }

/* ── Header and footer ─────────────────────────────────────────────────── */

.site-header {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--paper); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.site-header nav { display: flex; gap: 16px; flex-wrap: wrap; }
.site-header nav a { color: var(--muted); text-decoration: none; font-weight: 550; }
.site-header nav a[aria-current="page"], .site-header nav a:hover { color: var(--ink); }
.site-header .account { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.sync-dot[data-state="synced"] { background: var(--good); }
.sync-dot[data-state="syncing"] { background: var(--accent); }
.sync-dot[data-state="error"], .sync-dot[data-state="offline"] { background: var(--bad); }

.claim { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 10px 20px; background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); }

.site-footer {
  display: flex; gap: 18px; justify-content: space-between; flex-wrap: wrap;
  padding: 24px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px;
}
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }

/* ── Controls ──────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 10px 18px; border-radius: 8px; border: 1px solid var(--brand);
  background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 650;
  text-decoration: none; cursor: pointer;
}
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 5px 11px; font-size: 14px; }
.btn.link { background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; font-weight: 500; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
label.inline { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; margin: 0; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
input[type="checkbox"], input[type="radio"] { width: auto; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 14px; }
.honeypot { position: absolute; left: -5000px; }

/* ── Blocks ────────────────────────────────────────────────────────────── */

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 14px 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 14px 0; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; }
.notice ul { margin: 0; padding-left: 18px; }
.empty { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; border: 1px solid var(--line); color: var(--muted); }
.pill.good { color: var(--good); border-color: var(--good); }
.pill.bad { color: var(--bad); border-color: var(--bad); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
th, td { padding: 9px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
tr:last-child td { border-bottom: 0; }

pre.doc {
  white-space: pre-wrap; word-break: break-word; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 26px; font: 15px/1.6 Georgia, "Times New Roman", serif; color: var(--ink);
}

/* ── App ───────────────────────────────────────────────────────────────── */

.app-top { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.app-top select { width: auto; min-width: 220px; font-weight: 650; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 18px 0 8px; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-color: var(--brand); }
dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; max-width: 560px; width: calc(100% - 32px); background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgb(0 0 0 / 0.35); }

/* ── Marketing ─────────────────────────────────────────────────────────── */

.hero { padding: 24px 0 8px; }
.hero .lede { font-size: 19px; color: var(--muted); max-width: 640px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.features .card { margin: 0; }
.features h3 { margin-top: 0; }
.waitlist { border: 2px solid var(--brand); }
.print-only { display: none; }

@media print {
  .site-header, .site-footer, .claim, .tabs, .no-print, .app-top select, .app-top .btn { display: none !important; }
  body { background: #fff; color: #000; }
  main, main.wide { max-width: none; padding: 0; }
  pre.doc { border: 0; padding: 0; }
  .print-only { display: block !important; }
  .card, table { border-color: #ccc; }
}

/* ── The handover checklist (/passagem-administracao-condominio) ───────── */

.check-group { border: 0; padding: 0; margin: 0; min-width: 0; }
.check-group legend { padding: 0; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: grid; grid-template-columns: 28px 1fr; gap: 4px 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.checklist input[type="checkbox"] { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--brand); }
.checklist .item-label { margin: 0 0 4px; font-size: 16px; cursor: pointer; }
.checklist .note-label { margin-top: 4px; font-weight: 500; }
.checklist textarea { min-height: 0; }
.sheet { display: none; }
.sheet table { margin: 6px 0 14px; }
.sheet .box { width: 32px; font-size: 18px; }
.sheet .line { display: inline-block; min-width: 260px; border-bottom: 1px solid #000; }
.sheet .signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 36px; }
.sheet .signatures div { border-top: 1px solid #000; padding-top: 4px; }

@media print {
  .checklist textarea { border-color: #999; }
  .checklist li { break-inside: avoid; }
  body.print-sheet main > :not(.sheet):not([data-print-url]) { display: none !important; }
  body.print-sheet .sheet { display: block; }
  .sheet tr { break-inside: avoid; }
}

/* ── The budget template (/modelo-orcamento-condominio) ──────────────────── */

.budget-lines td { vertical-align: middle; }
.budget-lines td:first-child input { min-width: 170px; }
.budget-lines td:nth-child(2) input { width: 110px; }
.budget-lines [aria-invalid="true"] { border-color: var(--bad); }
.budget-totals { margin-top: 12px; }
.sheet .blank-cell { min-width: 120px; }

/* ── The payment notice (/modelo-aviso-pagamento-condominio) ─────────────── */

.notice-editor [aria-invalid="true"] { border-color: var(--bad); }
.notice-sheet { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin: 10px 0 18px; }
.notice-sheet .notice-title { margin-top: 0; }
.notice-rows th { text-align: left; width: 38%; vertical-align: top; }
.notice-rows td { white-space: pre-line; overflow-wrap: anywhere; }
.notice-rows .line { min-width: 180px; max-width: 100%; }
.notice-url { color: var(--muted); }

@media print {
  .notice-sheet { border: 0; padding: 0; margin: 0; background: #fff; }
  .notice-rows th, .notice-rows td { padding: 10px 6px; }
  .notice-url { color: #555; }
}

/* ── The accounts report (/modelo-relatorio-contas-condominio) ───────────── */

.report-lines td { vertical-align: middle; }
.report-lines td:first-child input { min-width: 150px; }
.report-lines td:nth-child(2) input { width: 110px; }
.report-lines input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--brand); }
.report-lines [aria-invalid="true"] { border-color: var(--bad); }
.report-lines tr.transfer td:first-child input { border-color: var(--warn-line); background: var(--warn-bg); }
.report-summary th { text-align: left; font-weight: 500; }
.report-summary .sub { font-weight: 400; padding-left: 18px; }
.report-summary { margin-top: 8px; }
.equation { font-weight: 500; }
.equation .num { white-space: normal; }
.report-sheet { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin: 10px 0 18px; }
.report-sheet .report-title { margin-top: 0; }
.report-sheet table { width: 100%; }
.report-sheet .sub { font-weight: 400; padding-left: 18px; }
.report-sheet .reserve-tag, .report-url { color: var(--muted); }

@media print {
  .report-sheet { border: 0; padding: 0; margin: 0; background: #fff; }
  .report-sheet .reserve-tag, .report-url { color: #555; }
}

/* ── The quota receipt (/modelo-recibo-condominio), on the notice's sheet ─── */

.receipt-sign { margin-top: 18px; }
.receipt-sign .line { min-width: 240px; }
@media print {
  .receipt-sign td { padding-top: 28px; }
}

/* ── The arrears letter (/modelo-carta-quotas-em-atraso-condominio), on the notice's sheet ── */

.letter-sheet p, .notice-example p { overflow-wrap: anywhere; }
.letter-items { width: 100%; }
.letter-items th { text-align: left; font-weight: 500; }
.letter-items .line { min-width: 200px; max-width: 100%; }
.letter-text, .letter-note { white-space: pre-line; }
.letter-sign { margin-top: 18px; }
@media print {
  .letter-items th, .letter-items td { padding: 8px 6px; }
  .letter-sign { margin-top: 28px; }
}

/* ── The assembly proxy (/modelo-procuracao-assembleia-condominio), on the notice's sheet ── */

.proxy-sheet p { line-height: 1.9; overflow-wrap: anywhere; }
.proxy-sheet .line { min-width: 160px; max-width: 100%; }
.proxy-subtitle { margin-top: -6px; color: var(--muted); }
.proxy-instructions { white-space: pre-line; }
.proxy-lines { margin-bottom: 18px; }
.proxy-lines .line { display: block; min-width: 0; width: 100%; height: 1.9em; }
.proxy-signature { margin-top: 36px; max-width: 320px; }
.proxy-signature .line { display: block; min-width: 0; width: 100%; }
@media print {
  .proxy-subtitle { color: #555; }
  .proxy-signature { margin-top: 56px; }
}

/* ── The quota map (/mapa-quotas-condominio-excel): the download beside the way into cond ── */

.map-actions { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.map-actions .card { margin: 0; }
.quota-map { font-size: 0.85rem; }
.quota-map caption { text-align: left; padding: 6px 0; color: var(--muted); }
.quota-map th, .quota-map td { white-space: nowrap; }
.quota-map thead th { white-space: normal; min-width: 5.5em; vertical-align: bottom; }
.expense-totals { display: grid; grid-template-columns: auto auto; justify-content: start; gap: 4px 16px; }
.expense-totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
@media print {
  .map-actions { display: none; }
}

/* ── The embeddable calculator and the page that offers it ─────────────── */

body.embed main { padding: 12px; max-width: none; }
body.embed .embed-title { font-size: 18px; margin-bottom: 4px; }
body.embed h2 { font-size: 18px; margin-top: 18px; }
body.embed .card { padding: 12px 14px; margin: 10px 0; }
body.embed .embed-back { border-top: 1px solid var(--line); padding-top: 10px; }
textarea.code { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; min-height: 0; }
body.embed input, body.embed select { padding: 6px 9px; }
body.embed label { margin-top: 6px; }
body.embed th, body.embed td { padding: 5px 8px; }
body.embed .error:empty { display: none; }

/* ── The regulamento (/modelo-regulamento-condominio): switchable articles, and the numbered text on the notice's sheet ── */

.clause.off textarea, .clause.off .fields, .clause.off [data-restore] { opacity: .55; }
.clause textarea { width: 100%; }
.regulation-sheet .regulation-building { margin: -4px 0 4px; }
.regulation-article h3 { margin: 18px 0 6px; font-size: 1rem; }
.regulation-article p { margin: 4px 0; overflow-wrap: anywhere; }
.regulation-approval { margin-top: 32px; }
@media print {
  .regulation-article { break-inside: avoid-page; }
}
