/* BR Brasil Solar — back-office UI. Plain CSS, no build step.
   Palette from the brand invoice: navy + solar amber on white. */

:root {
  --navy: #0d2244;
  --navy-2: #16305c;
  --brand: #1d4f91;
  --brand-strong: #153c70;
  --brand-soft: #e8eef8;
  --sun: #f5a623;
  --sun-strong: #d98a06;
  --sun-soft: #fff4dc;

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #dfe4ec;
  --border-strong: #c7cfdb;
  --text: #13213a;
  --text-2: #44506a;
  --muted: #5b6680;  /* ≥ 4.5:1 on every surface, also the tinted cards (WCAG AA, iteration 34) */

  --success: #17784c;   --success-bg: #e3f4ea;
  --warning: #8a5a00;   --warning-bg: #fff2d6;
  --danger:  #b42318;   --danger-bg:  #fde7e5;
  --info:    #175cd3;   --info-bg:    #e6efff;
  --neutral: #55607a;   --neutral-bg: #edf0f5;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(13, 34, 68, .05), 0 1px 3px rgba(13, 34, 68, .07);
  --sidebar: 236px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-strong); }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 28px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
p { margin: 8px 0; }
code { font-family: var(--mono); font-size: 13px; background: var(--neutral-bg); padding: 1px 5px; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
:focus-visible { outline: 3px solid rgba(245, 166, 35, .6); outline-offset: 2px; }

/* ---------- Layout ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 24px 28px 48px; }
.with-nav .container { margin-left: var(--sidebar); padding-left: 32px; max-width: 1640px; } /* use wide screens */
.public .container { max-width: 440px; padding-top: 10vh; }
.narrow { max-width: 680px; }

/* Sidebar */
/* The menu checkbox: keyboard-reachable on phones (its label is the "Menu" button), absent on desktop. */
.nav-open { display: none; position: absolute; opacity: 0; pointer-events: none; }
.mobilebar { display: none; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); overflow-y: auto; z-index: 10;
  display: flex; flex-direction: column; gap: 1px; padding: 18px 12px;
  background: var(--navy); color: #cdd7e8;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; text-decoration: none; color: inherit; }
.sidebar .brand { color: #fff; padding: 4px 10px 18px; }
.brand-mark { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.brand-logo { display: block; width: 150px; height: auto; }
/* "Energia / Condomínios" switch (ADR-0014) */
.mode-switch { display: flex; margin: 0 6px 6px; padding: 3px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, .08); }
.mode-switch button { flex: 1; padding: 6px 4px; border: 0; border-radius: var(--radius-sm); background: transparent; color: #cdd7e8; font: inherit; font-size: 13px; cursor: pointer; }
.mode-switch button:hover { color: #fff; }
.mode-switch button[aria-pressed="true"] { background: var(--sun); color: #3d2a00; font-weight: 700; }
.nav-group { margin: 16px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #8293b3; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius-sm); color: #dbe3f1; text-decoration: none; font-size: 14px; border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active { background: var(--navy-2); color: #fff; font-weight: 600; border-left-color: var(--sun); }
.count { min-width: 20px; padding: 0 6px; border-radius: 10px; font-size: 12px; line-height: 20px; text-align: center; background: var(--sun); color: #3d2a00; font-weight: 700; }
.count-danger { background: #f97066; color: #fff; }
.session { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255, 255, 255, .1); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.session-user { color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; display: flex; flex-direction: column; }
.session-user small { color: #8fa0c0; font-weight: 400; font-size: 12px; }
.session .link { color: #cdd7e8; }
.session form { margin: 0; }

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head .actions { margin: 0; }
.subtitle { color: var(--muted); margin: 2px 0 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 8px 16px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--brand); color: #fff; font: 600 14px/1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--brand-strong); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--muted); }
.btn-sm { min-height: 30px; padding: 5px 10px; font-size: 13px; }
button.link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.actions form { margin: 0; }
.otp-action { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; max-width: 100%; }
.otp-action .btn { white-space: normal; }
.otp-action input { width: 9em; }

/* ---------- Cards ---------- */
.card, .table-wrap, form.panel, .details, .pix-box, .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel { padding: 16px 18px; margin-bottom: 16px; }
.panel > h2:first-child, .panel > input[type=hidden] + h2, .panel > input[type=hidden] + input[type=hidden] + h2 { margin-top: 0; } /* UX-38: hidden inputs come first in forms */
.card { display: block; padding: 16px 18px; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--brand); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin: 12px 0 8px; }
.card .label { display: block; font-size: 13px; color: var(--muted); }
.card .num { display: block; white-space: nowrap; font-size: 24px; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.card small { display: block; color: var(--muted); margin-top: 2px; }
.card.warn { background: var(--sun-soft); border-color: #f5d48b; }
.cards-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 6px; }
.card.danger { background: var(--danger-bg); border-color: #f6b9b3; }

/* Dashboard task list */
.tasks { list-style: none; margin: 0; padding: 0; }
.tasks li a { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); color: inherit; text-decoration: none; }
.tasks li:first-child a { border-top: 0; }
.tasks li a:hover { background: var(--surface-2); }
.tasks .n { min-width: 36px; height: 28px; padding: 0 8px; border-radius: 14px; display: inline-grid; place-items: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.tasks .go { margin-left: auto; color: var(--brand); font-weight: 600; font-size: 14px; white-space: nowrap; }
.tasks .done { padding: 16px; color: var(--success); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.dash-grid h2 { margin-top: 8px; }

/* ---------- Details (label/value pairs) ---------- */
.details { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); padding: 6px 0; margin: 0 0 16px; }
.details > div { padding: 8px 18px; min-width: 0; }
.details dt { color: var(--muted); font-size: 13px; }
.details dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 12px 0 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); vertical-align: bottom; } /* headers may wrap: values stay on one line */
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #f9fbfe; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.num { white-space: nowrap; }
.table td form { margin: 0; display: inline; }
.table .empty { color: var(--muted); text-align: center; padding: 28px; }
tr.negative td { background: var(--danger-bg); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); vertical-align: middle; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning, .badge.warn { background: var(--warning-bg); color: var(--warning); }
.badge-danger, .badge.error { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--neutral-bg); color: var(--neutral); }
.origin { color: var(--muted); font-size: 12px; }

/* ---------- Alerts ---------- */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); margin: 0 0 14px; background: var(--success-bg); color: #0f4f32; border: 1px solid #bfe3cd; border-left-width: 4px; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #f3d8a0; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #f6c3be; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #c4d7fb; }

/* ---------- Forms ---------- */
form.panel { padding: 18px 20px; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.field { display: flex; flex-direction: column; margin-bottom: 14px; min-width: 0; }
.field label { font-weight: 600; font-size: 14px; margin-bottom: 5px; }
input, select, textarea {
  font: inherit; color: var(--text); width: 100%; min-height: 38px; padding: 8px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff;
}
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 3px solid rgba(29, 79, 145, .18); outline-offset: 0; }
.help { color: var(--muted); font-size: 13px; margin-top: 4px; }
.error { color: var(--danger); font-size: 13px; margin-top: 4px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 6px; }

/* Filters bar */
.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin: 4px 0 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.filters input, .filters select { min-width: 150px; width: auto; }
.more-filters { display: contents; }
.more-filters-body { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.more-filters > summary { display: none; }
@media (max-width: 700px) {
  .more-filters { display: block; width: 100%; }
  .more-filters > summary { display: list-item; cursor: pointer; font-weight: 600; font-size: 14px; }
  .more-filters[open] > summary { margin-bottom: 8px; }
}

.pager { display: flex; gap: 14px; align-items: center; justify-content: flex-end; color: var(--muted); }

/* ---------- Specific screens ---------- */
.codes { columns: 2; font-size: 18px; list-style: none; padding: 0; }
.codes code { font-size: 16px; }
.qr svg { width: 200px; height: 200px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px; }
.pix-box { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; padding: 16px; margin: 8px 0 16px; }
.pix-box img { border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.pix-box > div { flex: 1; min-width: 220px; }
.pix-box textarea { font-family: var(--mono); font-size: 12px; }

.funnel { display: grid; grid-template-columns: repeat(6, minmax(170px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.funnel-col { background: var(--neutral-bg); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.funnel-col h2 { font-size: 14px; margin: 2px 2px 10px; }
.funnel-col h2 small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.lead-card { padding: 10px 12px; margin-bottom: 8px; }
.lead-card small { display: block; color: var(--muted); font-size: 12px; }

/* Public pages (login, set password, 2FA) */
.public .brand { color: var(--text); font-size: 18px; margin-bottom: 18px; justify-content: center; }
.public main section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 24px; }
.public form .btn { width: 100%; margin-top: 4px; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .mobilebar {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20;
    padding: 10px 16px; background: var(--navy); color: #fff;
  }
  .nav-button { padding: 6px 12px; border: 1px solid rgba(255, 255, 255, .3); border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: 14px; }
  .sidebar { display: none; position: static; width: auto; padding: 8px 12px 14px; }
  .sidebar > .brand { display: none; }
  .nav-open { display: block; }
  .nav-open:checked ~ .sidebar { display: flex; }
  .nav-open:focus-visible ~ .mobilebar .nav-button { outline: 2px solid var(--sun); outline-offset: 2px; }
  .nav-open:checked ~ .mobilebar .nav-button { background: rgba(255, 255, 255, .15); }
  .with-nav .container, .container { margin-left: 0; padding: 18px 16px 40px; }
  .form-grid, .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head > .btn, .page-head .actions .btn { width: 100%; }
  .filters input, .filters select { min-width: 0; width: 100%; }
  .filters label { flex: 1 1 140px; }
  .funnel { grid-template-columns: repeat(6, 78%); scroll-snap-type: x mandatory; }
  .funnel-col { scroll-snap-align: start; }
  h1 { font-size: 21px; }
}

/* Brand accents */
.btn-accent { background: var(--sun); color: var(--navy); }
.btn-accent:hover { background: var(--sun-strong); color: var(--navy); }
.card.kpi-navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.card.kpi-navy .label, .card.kpi-navy small { color: #b7c4dc; }
.card.kpi-sun { border-top: 3px solid var(--sun); }
.page-head h1::after { content: ""; display: block; width: 36px; height: 3px; margin-top: 8px; border-radius: 2px; background: var(--sun); }
.tagline { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--sun); font-weight: 600; }
.panel.flush { padding: 0; }
.cards.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0; }
.brand .tagline { display: block; margin-top: 1px; }

.page-head h2 { margin: 0; }
.page-head > .badge { align-self: flex-start; }
.details dd { overflow-wrap: break-word; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f1c13; color: #fff; }
/* UX-22: deactivating looks different from editing or browsing. */
.btn-danger-outline { color: var(--danger); border-color: #f6b9b3; }
button.link.link-danger { color: var(--danger); }
.uc-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.lead-card a { text-decoration: none; color: var(--text); }
.lead-card a:hover { color: var(--brand); }
.table td a { font-weight: 500; }
.table td { white-space: nowrap; }
.table td.wrap, [data-testid=audit-table] td, [data-testid=failed-invoices] td { white-space: normal; }
@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 12px 14px; }
  .card .num { font-size: 19px; }
}

/* Charts (ADR-0006). Series = first three slots of the validated reference palette (all-pairs CVD-safe). */
:root { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --text-2: #44506a; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 10px; min-width: 0; }
.chart-card h2 { margin: 0; font-size: 15px; }
.chart-card .subtitle { font-size: 13px; margin: 2px 0 8px; }
.chart-box { position: relative; height: 260px; }
.chart-table { margin-top: 8px; }
.chart-table summary { cursor: pointer; color: var(--brand); font-size: 13px; font-weight: 600; }
.chart-table .table-wrap { box-shadow: none; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } .chart-box { height: 220px; } }
.card .num .unit { font-size: 14px; font-weight: 600; color: inherit; opacity: .75; }
.inline-reject { display: flex; gap: 6px; }
.inline-reject input { width: 220px; }
.table td small { color: var(--muted); font-size: 12px; }
.table-compact th, .table-compact td { padding: 8px; }
.table td .note { display: block; white-space: normal; min-width: 200px; max-width: 300px; margin-top: 2px; }
.table td .note-danger { color: var(--danger); }
.todo { border-left: 4px solid var(--sun); margin: 12px 0 18px; }
.todo h2 { margin-top: 0; }
.todo-list { list-style: none; padding: 0; margin: 0; }
.todo-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.todo-list li:last-child { border-bottom: 0; }
.todo-list form { margin: 0; }
.field label:has(> input[type=checkbox]) { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 2px 0; }
.credit-split { list-style: none; margin: 2px 0 0; padding: 0; font-size: 12px; color: var(--muted); white-space: nowrap; }
.void-reading { margin-top: 16px; }
.void-reading summary { cursor: pointer; color: var(--danger); font-weight: 600; }
.void-reading fieldset { border: 0; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 4px; }
.void-reading textarea { width: 100%; }
/* Bill detail: value groups (UX-12) */
.value-group { margin: 10px 0; }
.value-group summary { cursor: pointer; font-weight: 600; padding: 6px 0; }

/* Pendências summary (UX-03) */
.issues-summary ul { margin: 0; padding-left: 20px; columns: 2 260px; }
.issues-summary li { margin: 2px 0; }

/* Irreversible actions stay closed until asked for (UX-02), like .void-reading. */
.danger-zone { margin-top: 24px; }
.danger-zone summary { cursor: pointer; color: var(--danger); font-weight: 600; }
.danger-zone[open] summary { margin-bottom: 8px; }
.danger-zone textarea { width: 100%; }

/* ---------- Phone: tables become cards (js/tables.js adds data-label + .table-stack) ---------- */
@media (max-width: 700px) {
  .table td, .table td.num { white-space: normal; overflow-wrap: break-word; }
  .table-stack thead { display: block; }
  .table-stack thead tr { display: block; }
  .table-stack thead th { display: none; }
  .table-stack thead th.cell-check { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 13px; }
  .table-stack thead th.cell-check::after { content: "Selecionar todos"; }
  .table-stack, .table-stack tbody, .table-stack tr { display: block; width: 100%; }
  .table-stack tbody tr { position: relative; padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack tbody tr:hover td { background: none; }
  .table-stack tr.negative { background: var(--danger-bg); }
  .table-stack td { display: block; padding: 3px 0; border: 0; text-align: right; }
  .table-stack td::after { content: ""; display: table; clear: both; }
  .table-stack td::before { content: attr(data-label); float: left; max-width: 45%; margin-right: 12px; text-align: left; font-size: 12px; font-weight: 600; line-height: 21px; color: var(--muted); }
  .table-stack td.cell-title { text-align: left; font-weight: 600; font-size: 15px; padding: 0 36px 4px 0; }
  .table-stack td.cell-title::before, .table-stack td.cell-check::before, .table-stack td:not([data-label])::before { content: none; }
  .table-stack td.cell-title small { font-weight: 400; }
  .table-stack td.cell-check { position: absolute; top: 10px; right: 14px; padding: 0; }
  .table-stack td.cell-check input { width: 22px; height: 22px; }
  .table-stack td.cell-empty { display: none; }
  .table-stack td:not([data-label]):not(.cell-check) { padding-top: 6px; }
  .table-stack td.cell-full, .table-stack td.empty { text-align: center; padding: 14px 0; }
  .table td .note { min-width: 0; max-width: none; }
  .credit-split { white-space: normal; }
  .inline-reject { flex-wrap: wrap; }
  .inline-reject input { width: 100%; flex: 1 1 180px; }
  .actions .btn, .actions form, .actions form .btn { flex: 1 1 auto; }
  /* Iteration 34 (crawl): totals row as one full-width line; long buttons wrap instead of overflowing. */
  .table-stack tfoot { display: block; width: 100%; }
  .table-stack tfoot tr { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; }
  .table-stack tfoot th, .table-stack tfoot td { padding: 0; }
  .table-stack tfoot th:empty, .table-stack tfoot td:empty { display: none; }
  .form-actions .btn { white-space: normal; line-height: 1.3; text-align: center; max-width: 100%; }
  .codes { columns: 1; }
}
@media (max-width: 700px) {
  .table-stack td:not([data-label]) > * + * { margin-left: 14px; }
}

/* ---------- Sorting and pagination (iteration 16) ---------- */
.table th a.sort-link { color: inherit; text-decoration: none; }
.table th a.sort-link:hover { color: var(--brand); text-decoration: underline; }
.table th[aria-sort] { color: var(--text); }
.sort-select { display: none !important; }
.clear-filters { align-self: center; font-size: 14px; }
.pager { flex-wrap: wrap; margin: 4px 0 16px; font-size: 14px; }
@media (max-width: 700px) {
  .sort-select { display: flex !important; flex: 1 1 100%; }
  .pager { justify-content: space-between; }
}
.filters label.check { flex-direction: row; align-items: center; gap: 6px; min-height: 38px; }
.filters label.check input { min-width: 0; width: auto; }
/* Contas a pagar (iteration 17) */
.pay-form { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.pay-form input[type=date] { width: 150px; min-height: 30px; padding: 4px 8px; }
@media (max-width: 700px) { .pay-form { flex-wrap: wrap; justify-content: flex-end; } .pay-form input[type=date] { flex: 1 1 140px; } }
.table td.payable-client { white-space: normal; min-width: 180px; }
.bill-total { margin: 6px 0 0; font-size: 15px; }
.pay-bill label { display: block; font-weight: 600; font-size: 13px; margin: 8px 0 4px; }
.pay-bill p { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 4px 0; }
.copy-row { display: flex; gap: 6px; align-items: flex-start; }
.copy-row textarea, .copy-row input { font-family: var(--mono); font-size: 12px; }
.payables-pay summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 13px; }
.payables-pay .pay-bill { min-width: 280px; white-space: normal; }
.table td small.sub { display: block; }
.pay-form label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
[data-testid=uc-table] small.origin { display: block; }
[data-testid=payable-table] td:last-child { white-space: normal; min-width: 210px; max-width: 260px; }
/* UX-09: a labelled date and the button on one tidy block, left-aligned also on the phone. */
.pay-form .pay-date { display: flex; flex-direction: column; gap: 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
.pay-form .pay-date input { width: 100%; }
@media (max-width: 700px) {
  [data-testid=payable-table] td:last-child { max-width: none; min-width: 0; text-align: left; }
  .pay-form { align-items: stretch; }
  .pay-form .pay-date input { flex: none; }
  .pay-form .btn { align-self: flex-start; }
}
.negative-text { color: var(--danger); }

/* Iteration 21: "Copiar" next to a value (UC, CPF/CNPJ) */
.copy-inline { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.btn-icon:hover { background: var(--border); color: var(--text); }
.btn-icon:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.btn-icon .icon-check { display: none; }
.btn-icon.is-copied { color: var(--success); }
.btn-icon.is-copied .icon-copy { display: none; }
.btn-icon.is-copied .icon-check { display: inline; }
.copy-buffer { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
[data-testid=bills-to-fetch] td:first-child small.origin { display: block; }

/* Iteration 28 (UX-30): "Quem paga" choice on the new-client page */
.choice-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 8px 0 12px; }
.btn.is-current { cursor: default; }
.pick-client { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 0; }
.pick-client select { width: auto; min-width: 200px; flex: 1 1 200px; }
.nowrap { white-space: nowrap; }

/* Condos (iteration 29): notes and errors under the value, one per line. */
[data-testid=import-table] small.origin, [data-testid=import-table] small.error,
[data-testid=condo-table] small.origin { display: block; }
[data-testid=import-table] td.wrap { min-width: 220px; max-width: 360px; }
[data-testid=import-table] small.error { color: var(--danger); }
.meter-thumb { display: block; width: 56px; height: 42px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border, #d8dee8); }
.meter-photo { width: 240px; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--border, #d8dee8); }
[data-testid=readings-month] small.origin { display: block; }
.origin-inline { color: var(--muted); font-size: 12px; }
[data-testid=readings-month] td.wrap { min-width: 180px; max-width: 280px; }
.swap-fields { margin: 4px 0 16px; }
.swap-fields summary { cursor: pointer; font-weight: 600; color: var(--brand); margin-bottom: 8px; }
.charge-details small.origin { display: block; }
[data-testid=charges-preview] small.origin, [data-testid=charge-table] small.origin { display: block; }
[data-testid=to-charge] small.origin { display: block; }
[data-testid=charge-attention] small.origin, [data-testid=charge-attention] small.error { display: block; }
[data-testid=cash-table] small.origin { display: block; }

/* Caretaker pages (US-CONDO-015): phone first, big targets, one action per screen. */
.caretaker { max-width: 480px; margin: 0 auto; }
.caretaker-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; color: var(--muted); font-size: 14px; }
.caretaker-bar form { margin: 0; }
.btn-block { display: flex; width: 100%; justify-content: center; margin-bottom: 10px; }
.btn-big { min-height: 52px; font-size: 18px; }
.caretaker-list { list-style: none; padding: 0; margin: 0 0 16px; }
.caretaker-list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.caretaker-house { font-size: 28px; font-weight: 700; margin: 8px 0 20px; }
.caretaker-progress { font-size: 18px; }
.caretaker select, .caretaker input[type="text"], .caretaker input[inputmode] { font-size: 18px; min-height: 48px; width: 100%; }
form.inline { display: inline-flex; margin: 0; }
/* Client payment page (US-BILL-013): the invoice's look on screen, phone first. */
.pay-public .container { max-width: 560px; margin: 0 auto; padding: 16px 16px 8px; }
.pay { max-width: 520px; margin: 0 auto; }
.pay-head { text-align: center; margin: 8px 0 16px; }
.pay-logo { width: 220px; height: auto; }
.pay-tagline { margin: 2px 0 0; font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--navy); }
.pay-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: 0 1px 3px rgba(13, 34, 68, .08); }
.pay-badge { background: var(--navy); color: #fff; padding: 16px 20px 14px; border-bottom: 4px solid var(--sun); }
.pay-badge-title { display: block; font-size: 20px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; }
.pay-badge dl { display: flex; gap: 24px; margin: 10px 0 0; }
.pay-badge dt { font-size: 12px; color: #c9d4e8; }
.pay-badge dd { margin: 0; font-weight: 700; }
.pay-hello { margin: 16px 20px 0; font-size: 17px; }
.pay-amount { margin: 12px 20px 0; padding: 14px 16px; border: 2px solid var(--navy); border-radius: 10px; }
.pay-amount span { display: block; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--navy); }
.pay-amount strong { font-size: 30px; color: var(--navy); }
.pay .alert { margin: 12px 20px 0; }
.pay-pix { margin: 16px 20px 20px; padding: 16px; border: 2px dashed var(--sun); border-radius: 12px; }
.pay-pix h1 { margin: 0 0 8px; font-size: 20px; color: var(--navy); }
.pay-steps { margin: 0 0 14px; padding-left: 20px; color: var(--text-2); }
.pay-code-label { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.pay-code { width: 100%; font-family: "DejaVu Sans Mono", ui-monospace, monospace; font-size: 12px; word-break: break-all; background: var(--surface-2); }
.pay-qr { display: flex; gap: 12px; align-items: center; margin-top: 14px; color: var(--muted); font-size: 13px; }
.pay-qr img { width: 120px; height: 120px; flex: none; }
.pay-terms { margin: 12px 0 0; font-size: 13px; color: var(--text-2); }
.pay-done, .pay-off { margin: 16px 20px 20px; padding: 16px; border-radius: 10px; }
.pay-done { background: var(--success-bg); color: var(--success); }
.pay-off { background: var(--surface-2); color: var(--text-2); }
.pay-foot { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0 24px; }
.caretaker-condo { flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.caretaker-condo small { color: var(--muted); font-weight: 400; }
/* Caretaker camera button (US-CONDO-015): one big target; the file input is under it, invisible. */
.camera-tip { color: var(--text-2); margin: 0 0 12px; }
.camera-button { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; margin-bottom: 12px; border: 2px dashed var(--brand); border-radius: 12px; background: var(--brand-soft); color: var(--brand-strong); font-size: 18px; font-weight: 700; cursor: pointer; }
.camera-button input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.camera-button:focus-within { outline: 3px solid var(--sun); outline-offset: 2px; }
.camera-icon { font-size: 26px; }
.camera-preview { display: block; width: 100%; max-height: 320px; object-fit: contain; margin: 0 0 12px; border-radius: 10px; background: var(--surface-2); }
.camera-preview[hidden] { display: none; }
.caretaker-condo, .caretaker-condo small { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
.caretaker-condo { line-height: 1.35; }
