/* ==========================================================================
   MoMA — Controle de Obra
   Visual: grafite/azul-petróleo, fundo neutro claro, um único acento âmbar
   (só ações principais). Cores, tipografia, espaços e raios vêm de
   css/tokens.css (cópia idêntica nos dois apps; ver README). Aqui ficam só
   os APELIDOS usados pelas regras antigas e os componentes.
   ========================================================================== */

:root {
  --brand: var(--cor-primaria);
  --brand-600: #13606f;
  --brand-700: var(--cor-primaria-forte);
  --brand-800: #072c34;
  --brand-300: var(--cor-primaria-linha);
  --brand-100: #c8dde1;
  --brand-050: var(--cor-primaria-suave);

  --bg: var(--cor-fundo);
  --surface: var(--cor-superficie);
  --surface-2: var(--cor-superficie-2);

  --text: var(--cor-texto);
  --text-2: var(--cor-texto-2);
  --muted: var(--cor-texto-suave);

  --line: var(--cor-linha);
  --line-2: var(--cor-linha-2);
  --line-strong: #a9b4b9;

  --ok: var(--cor-ok);         --ok-bg: var(--cor-ok-fundo);
  --warn: var(--cor-alerta);   --warn-bg: var(--cor-alerta-fundo);
  --danger: var(--cor-perigo); --danger-bg: var(--cor-perigo-fundo);

  --shadow-sm: var(--sombra-1);
  --r: var(--raio);
  --r-sm: var(--raio-sm);
  --r-lg: var(--raio-lg);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--fonte);
  font-size: var(--fs-base);
  line-height: var(--entrelinha);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
/* Layout em coluna: cabeçalho e navegação no topo, #app-scroll ocupa o resto
   (sem depender de alturas fixas somadas em calc()). */
body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
:focus-visible { outline: var(--foco-contorno); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: transparent; color: inherit; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

/* ------------------------------ Header ------------------------------ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 20px;
  flex: none;
  background: var(--cor-cabecalho);
  color: var(--cor-cabecalho-texto);
  border-bottom: 1px solid var(--cor-primaria-forte);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 7px;
  border-radius: var(--r-sm);
  background: var(--cor-acento);
  color: var(--cor-sobre-acento);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title {
  font-size: 14.5px;
  font-weight: 650;
  color: var(--cor-cabecalho-texto);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  font-size: 11.5px;
  color: var(--cor-cabecalho-texto-2);
  line-height: 1.25;
  letter-spacing: 0.01em;
}
.header-right { display: flex; align-items: center; gap: 12px; flex: none; }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--line-2);
  white-space: nowrap;
}
.status-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-chip.is-online { color: var(--ok); background: var(--ok-bg); }
.status-chip.is-offline { color: var(--warn); background: var(--warn-bg); }
.sync-status { font-size: 12px; color: var(--cor-cabecalho-texto-2); white-space: nowrap; }
.app-header .btn-ghost { color: var(--cor-cabecalho-texto); }
.app-header .btn-ghost:hover { background: rgb(255 255 255 / 0.12); color: var(--cor-cabecalho-texto); }
.app-header :focus-visible { outline-color: var(--cor-acento); }

/* ------------------------------ Navegação ------------------------------ */
.app-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  position: sticky;
  top: 56px;
  z-index: 30;
  flex: none;
  height: 48px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 2px rgb(12 30 36 / 0.05);
  scrollbar-width: none;
}
.app-nav::-webkit-scrollbar { display: none; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 48px;
  padding: 0 13px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
}
.nav-link:hover { color: var(--brand); background: var(--brand-050); }
.nav-link.active {
  color: var(--cor-primaria);
  font-weight: 700;
  border-bottom-color: var(--cor-primaria);
}
.nav-spacer { flex: 1; }

/* ------------------------------ Layout ------------------------------ */
/* O scroll fica no wrapper (#app-scroll), que NUNCA troca de conteudo.
 * Assim, quando o modulo troca o innerHTML de #app-main, a posicao de
 * rolagem do usuario e preservada pelo navegador (sem "flick").
 * O overflow-x tambem e "auto" (e nao "hidden") para que o sticky das
 * tabelas funcione: com overflow-x hidden, o elemento vira um container
 * de scroll proprio e o sticky para de grudar. */
