/* =========================================================
   INVERSUS CRM — folha de estilos partilhada
   Todas as páginas usam este ficheiro; as cores vivem aqui.
   ========================================================= */

:root {
  --navy: #0b2a52;
  --navy-hover: rgba(255, 255, 255, .09);
  --navy-active: rgba(255, 255, 255, .16);
  --blue: #1d6fd6;
  --blue-600: #1760c0;
  --blue-700: #124d99;
  --tint: #e6f0fd;
  --tint-2: #f4f8fe;

  --ink: #12233a;
  --muted: #5b6b80;
  --line: #dce4ef;
  --line-soft: #edf1f7;
  --bg: #f1f5fa;
  --surface: #ffffff;

  --ok: #12764f;
  --ok-bg: #e3f4ec;
  --warn: #8f5200;
  --warn-bg: #fdf0d9;
  --bad: #b3302a;
  --bad-bg: #fde9e7;

  --link: var(--blue-600);
  --blue-hover: #1760c0;
  --tint-hover: #d6e6fb;
  --line-strong: #c3d2e6;
  --bad-line: #f3c6c2;
  --placeholder: #8a98ab;
  --faint: #9aa8ba;

  --r-sm: 8px;
  --r-md: 12px;
  --topbar-h: 60px;
  --tabbar-h: 62px;
  color-scheme: light;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --navy: #060d19;
  --tint: #16294a;
  --tint-2: #0f1b30;
  --ink: #e8eef8;
  --muted: #8fa3c0;
  --line: #1f3050;
  --line-soft: #18263f;
  --bg: #0a1220;
  --surface: #111c30;
  --blue: #3d8bf2;
  --blue-700: #8ec0ff;
  --link: #7db4ff;
  --blue-hover: #5aa0f7;
  --tint-hover: #1d3560;
  --line-strong: #2c4570;
  --bad-line: #6b2a26;
  --placeholder: #6f84a3;
  --faint: #5f7391;
  --ok: #4cc38a;
  --ok-bg: #10301f;
  --warn: #f0b04a;
  --warn-bg: #33260d;
  --bad: #ff8a80;
  --bad-bg: #3a1614;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  color-scheme: dark;
  --navy: #060d19;
  --tint: #16294a;
  --tint-2: #0f1b30;
  --ink: #e8eef8;
  --muted: #8fa3c0;
  --line: #1f3050;
  --line-soft: #18263f;
  --bg: #0a1220;
  --surface: #111c30;
  --blue: #3d8bf2;
  --blue-700: #8ec0ff;
  --link: #7db4ff;
  --blue-hover: #5aa0f7;
  --tint-hover: #1d3560;
  --line-strong: #2c4570;
  --bad-line: #6b2a26;
  --placeholder: #6f84a3;
  --faint: #5f7391;
  --ok: #4cc38a;
  --ok-bg: #10301f;
  --warn: #f0b04a;
  --warn-bg: #33260d;
  --bad: #ff8a80;
  --bad-bg: #3a1614;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 70px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid rgba(29, 111, 214, .5); outline-offset: 2px; border-radius: 6px; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--navy); color: #fff; }
.topbar-in {
  max-width: 1280px; height: var(--topbar-h); margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; flex: none; }
.brand img { height: 38px; width: auto; display: block; }
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; }
.nav a {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 13px;
  color: #c6d6ec; font-weight: 600; font-size: 14.5px; border-radius: var(--r-sm);
  white-space: nowrap; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--navy-hover); color: #fff; text-decoration: none; }