#app-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  overscroll-behavior-y: contain;
  scroll-behavior: auto;
}
#app-main {
  padding: 20px;
  min-height: 100%;
}
.page { max-width: 1500px; margin: 0 auto; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-title { font-size: var(--fs-xl); font-weight: var(--peso-titulo); color: var(--text); letter-spacing: -0.015em; }
.page-desc { font-size: 13.5px; color: var(--text-2); margin-top: 3px; max-width: 76ch; }

/* ------------------------------ Cartões ------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-title { font-size: 15px; font-weight: 650; color: var(--text); }
.card-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.card-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ------------------------------ Formulários ------------------------------ */
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: 0.02em;
}
.input, .select, .textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--cor-borda-campo);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--cor-primaria);
  box-shadow: var(--foco-anel);
}
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.textarea { resize: vertical; min-height: 58px; }
.input-sm { min-height: 32px; padding: 4px 8px; font-size: 13px; }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--cor-superficie-3); }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { accent-color: var(--brand); width: 17px; height: 17px; }
.hint { font-size: 12px; color: var(--muted); }

/* ------------------------------ Botões ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  transition: background var(--transicao), border-color var(--transicao), color var(--transicao);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--cor-primaria); color: var(--cor-primaria); background: var(--cor-primaria-suave); }
.btn:active { transform: translateY(1px); }
/* Ação principal: o ÚNICO uso do âmbar na interface */
.btn-primary { background: var(--cor-acento); border-color: var(--cor-acento-borda); color: var(--cor-sobre-acento); }
.btn-primary:hover { background: var(--cor-acento-hover); border-color: var(--cor-acento-borda); color: var(--cor-sobre-acento); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--cor-primaria-suave); color: var(--cor-primaria); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: #e3a9a4; background: var(--surface); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-icon { padding: 4px 7px; }

/* ------------------------------ Tabelas ------------------------------ */
.table-wrap {
  overflow-x: auto;
  margin: 0 -18px -18px;
  padding: 0 18px 4px;
  -webkit-overflow-scrolling: touch;
  /* sombra nas bordas quando há mais colunas para rolar (só CSS) */
  background:
    linear-gradient(to right, var(--surface) 30%, rgb(255 255 255 / 0)) left / 24px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, rgb(255 255 255 / 0)) right / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgb(22 36 43 / 0.16), transparent) left / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgb(22 36 43 / 0.16), transparent) right / 10px 100% no-repeat scroll;
}
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 9px 12px 9px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 13.5px;
  vertical-align: middle;
}
td { font-variant-numeric: tabular-nums; }
th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  border-bottom: 2px solid var(--line-strong);
  white-space: nowrap;
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}

/* Tabelas grandes: cabecalho fixo durante a rolagem.
   A tabela tem a propria area de rolagem (altura maxima), e o cabecalho
   fica grudado no topo dela. Isso e mais confiavel que sticky na pagina
   (que conflita com o scroll do #app-scroll) e evita perder a coluna
   "Ponto"/"Ações" em telas estreitas. */
.table-wrap.sticky-head {
  max-height: min(62vh, 720px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
}
.table-wrap.sticky-head thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--line);
}
.table-wrap.sticky-head tbody tr:hover td { background: var(--surface-2); }
.table-wrap.sticky-head table { min-width: 720px; }
/* tabelas muito largas mantem rolagem horizontal dentro da area propria */
.table-wrap.sticky-head.largo table { min-width: 980px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; padding-right: 16px; }
td.actions-cell { text-align: right; padding-right: 0; white-space: nowrap; }
.cell-strong { font-weight: 600; color: var(--text); }
.cell-muted { color: var(--text-2); }
.row-actions { display: inline-flex; gap: 4px; }

/* ------------------------------ Badges ------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--raio-pilula);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #9fd2b3; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #e8c47e; }
.badge-bad { background: var(--danger-bg); color: var(--danger); border: 1px solid #eba9a2; }
.badge-neutral { background: var(--cor-superficie-3); color: var(--text-2); border: 1px solid var(--line); }
.badge-brand { background: var(--brand-050); color: var(--brand-700); border: 1px solid var(--brand-100); }

/* ------------------------------ Corte esquemático ------------------------------ */
.corte-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.corte-col { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.corte-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
}
.corte-col.is-b { opacity: 0.62; }
.corte-col.is-b .corte-col-head { opacity: 1; }
.corte-items { max-height: 620px; overflow-y: auto; }
.corte-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line-2);
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.12s;
}
.corte-item:last-child { border-bottom: none; }
.corte-item:hover { filter: brightness(0.97); }

/* Em execução: 100% escorado (destaque com faixa lateral) */
.corte-item.is-execucao {
  background: var(--brand-050);
  box-shadow: inset 3px 0 0 var(--brand);
  font-weight: 600;
}
/* 100% reescorado */
.corte-item.is-100 { background: var(--brand); color: #fff; }
/* 50% reescorado */
.corte-item.is-50 { background: var(--brand-100); }
/* 25% reescorado */
.corte-item.is-25 { background: #e8f3f4; }
/* Concretado e liberado (sem escoramento) */
.corte-item.is-liberado { background: #fff; color: var(--text-2); }
/* Concretagem prevista */
.corte-item.is-previsto { background: #fff; color: var(--muted); }
/* Ainda nao existe */
.corte-item.is-futuro { background: var(--surface-2); color: var(--muted); }

.corte-pav {
  flex: none;
  min-width: 38px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.corte-tipo { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.corte-pct {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.6);
  color: var(--brand-700);
}
.corte-item.is-100 .corte-pct { background: rgb(255 255 255 / 0.22); color: #fff; }
.corte-item.is-25 .corte-pct,
.corte-item.is-50 .corte-pct { background: rgb(255 255 255 / 0.75); }
.corte-item.is-futuro .corte-pct { background: var(--line-2); color: var(--muted); }
.corte-item.is-liberado .corte-pct,
.corte-item.is-previsto .corte-pct { background: var(--line-2); color: var(--muted); font-weight: 600; }
.corte-item.is-execucao .corte-pct { background: var(--brand); color: #fff; }
.corte-flag {
  flex: none;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--brand);
  color: #fff;
}
.corte-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 11.5px; color: var(--muted); }
.corte-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; border: 1px solid var(--line); }

/* ------------------------------ Stat tiles ------------------------------ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand-300);
  border-radius: var(--r);
  padding: 13px 15px;
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 11.5px; color: var(--text-2); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value {
  font-size: 23px;
  font-weight: 700;
  color: var(--cor-primaria);
  line-height: 1.25;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.stat-note { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.stat.destaque { border-left-color: var(--brand); background: var(--brand-050); }
.stat.alerta { border-left-color: var(--warn); background: var(--warn-bg); }
.stat.alerta .stat-value { color: var(--warn); }

/* ------------------------------ Modal ------------------------------ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgb(22 36 43 / 0.5);
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal.open { display: flex; }

/* O painel usa a classe ".panel" (criada em js/ui.js) */
.modal > .panel {
  background: var(--surface);
  width: 100%;
  max-width: 780px;
  max-height: calc(100vh - 40px);
  border-radius: var(--r-lg);
  padding: 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: var(--sombra-3);
  animation: modal-entra 0.14s ease-out;
}
@keyframes modal-entra {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.modal > .panel > h3 {
  font-size: 17px;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: -22px;
  background: var(--surface);
  z-index: 2;
}
.modal > .panel > .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: -22px;
  background: var(--surface);
  padding-bottom: 4px;
}
/* forma compacta para os modais de linha */
.modal > .panel.compacto { max-width: 560px; }
.modal > .panel.largo { max-width: 980px; }

/* ------------------------------ Toast ------------------------------ */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 110;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--cor-toast);
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--sombra-3);
  transform: translateY(140%);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
  pointer-events: none;
  max-width: 380px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-ok { background: var(--cor-ok); }
.toast-bad { background: var(--cor-perigo); }

/* ------------------------------ Utilidades ------------------------------ */
.empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }
.text-right { text-align: right; }
.text-muted { color: var(--text-2); }
.mono { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--line); margin: 14px 0; border: none; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--surface);
}
.pill.is-on { border-color: var(--brand); background: var(--brand-050); color: var(--brand); font-weight: 600; }