.nav a[aria-current="page"] { background: var(--navy-active); color: #fff; }
.user { display: flex; align-items: center; gap: 10px; margin-left: auto; color: #c6d6ec; font-size: 14px; }
.user-chip { display: flex; align-items: center; gap: 9px; font-weight: 600; color: #fff; }
.user-chip .avatar { width: 30px; height: 30px; font-size: 12px; background: rgba(255, 255, 255, .16); color: #fff; }
.logout {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: var(--r-sm);
  color: #c6d6ec; font-weight: 600; font-size: 14px; border: 1px solid rgba(255, 255, 255, .22);
  transition: background .15s, color .15s;
}
.logout:hover { background: #fff; color: var(--navy); text-decoration: none; }

/* ---------- Barra inferior (telemóvel) ---------- */
.tabbar { display: none; }

/* ---------- Página ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 26px 20px 48px; }
.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 12px 24px; margin-bottom: 18px;
}
.page-head h1 { margin: 0; font-size: 25px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
.page-head p { margin: 3px 0 0; color: var(--muted); font-size: 14.5px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 14px/1 var(--font); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--tint-2); border-color: var(--line-strong); text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.btn-soft { background: var(--tint); border-color: transparent; color: var(--blue-700); }
.btn-soft:hover { background: var(--tint-hover); border-color: transparent; }
.btn-quiet-danger { color: var(--bad); }
.btn-quiet-danger:hover { background: var(--bad-bg); border-color: var(--bad-line); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }

/* ---------- Sub-navegação (separadores da secção) ---------- */
.subnav {
  display: flex; gap: 4px; overflow-x: auto; margin-bottom: 16px;
  border-bottom: 1px solid var(--line); scrollbar-width: none;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  padding: 10px 14px; margin-bottom: -1px; color: var(--muted); font-weight: 600; font-size: 14.5px;
  white-space: nowrap; border-bottom: 2px solid transparent;
}
.subnav a:hover { color: var(--ink); text-decoration: none; }
.subnav a[aria-current="page"] { color: var(--link); border-bottom-color: var(--blue); }

/* ---------- Pesquisa ---------- */
.toolbar {
  position: sticky; top: var(--topbar-h); z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 0; margin-bottom: 4px; background: var(--bg);
}
.search { display: flex; gap: 8px; flex: 1 1 360px; max-width: 620px; }
.field { position: relative; flex: 1; min-width: 0; }
.field .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input {
  width: 100%; min-height: 44px; padding: 0 14px 0 42px; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: 16px/1.2 var(--font);
}
.input::placeholder { color: var(--placeholder); }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 111, 214, .18); }
.search .btn { min-height: 44px; }
.clear-search { font-size: 14px; font-weight: 600; }

/* ---------- Cartão e tabela ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; box-shadow: 0 1px 2px rgba(11, 42, 82, .05); }
.table-scroll { overflow-x: auto; }
.dtable { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.dtable th {
  padding: 12px 16px; text-align: left; white-space: nowrap; font-size: 13px; font-weight: 600;
  color: var(--muted); background: var(--tint-2); border-bottom: 1px solid var(--line);
}
.dtable td { padding: 12px 16px; vertical-align: middle; border-bottom: 1px solid var(--line-soft); }
.dtable tbody tr:last-child td { border-bottom: 0; }
.dtable tbody tr:hover { background: var(--tint-2); }
.dtable .num { text-align: right; font-variant-numeric: tabular-nums; }
.dtable .center { text-align: center; }
.dtable .actions { text-align: right; white-space: nowrap; }
.dtable .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 340px; color: var(--muted); }
.dtable tr.is-zero td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.muted { color: var(--muted); }
.dash { color: var(--faint); }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty strong { color: var(--ink); }

.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--tint); color: var(--blue-700); font-weight: 700; font-size: 13px;
}
.person-name { font-weight: 600; color: var(--ink); }
a.person-name:hover { color: var(--link); text-decoration: none; }
.link-strong { font-weight: 600; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--tint); color: var(--blue-700);
}
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-min { margin-left: 8px; font-size: 12.5px; color: var(--muted); font-weight: 500; }

.icon-link {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--tint); color: var(--blue-700); transition: background .15s, color .15s;
}
.icon-link:hover { background: var(--blue); color: #fff; text-decoration: none; }

.section-title { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 10px; font-size: 18px; font-weight: 700; letter-spacing: -.005em; }
.section-title:first-of-type { margin-top: 6px; }
.section-title small { font-size: 13.5px; font-weight: 500; color: var(--muted); }


/* ---------- Botão de tema ---------- */
.theme-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .22); border-radius: var(--r-sm); background: transparent; color: #c6d6ec;
  transition: background .15s, color .15s;
}
.theme-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-btn .i-moon { display: none; }
}