/* Seleção múltipla de colaboradores (diárias) */
.pick-list {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  max-height: 260px;
  overflow-y: auto;
}
.pick-head {
  display: grid;
  grid-template-columns: 20px minmax(90px, 1fr) 92px 84px 84px 56px;
  gap: 6px;
  padding: 6px 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-2);
}
.pick-head span:nth-child(n+3) { text-align: center; }
.pick-list:has(+ .pick-head) { border-radius: 0 0 var(--r-sm) var(--r-sm); }
.pick-row {
  display: grid;
  grid-template-columns: 20px minmax(90px, 1fr) 92px 84px 84px 56px;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
}
.pick-row:last-child { border-bottom: none; }
.pick-row:hover { background: var(--surface-2); }
.pick-row .pick-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-row input[type="checkbox"] { accent-color: var(--brand); width: 15px; height: 15px; }
.pick-qtd, .pick-hora { width: 100%; }
.pick-hora { text-align: center; }
.pick-horas {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.pick-row.is-off { opacity: 0.45; }
@media (max-width: 760px) {
  .pick-head { display: none; }
  .pick-row { grid-template-columns: 22px 1fr 92px; grid-auto-rows: auto; row-gap: 6px; }
  .pick-row .pick-hora, .pick-row .pick-horas { grid-column: span 1; }
}

/* ------------------------------ Login ------------------------------ */
.login-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 14px;
  max-width: 900px;
  margin: 0 auto;
  padding-top: 12px;
}
.login-card { margin-bottom: 0; }
.login-info { margin-bottom: 0; }
@media (max-width: 760px) {
  .login-wrap { grid-template-columns: 1fr; }
}

/* ------------------------------ Relatórios ------------------------------ */
.rel-opcao {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.rel-opcao:hover { border-color: var(--brand-300); background: var(--surface-2); }
.rel-opcao input { accent-color: var(--brand); width: 16px; height: 16px; margin-top: 2px; flex: none; }
.rel-opcao-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rel-opcao-txt strong { font-size: 13.5px; font-weight: 600; }
.rel-opcao-txt small { font-size: 11.5px; color: var(--muted); }

/* Área de impressão (visível só na impressão ou na prévia) */
.area-impressao { display: none; }
body.imprimindo .app-header,
body.imprimindo .app-nav,
body.imprimindo #app-scroll { display: none !important; }
body.imprimindo .area-impressao { display: block; }
.area-impressao.is-preview {
  position: fixed;
  inset: 0;
  z-index: 200;
  overflow: auto;
  background: #e8ecec;
  padding: 24px;
}
.area-impressao.is-preview > *:not(.preview-fechar) {
  max-width: 1100px;
  margin: 0 auto 16px;
  background: #fff;
  padding: 20px;
  box-shadow: 0 4px 18px rgb(18 38 44 / 0.12);
}
.preview-fechar {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 210;
  box-shadow: 0 4px 14px rgb(18 38 44 / 0.25);
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  html, body { background: #fff !important; height: auto !important; }
  body { display: block !important; }
  .area-impressao { display: block !important; position: static !important; overflow: visible !important; background: #fff !important; padding: 0 !important; }
  #app-scroll { display: none !important; }
  .area-impressao.is-preview > *:not(.preview-fechar) { box-shadow: none !important; padding: 0 !important; max-width: none !important; margin: 0 !important; }
  .preview-fechar { display: none !important; }
  .rel-cabecalho { break-after: avoid; page-break-after: avoid; }
  .rel-bloco { break-inside: auto; }
  .rel-tabela thead { display: table-header-group; }
  .rel-tabela tfoot { display: table-footer-group; }
  .rel-tabela tr { break-inside: avoid; page-break-inside: avoid; }
}

@media (max-width: 900px) {
  .corte-wrap { grid-template-columns: 1fr; }
}

/* ===== Previsão de Custo Mensal (#6) ===== */
.mt-6 { margin-top: 6px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; }
.mb-6 { margin-bottom: 6px; }

.prv-passos { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.prv-passo {
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 6px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.prv-passo:hover { border-color: var(--brand); color: var(--brand-700); }
.prv-passo.is-ativo { background: var(--brand); border-color: var(--brand); color: #fff; }
.prv-passo.is-disabled { opacity: .45; cursor: not-allowed; }

.prv-alerta {
  border: 1px solid var(--line); border-left-width: 3px; border-radius: 8px;
  padding: 9px 12px; font-size: 12.5px; color: var(--text-2); background: var(--surface);
}
.prv-alerta-info { border-left-color: var(--brand); background: var(--brand-050); color: var(--brand-700); }
.prv-alerta-warn { border-left-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
.prv-alerta-ok { border-left-color: var(--ok); background: var(--ok-bg); color: var(--ok); }

#mod-previsao .prv-sobrescrita td { background: var(--warn-bg); }
#mod-previsao tfoot td { border-top: 2px solid var(--line); font-weight: 700; padding-top: 8px; }
#mod-previsao tbody td { vertical-align: middle; }
#mod-previsao .prv-qtd, #mod-previsao .prv-just { min-width: 96px; }
#mod-previsao .prv-grupo td { background: var(--surface-2); font-weight: 600; font-size: 12.5px; }
#mod-previsao .prv-item.is-off td { opacity: .5; }
#mod-previsao .prv-glob { margin-left: 8px; }
@media (max-width: 640px) {
  .app-header { height: auto; padding: 9px 14px; flex-wrap: wrap; gap: 8px; }
  .brand-sub { display: none; }
  /* celular: Sincronizar sobe para a linha da marca; conta + status embaixo */
  .app-header { display: grid; grid-template-columns: auto auto 1fr auto; column-gap: 8px; row-gap: 6px; }
  .header-right { display: contents; }
  .brand { grid-column: 1 / 4; grid-row: 1; }
  #btn-sync { grid-column: 4; grid-row: 1; }
  #btn-usuario { grid-column: 1; grid-row: 2; justify-self: start; padding-left: 0; }
  .app-header .status-chip { grid-column: 2; grid-row: 2; }
  .sync-status { grid-column: 3 / 5; grid-row: 2; overflow: hidden; text-overflow: ellipsis; }
  .app-nav { top: 0; position: sticky; padding: 0 8px; }
  .nav-link { padding: 0 12px; }
  #app-main { padding: 14px; }
  .page-head { margin-bottom: 14px; }
  .card { padding: 14px; }
  .table-wrap { margin: 0 -14px -14px; padding: 0 14px 4px; }
  .modal { padding: 10px; align-items: flex-end; }
  .modal > .panel { max-height: 92vh; max-width: 100%; padding: 16px; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .modal > .panel > h3 { top: -16px; }
  .modal > .panel > .actions { bottom: -16px; flex-wrap: wrap; }
  .modal > .panel > .actions .btn { flex: 1 1 140px; }
  .toast { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); max-width: none; }
  .page-head > .btn, .page-head > div > .btn { min-height: var(--toque-min); }
}

/* ---------------------------------------------------------------------------
   Celular e telas de toque: fonte base 16px (iOS não dá zoom em campo ≥16px),
   alvos de toque ≥44px, botões grandes. Vale também para tablet (pointer:coarse).
---------------------------------------------------------------------------- */
@media (max-width: 640px), (pointer: coarse) {
  html, body { font-size: var(--fs-base-movel); }
  .btn, .btn-sm { min-height: var(--toque-min); padding: 8px 14px; font-size: 15px; }
  .btn-icon { min-width: var(--toque-min); }
  .input, .select, .textarea, .input-sm { min-height: var(--toque-min); font-size: 16px; }
  .nav-link { height: 52px; font-size: 14.5px; }
  .label { font-size: 13px; }
  .hint, .card-sub, .stat-note { font-size: 13px; }
  .page-desc { font-size: 14.5px; }
  th { font-size: 12px; }
  td { font-size: 15px; padding-top: 11px; padding-bottom: 11px; }
  .badge { font-size: 12.5px; }
  .check { font-size: 15px; min-height: var(--toque-min); }
  .check input, .pick-row input[type="checkbox"], .rel-opcao input { width: 22px; height: 22px; }
  .pick-row { font-size: 15px; padding: 8px 11px; }
  .rel-opcao { padding: 13px 14px; }
  .rel-opcao-txt strong { font-size: 15px; }
  .rel-opcao-txt small { font-size: 13px; }
  .corte-item { font-size: 14px; padding: 10px 12px; min-height: var(--toque-min); }
  .prv-passo { min-height: var(--toque-min); font-size: 14px; }
  .status-chip { font-size: 12px; padding: 4px 10px; }
  .row-actions { gap: 6px; }
}

/* ---------------------------------------------------------------------------
   Somente leitura (visitante ou visualizador)

   O JS desliga os controles que já existem no render; estas regras cobrem os
   botões que as tabelas montam depois, quando as linhas chegam do IndexedDB.
   A segurança de verdade é o RLS no banco (exige login + appKey + papel
   editor/admin) — isto aqui é só aparência e prevenção de confusão.
---------------------------------------------------------------------------- */
.so-leitura :is(button, input, select, textarea):enabled { opacity: 0.5; }

/* continuam plenamente utilizáveis: filtros da tabela e o botão do aviso */
.so-leitura .card-tools :is(button, input, select, textarea):enabled,
.so-leitura #rel-excel:enabled,
.so-leitura #rel-pdf:enabled,
.so-leitura #btn-ir-login:enabled { opacity: 1; }