/* ---------- Resumo (números) ---------- */
.stats {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; margin-bottom: 16px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.stat { padding: 16px 20px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font-size: 30px; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13.5px; }
.stat-main b { color: var(--link); }
.stat-hot b { color: var(--bad); }

/* ---------- Filtros ---------- */
.toolbar .search { flex: 0 0 500px; }
.chips { display: flex; gap: 6px; flex: 1 1 320px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted);
  font: 600 13.5px/1 var(--font); transition: background .15s, color .15s;
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--tint); color: var(--blue-700); border-color: transparent; }
.chip small { font-size: 12px; opacity: .75; font-variant-numeric: tabular-nums; }

/* ---------- Aviso ---------- */
.alert {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 11px 14px;
  border-radius: var(--r-sm); background: var(--warn-bg); color: var(--warn); font-weight: 600; font-size: 14.5px;
}
.alert a { color: inherit; font-weight: 700; text-decoration: underline; white-space: nowrap; }
.alert-close { margin-left: auto; display: grid; place-items: center; padding: 4px; border: 0; background: none; color: inherit; cursor: pointer; border-radius: 6px; }

/* ---------- Estados e documentos ---------- */
.st { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; background: var(--line-soft); color: var(--muted); }
.st-emrep, .st-aguardar, .st-enviado { background: var(--warn-bg); color: var(--warn); }
.st-entrada, .st-finalizado, .st-aceite { background: var(--ok-bg); color: var(--ok); }
.st-em-progresso { background: var(--tint); color: var(--blue-700); }
.st-cancelado { background: var(--bad-bg); color: var(--bad); }
.doc { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 6px; background: var(--tint); color: var(--blue-700); font-size: 12.5px; font-weight: 600; }
.doc .ico { width: 15px; height: 15px; }
.doc:hover { background: var(--blue); color: #fff; text-decoration: none; }
.doc-recibo { background: var(--ok-bg); color: var(--ok); }
.docs { display: inline-flex; gap: 6px; }
.date-warning { color: var(--bad); font-weight: 700; }

/* ---------- Lista de reparações ---------- */
.rep-id { font-weight: 700; color: var(--link); font-variant-numeric: tabular-nums; }
.c-eq { display: block; margin-top: 1px; font-size: 13.5px; color: var(--muted); }
a.c-eq:hover { color: var(--link); text-decoration: none; }
.dtable tr.group-row td { padding: 8px 16px; background: var(--tint-2); color: var(--muted); font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--line-soft); }
.dtable tbody tr.group-row:hover { background: var(--tint-2); }
.group-row small { margin-left: 6px; font-weight: 500; opacity: .8; }

/* ---------- Valor pendente (tecla E ×3) ---------- */
.finance-badge {
  position: fixed; right: 20px; bottom: 20px; z-index: 1000; display: flex; align-items: center; gap: 8px;
  padding: 12px 20px; border-radius: 999px; background: #12764f; color: #fff; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25); opacity: 0; pointer-events: none; transition: opacity .25s;
}
.finance-badge.show { opacity: 1; pointer-events: auto; }

/* ---------- Botão flutuante (telemóvel) ---------- */
.fab { display: none; }

/* ---------- Telemóvel: tabelas viram cartões ---------- */
@media (max-width: 860px) {
  .nav { display: none; }
  .user-chip .name { display: none; }
  .logout span { display: none; }
  .logout { padding: 8px 10px; }
  .finance-badge { bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); }
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); font-size: 11.5px; font-weight: 600; position: relative;
  }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a[aria-current="page"] { color: var(--link); }
  .tabbar a[aria-current="page"]::before {
    content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px;
    background: var(--blue); border-radius: 0 0 3px 3px;
  }
}

@media (max-width: 720px) {
  .topbar-in { padding: 0 14px; gap: 12px; }
  .brand img { height: 34px; }
  .page { padding: 16px 14px 32px; }
  .page-head h1 { font-size: 22px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .toolbar { margin: 0 -14px 4px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
  .search { flex-basis: 100%; max-width: none; }

  .card.cards-on-mobile { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .cards-on-mobile .table-scroll { overflow: visible; }
  .cards-on-mobile .dtable, .cards-on-mobile .dtable tbody { display: block; }
  .cards-on-mobile .dtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .cards-on-mobile .dtable tr {
    display: block; margin-bottom: 10px; padding: 4px 0; overflow: hidden;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  }
  .cards-on-mobile .dtable tbody tr:hover { background: var(--surface); }
  .cards-on-mobile .dtable tr.is-zero { box-shadow: inset 3px 0 0 var(--bad); }
  .cards-on-mobile .dtable tr.is-zero td:first-child { box-shadow: none; }
  .cards-on-mobile .dtable td {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 7px 14px; border: 0; text-align: right;
  }
  .cards-on-mobile .dtable td::before {
    content: attr(data-label); flex: none; color: var(--muted); font-size: 13px; font-weight: 500; text-align: left;
  }
  .cards-on-mobile .dtable td[data-primary] { display: block; padding: 10px 14px 6px; text-align: left; font-size: 16px; }
  .cards-on-mobile .dtable td[data-primary]::before { display: none; }
  .cards-on-mobile .dtable td[data-wide] { display: block; text-align: left; }
  .cards-on-mobile .dtable td[data-wide]::before { display: block; margin-bottom: 2px; }
  .cards-on-mobile .dtable td.actions { display: flex; justify-content: stretch; padding: 8px 14px 10px; }
  .cards-on-mobile .dtable td.actions::before { display: none; }
  .cards-on-mobile .dtable td.actions .btn { flex: 1; min-height: 42px; }
  .cards-on-mobile .dtable td.is-empty { display: none; }
  .cards-on-mobile .dtable .clamp { max-width: none; -webkit-line-clamp: 4; }
  .cards-on-mobile .dtable td.empty-row { display: block; text-align: center; }
  .cards-on-mobile .dtable td.empty-row::before { display: none; }
  .cards-on-mobile .empty { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }

  .stats { grid-auto-flow: row; grid-template-columns: 1fr 1fr; grid-auto-columns: auto; }
  .stat { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .stat:nth-child(2n) { border-right: 0; }
  .stat:nth-last-child(-n+2):nth-child(odd), .stat:last-child { border-bottom: 0; }
  .stat:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
  .stat b { font-size: 24px; }
  .toolbar .search { flex-basis: 100%; }
  .chips { flex-basis: 100%; }

  .reps-card { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .reps-card .table-scroll { overflow: visible; }
  .reps, .reps tbody { display: block; }
  .reps thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .reps tr.rep {
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 3px 12px; margin-bottom: 10px; padding: 12px 14px;
    grid-template-areas: "num estado" "cli cli" "data valor" "ent docs";
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  }
  .reps tbody tr.rep:hover { background: var(--surface); }
  .reps td { display: block; padding: 0; border: 0; }
  .reps .c-num { grid-area: num; }
  .reps .c-estado { grid-area: estado; justify-self: end; }
  .reps .c-cli { grid-area: cli; margin: 4px 0 2px; }
  .reps .c-cli .person-name { font-size: 16px; }
  .reps .c-data { grid-area: data; color: var(--muted); font-size: 13.5px; }
  .reps .c-valor { grid-area: valor; justify-self: end; font-weight: 600; }
  .reps .c-ent { grid-area: ent; color: var(--muted); font-size: 13.5px; }
  .reps .c-docs { grid-area: docs; justify-self: end; }
  .reps .c-data::before, .reps .c-ent::before { content: attr(data-label) " "; }
  .reps td.is-empty { display: none; }
  .reps tr.group-row { display: block; margin: 16px 2px 8px; padding: 0; background: none; border: 0; }
  .reps tr.group-row td { padding: 0; background: none; border: 0; }
  .reps tbody tr.group-row:hover { background: none; }

  .fab {
    display: grid; place-items: center; position: fixed; z-index: 55; right: 16px;
    bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); width: 52px; height: 52px;
    border-radius: 16px; background: var(--blue); color: #fff; box-shadow: 0 6px 16px rgba(29, 111, 214, .4);
  }
  .fab:hover { text-decoration: none; background: var(--blue-hover); }
  .fab .ico { width: 26px; height: 26px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* =========================================================
   Componentes adicionais (formulários, login, relatórios)
   ========================================================= */

/* ---------- Formulários ---------- */
.form-card { max-width: 880px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: 0 1px 2px rgba(11, 42, 82, .05); }
.form-card.wide { max-width: 1120px; }
.form-card + .form-card { margin-top: 16px; }
.form-section { margin: 0 0 26px; }
.form-section:last-of-type { margin-bottom: 0; }
.form-section > h2 { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.form-section > .hint { margin: 0 0 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.f { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.f > label, .label { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.req::after { content: " *"; color: var(--bad); }
.hint { color: var(--muted); font-size: 13px; }
.control {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: 16px/1.3 var(--font);
}
textarea.control { min-height: 110px; resize: vertical; }
.control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 111, 214, .18); }
.control[readonly], .control:disabled { background: var(--tint-2); color: var(--muted); }
input[type="file"].control { padding: 9px 10px; min-height: 0; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; accent-color: var(--blue); flex: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: var(--bad); filter: brightness(.92); border-color: var(--bad); }
.alert-bad { background: var(--bad-bg); color: var(--bad); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-info { background: var(--tint); color: var(--blue-700); }

/* ---------- Dados em lista (ficha) ---------- */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 24px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; margin: 0 0 2px; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ---------- Seletor segmentado (ex.: ano) ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--line-soft); border-radius: 10px; }
.seg a { padding: 7px 14px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap; }
.seg a:hover { color: var(--ink); text-decoration: none; }
.seg a[aria-current="true"] { background: var(--surface); color: var(--link); box-shadow: 0 1px 2px rgba(11, 42, 82, .12); }

/* ---------- Relatórios / totais ---------- */
.dtable tfoot td { padding: 12px 16px; font-weight: 700; background: var(--tint-2); border-top: 1px solid var(--line); }
.dtable tr.is-current td { background: var(--tint-2); }
.dtable tr.is-current td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
.tag-now { margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--tint); color: var(--blue-700); font-size: 12px; font-weight: 600; }
.report-block + .report-block { margin-top: 8px; }
.card-note { padding: 28px 20px; text-align: center; color: var(--muted); }
.rank { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--line-soft); color: var(--muted); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-1 { background: var(--warn-bg); color: var(--warn); }
.rank-2 { background: var(--tint); color: var(--blue-700); }
.rank-3 { background: var(--tint-2); color: var(--blue-700); border: 1px solid var(--line); }
.pill-no { background: var(--line-soft); color: var(--muted); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 28px rgba(11, 42, 82, .12); }
.auth-top { padding: 26px 24px; text-align: center; background: var(--navy); }
.auth-top img { height: 52px; width: auto; }
.auth-body { padding: 24px; }
.auth-body h1 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.01em; }
.auth-body > p { margin: 0 0 18px; color: var(--muted); font-size: 14.5px; }
.auth-body .f + .f { margin-top: 14px; }
.auth-body .btn { width: 100%; margin-top: 18px; min-height: 46px; font-size: 15px; }

@media (max-width: 960px) {
  .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .form-card { padding: 16px; }
  .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .form-actions {
    position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 10;
    margin: 20px -16px -16px; padding: 12px 16px; background: var(--surface); border-radius: 0 0 var(--r-md) var(--r-md);
  }
  .form-actions .btn { flex: 1; }
  .seg { width: 100%; }
  .seg a { flex: 1; text-align: center; }
  .dtable tfoot { display: block; }
  .cards-on-mobile .dtable tfoot td { display: flex; justify-content: space-between; padding: 8px 14px; background: transparent; border: 0; }
  .cards-on-mobile .dtable tfoot td::before { content: attr(data-label); font-weight: 500; color: var(--muted); }
  .cards-on-mobile .dtable tfoot tr { background: var(--tint-2); }
}

/* ---------- Barra de progresso (limite mensal) ---------- */
.meter-card { margin-bottom: 16px; padding: 16px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.meter-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; margin-bottom: 10px; font-weight: 600; }
.meter-head span { color: var(--muted); font-weight: 500; }
.meter { height: 12px; overflow: hidden; background: var(--line-soft); border-radius: 999px; }
.meter > i { display: block; height: 100%; min-width: 2px; border-radius: 999px; background: var(--ok); }
.meter.is-warn > i { background: #d99a1a; }
.meter.is-bad > i { background: var(--bad); }
.meter-pct { margin-top: 6px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dtable tr.is-paid td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.dtable tr.is-fuel td { background: var(--warn-bg); }
@media (max-width: 720px) {
  .cards-on-mobile .dtable tr.is-paid { box-shadow: inset 3px 0 0 var(--ok); }
  .cards-on-mobile .dtable tr.is-paid td:first-child { box-shadow: none; }
  .cards-on-mobile .dtable tr.is-current { box-shadow: inset 3px 0 0 var(--blue); }
  .cards-on-mobile .dtable tr.is-current td:first-child { box-shadow: none; }
}

/* ---------- Mensagens vindas do código antigo (HTML pronto) e pré-visualização de PDF ---------- */
.alert-error { background: var(--bad-bg); color: var(--bad); }
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-warning { background: var(--warn-bg); color: var(--warn); }
.alerts { max-width: 880px; }
.alerts .alert { align-items: flex-start; line-height: 1.45; font-weight: 500; }
.pdf-box { max-width: 880px; margin-top: 16px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.pdf-box-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.pdf-box embed { display: block; width: 100%; height: 70vh; border: 0; }

/* ---------- Duas colunas (formulário + lista) ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.split .form-card { max-width: none; }
.split .section-title { margin-top: 0; }
@media (max-width: 960px) { .split { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Login: campo de palavra-passe ---------- */
.pw-wrap { position: relative; }
.pw-wrap .control { padding-right: 88px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); height: 34px; padding: 0 12px; cursor: pointer;
  border: 0; border-radius: 6px; background: transparent; color: var(--link); font: 600 13.5px/1 var(--font);
}
.pw-toggle:hover { background: var(--tint); }
.auth-foot { margin: 18px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.auth-foot a { font-weight: 600; }

/* ---------- Ficha de reparação ---------- */
.rep-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.rep-grid .form-card { max-width: none; }
.card-title { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-size: 16px; font-weight: 700; }
.card-title .ico { color: var(--link); }
.rep-grid .f + .f { margin-top: 14px; }
.rep-grid .f.full + .f.full { margin-top: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.control.is-invalid { border-color: var(--bad); }

.fin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.fin { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--tint-2); }
.fin .label { display: block; margin-bottom: 2px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.fin .value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fin .value a { color: inherit; }
.fin.total { grid-column: 1 / -1; background: var(--tint); border-color: transparent; }
.fin.total .value { color: var(--blue-700); font-size: 24px; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--tint-2); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb-del {
  position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(11, 26, 46, .72); color: #fff; font-size: 17px; line-height: 1; cursor: pointer;
}
.thumb-del:hover { background: var(--bad); }
.thumbs-empty { grid-column: 1 / -1; padding: 14px; text-align: center; color: var(--muted); }
.file-list { display: flex; flex-direction: column; gap: 6px; }
.file-list .doc { align-self: flex-start; max-width: 100%; padding: 6px 10px; font-size: 13.5px; word-break: break-all; }
.file-empty { margin: 0; color: var(--muted); font-size: 14px; }

.save-bar {
  position: sticky; bottom: 0; z-index: 15; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  margin-top: 16px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 -4px 14px rgba(11, 42, 82, .08);
}
.save-bar .muted { font-size: 14px; }

@media (max-width: 1200px) {
  .rep-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rep-grid > :nth-child(3) { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .save-bar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); }
}
@media (max-width: 720px) {
  .rep-grid { grid-template-columns: minmax(0, 1fr); }
  .save-bar .btn { flex: 1; }
}

.rep-grid > .form-card { margin-top: 0; }
.fin-grid.fin-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 10px; }
.fin-grid.fin-grid-3 .fin { padding: 10px 12px; }
.fin-grid.fin-grid-3 .fin .value { font-size: 16px; }
.auth-body > p.auth-foot { margin: 18px 0 0; }

/* Blocos empilhados em largura total (ex.: ficha de cliente: formulário + tabela) */
.stack-lg { display: flex; flex-direction: column; gap: 8px; }
.stack-lg > .form-card { max-width: none; }
.stack-lg .section-title { margin-top: 18px; }

/* Páginas de formulário: cabeçalho, avisos e formulário alinhados na mesma largura */
.page.narrow { max-width: 920px; }
.page.narrow-wide { max-width: 1160px; }
