:root {
  --bg: #0b1d33;
  --bg-soft: #122540;
  --sidebar: #0e2138;
  --card: #17294a;
  --card-soft: #1d3457;
  --text: #f2f5fb;
  --muted: #8d9bb5;
  --border: rgba(255,255,255,0.08);

  --orange: #ff7a00;
  --violet: #7c3aed;
  --blue: #126bff;
  --indigo: #6366f1;
  --cyan: #00c2ff;
  --green: #22c55e;
  --amber: #ffc107;
  --red: #ef4444;
  --slate: #64748b;

  --grad-main: linear-gradient(135deg, #475569 0%, #1e293b 100%);
  --grad-warm: linear-gradient(135deg, #ffc107 0%, #ef4444 100%);
  --grad-ok: linear-gradient(135deg, #22c55e 0%, #00c2ff 100%);
  --grad-pink: linear-gradient(135deg, #7c3aed 0%, #126bff 100%);
  --grad-text: linear-gradient(135deg, #f8fafc 0%, #94a3b8 100%);

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 24px 48px -16px rgba(0,0,0,0.45), 0 4px 12px rgba(0,0,0,0.18);
  --glass: rgba(11,29,51,0.72);
}

:root[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --sidebar: #ffffff;
  --card: #ffffff;
  --card-soft: #eef1f8;
  --text: #101a2e;
  --muted: #64748b;
  --border: rgba(16,26,46,0.08);
  --shadow: 0 24px 48px -20px rgba(10,25,48,0.18), 0 4px 12px rgba(10,25,48,0.06);
  --glass: rgba(255,255,255,0.72);
  --grad-text: linear-gradient(135deg, #1e293b 0%, #475569 100%);
}

* { box-sizing: border-box; }
html, body { height: 100%; overscroll-behavior-y: contain; }
body {
  margin: 0;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  background: radial-gradient(1200px 600px at 100% -10%, #4a2c1f 0%, transparent 60%),
              radial-gradient(1000px 500px at -10% 110%, #0d3350 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  transition: background .2s, color .2s;
}
:root[data-theme="light"] body {
  background: radial-gradient(1200px 600px at 100% -10%, #ffe8d9 0%, transparent 60%),
              radial-gradient(1000px 500px at -10% 110%, #dff3fb 0%, transparent 55%),
              var(--bg);
}

.app { display: flex; min-height: 100vh; min-height: 100dvh; }

/* Mobile top bar (hidden on desktop) */
.mobile-topbar { display: none; }
.mobile-bottombar { display: none; }
.gantt-dica { display: none; }
#eapGanttScroll, #lbGanttScroll { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.login-extra { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 13px; }
.login-extra[hidden], .field[hidden] { display: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: var(--text); }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(5,6,20,0.55); z-index: 90;
}
.sidebar-overlay.open { display: block; }

/* Sidebar */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: #2a4365;
  border-right: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  transition: width .2s ease;
  overflow-x: hidden;
}
/* A barra lateral fica sempre azul-marinho, independente do modo claro/escuro
   do resto do app — por isso os tons de texto/ícone aqui são fixos, não usam
   as variáveis de tema (que mudariam pra escuro em cima de um fundo escuro). */
.sidebar .brand-text strong { color: #f2f5fb; }
.sidebar .brand-text span { color: #8d9bb5; }
.sidebar .nav-group-label { color: #f2f5fb; }
.sidebar .nav-item { color: #8d9bb5; }
.sidebar .nav-item:hover { background: rgba(255,255,255,0.08); color: #f2f5fb; }
.sidebar .sync-status { color: #8d9bb5; background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.1); }
.sidebar .sync-status.online { color: #4ade80; }
.sidebar .sync-status.error { color: #fbbf24; }
.sidebar .btn-ghost, .sidebar .icon-btn {
  background: rgba(255,255,255,0.06); color: #8d9bb5; border-color: rgba(255,255,255,0.1);
}
.sidebar .btn-ghost:hover, .sidebar .icon-btn:hover { color: #f2f5fb; border-color: rgba(255,255,255,0.25); }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; }
.brand-badge {
  width: 42px; height: 42px; border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 6px 16px rgba(255,122,0,0.4);
  flex-shrink: 0;
}
.brand-badge.sm { width: 32px; height: 32px; font-size: 14px; border-radius: 9px; }
.brand-badge.lg { width: 64px; height: 64px; font-size: 26px; border-radius: 16px; margin: 0 auto 16px; }
.brand-text { display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 15px; white-space: nowrap; }
.brand-text span { font-size: 11px; color: var(--muted); white-space: normal; }
.sidebar-collapse-btn { margin-left: auto; flex-shrink: 0; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; margin-top: 6px; }
.nav-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.nav-group[hidden] { display: none; }
.nav-group-label {
  font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text); padding: 10px 14px 7px; margin-top: 2px;
}
.sidebar.collapsed .nav-group-label { display: none; }
.nav-item[hidden] { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: none; color: var(--muted);
  padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  text-align: left; width: 100%;
  min-height: 54px;
  transition: background .18s ease, color .18s ease, transform .15s ease, box-shadow .18s ease;
  position: relative;
}
.nav-item .ico { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
/* Um rótulo mais longo (ex.: "Cronograma de Suprimentos") não cabe numa
   linha só na largura da barra lateral. min-width:0 + white-space:normal
   deixam o texto quebrar linha em vez de vazar do fundo branco do item
   ativo. Só isso, porém, faz a caixa do rótulo ocupar todo o espaço que
   sobrou na linha (jeito como o flexbox mede um item que quebra linha) —
   com o texto centralizado nessa caixa larga, ele fica flutuando longe do
   ícone. Por isso os rótulos que realmente precisam de 2 linhas (ver
   index.html) têm uma quebra manual (<br>) no ponto certo: com a quebra já
   escrita, a caixa fica do tamanho da linha mais larga (coladinha no
   ícone), e text-align:center só equilibra as duas linhas entre si. */
.nav-item .label { min-width: 0; white-space: normal; line-height: 1.25; overflow-wrap: break-word; text-align: center; }
/* Ícone minimalista (sem cor própria por item, herda currentColor), mas com
   um chip suave por trás e cor mais clara que o rótulo — pra ter presença
   sem voltar ao quadrado colorido por ícone de antes. */
.ico-badge {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: #dbe6f7;
  flex-shrink: 0;
  transition: transform .18s ease, background .18s ease;
}
.ico-badge svg { width: 19px; height: 19px; display: block; stroke-width: 2; }
.sidebar.collapsed .ico-badge { margin: 0 auto; }
.nav-item:hover { background: rgba(127,127,160,0.12); color: var(--text); }
.nav-item:hover .ico-badge { transform: scale(1.1); background: rgba(255,255,255,0.16); }
.nav-item.active {
  background: #e5e9f0;
  color: #1e293b;
  border: 1.5px solid #ffc38a;
  box-shadow: none;
  transform: translateY(-1px);
}
.nav-item.active .ico-badge { background: rgba(30,41,59,0.1); color: #1e293b; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
}

.sidebar-footer { display: flex; flex-direction: column; gap: 8px; }
.sync-status {
  font-size: 11px; font-weight: 700; color: var(--muted);
  background: var(--card-soft); border: 1px solid var(--border);
  padding: 8px 10px; border-radius: var(--radius-sm); text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sync-status.online { color: var(--green); }
.sync-status.error { color: var(--amber); }
.btn-ghost {
  display: flex; align-items: center; gap: 8px;
  background: var(--card-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  width: 100%;
}
.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }
.btn-ghost .ico { width: 16px; text-align: center; flex-shrink: 0; }
.btn-ghost[hidden] { display: none; }

/* Collapsed sidebar (icon-only) */
.sidebar.collapsed { width: 76px; }
.sidebar.collapsed .brand { flex-direction: column; justify-content: center; gap: 8px; padding: 4px 0; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item .label,
.sidebar.collapsed .nav-item .nav-badge,
.sidebar.collapsed .btn-ghost .label,
.sidebar.collapsed .sync-status { display: none; }
.sidebar.collapsed .sidebar-collapse-btn { margin: 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 11px; }
.sidebar.collapsed .btn-ghost { justify-content: center; }

/* Content */
.content { flex: 1; min-width: 0; padding: 30px 36px 60px; max-width: 1400px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 12px; }
.topbar h1 {
  margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -0.025em;
  background: var(--grad-text); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.muted { color: var(--muted); margin: 4px 0 0; font-size: 13.5px; }
.page-title-badge {
  display: inline-block; vertical-align: middle; margin-left: 12px; padding: 4px 12px;
  border-radius: 999px; font-size: 12.5px; font-weight: 700; letter-spacing: normal;
  background: var(--card-soft); color: var(--muted); -webkit-text-fill-color: var(--muted);
  border: 1px solid var(--border);
}
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.view { display: none; }
.view.active { display: block; animation: fadein .3s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0);} }

#view-cashflow.active { display: flex; flex-direction: column; }
.cashflow-frame-wrap {
  width: 100%; height: calc(100vh - 160px); height: calc(100dvh - 160px); min-height: 480px;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.cashflow-frame { width: 100%; height: 100%; border: none; display: block; }
@media (max-width: 900px) {
  .cashflow-frame-wrap { height: calc(100vh - 220px); height: calc(100dvh - 220px); }
}

/* Buttons */
.btn {
  border: none; cursor: pointer; font-weight: 700; font-size: 13.5px;
  padding: 11px 20px; border-radius: 980px; color: #1e2530;
  background: #d5d9e0;
  box-shadow: 0 8px 20px -6px rgba(16,26,46,0.25);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -6px rgba(16,26,46,0.3); background: #c9cedb; }
.btn:active { transform: translateY(0); }
.btn.secondary {
  background: var(--card-soft); color: var(--text); box-shadow: none;
  border: 1px solid var(--border);
}
.btn.small { padding: 7px 14px; font-size: 12px; }
.btn.danger { background: var(--grad-warm); color: white; box-shadow: 0 8px 20px -6px rgba(239,68,68,0.45); }
.btn.secondary.active { background: var(--orange); color: #fff; border-color: transparent; }
.btn.ata-record { background: linear-gradient(135deg, #f59e0b, #ff7a00); color: #fff; box-shadow: 0 8px 20px -6px rgba(245,158,11,0.45); }
.btn.ata-record:hover { box-shadow: 0 10px 24px -6px rgba(245,158,11,0.55); }
.btn.recording { background: #ef4444; box-shadow: 0 8px 20px -6px rgba(239,68,68,0.5); animation: ata-pulse 1.4s ease-in-out infinite; }
@keyframes ata-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .7; } }
@keyframes impacto-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.65); } 50% { box-shadow: 0 0 0 9px rgba(220,38,38,0); } }
.impacto-raiz { animation: impacto-pulse 1.5s ease-in-out infinite; }
@keyframes impacto-faixa-pulso { 0%, 100% { background: #b71c1c; box-shadow: 0 0 0 0 rgba(183,28,28,.65); } 50% { background: #ec3b37; box-shadow: 0 0 0 12px rgba(183,28,28,0); } }
@keyframes impacto-faixa-amarela { 0%, 100% { background: #f5b400; box-shadow: 0 0 0 0 rgba(245,180,0,.6); } 50% { background: #ffd54a; box-shadow: 0 0 0 10px rgba(245,180,0,0); } }
.impacto-faixa { background: #b71c1c; animation: impacto-faixa-pulso 1.2s ease-in-out infinite; }
.impacto-faixa.amarela { background: #f5b400; animation: impacto-faixa-amarela 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .impacto-faixa, .impacto-raiz { animation: none; } }
.agenda-tatico-status {
  background: #16a34a; color: #fff; font-weight: 800; font-size: 13px;
  text-align: center; padding: 12px 16px; border-radius: 10px; margin: 4px 0 14px;
  animation: ata-pulse 1.1s ease-in-out infinite;
}
.icon-btn {
  border: none; background: var(--card-soft); color: var(--muted);
  width: 30px; height: 30px; border-radius: 10px; cursor: pointer; font-size: 13px;
  border: 1px solid var(--border);
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.icon-btn:hover { color: var(--text); transform: translateY(-1px); }

/* Grids & cards */
.grid { display: grid; gap: 20px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.card h3 { margin: 0 0 12px; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }

.kpi-card { position: relative; overflow: hidden; }
.kpi-card .kpi-header { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 10px; }
.kpi-card .kpi-icon { font-size: 22px; }
.kpi-card .kpi-value { font-size: 30px; font-weight: 800; margin: 8px 0 2px; }
.kpi-card .kpi-value.small { font-size: 21px; word-break: break-word; }
.kpi-card .kpi-label { color: var(--muted); font-size: 12.5px; }
.kpi-card::after {
  content: ""; position: absolute; right: -30px; top: -30px;
  width: 100px; height: 100px; border-radius: 50%;
  background: var(--accent, var(--grad-main));
  opacity: .18; filter: blur(2px);
}
.kpi-card.violet { --accent: var(--grad-main); }
.kpi-card.ok { --accent: var(--grad-ok); }
.kpi-card.warm { --accent: var(--grad-warm); }
.kpi-card.pink { --accent: var(--grad-pink); }

/* Section title row */
.section-row { display: flex; align-items: center; justify-content: space-between; margin: 32px 0 16px; }
.section-row h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.015em; }

/* Avatar */
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.avatar.lg { width: 54px; height: 54px; font-size: 18px; }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--border); background: var(--card-soft); color: var(--muted);
  padding: 7px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.chip.active { background: var(--grad-main); color: white; border-color: transparent; }
select, input[type=text], input[type=date], input[type=number], input[type=time], input[type=password], input[type=email], textarea {
  background: var(--card-soft); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
select:focus, input:focus, textarea:focus, button:focus-visible {
  outline: none; border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(18,107,255,0.25);
}
textarea { resize: vertical; }
/* Seletor de obra travado em uma única opção (obraSelectHtml) — some o "combobox"
   pra não parecer que dá pra trocar de obra quando o usuário só tem uma liberada. */
select.select-locked {
  -webkit-appearance: none; appearance: none; background-image: none;
  opacity: 1; cursor: default; font-weight: 700;
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }
.field-row.wrap { flex-wrap: wrap; }
.field-row.wrap .field { flex: 1 1 160px; min-width: 160px; }
.checkrow { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }

/* Cadastro de usuários: seletor de módulos e permissões */
.module-access-list { display: flex; flex-direction: column; gap: 10px; }
.module-access-item { background: var(--card-soft); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.module-perm-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding-left: 24px; }
.module-perm-actions[hidden] { display: none; }

/* Activity list */
.activity {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 14px 16px; margin-bottom: 10px;
  transition: transform .2s ease, box-shadow .2s ease;
}
.activity.done { opacity: .55; }
.activity .check {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted);
  cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: transparent;
}
.activity .check.checked { background: var(--green); border-color: var(--green); color: white; }
.activity .body { flex: 1; min-width: 0; }
.activity .title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.activity .title { font-weight: 700; font-size: 14px; }
.activity .title.strike { text-decoration: line-through; }
.activity .meta { color: var(--muted); font-size: 12px; margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.activity .actions { display: flex; gap: 6px; }

/* Atividades tab: seções por usuário */
.user-section { margin-bottom: 28px; }
.user-section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-section-head .avatar { width: 32px; height: 32px; font-size: 13px; }
.user-section-name { font-weight: 800; font-size: 15px; }
.user-section-empty { font-size: 13px; padding: 4px 0 8px; }

/* Relatório Diário: pastas por estado + cards de obra agrupados por status */
.diario-obra-picker { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }

.diario-estado-folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); gap: 12px; }
.diario-estado-folder {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--border); border-left: 4px solid var(--folder-color, var(--border));
  background: var(--card-soft); cursor: pointer;
  font-family: inherit; color: var(--text); text-align: left;
  transition: border-color .15s ease, background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.diario-estado-folder:hover { border-color: var(--folder-color, var(--blue)); border-left-color: var(--folder-color, var(--blue)); transform: translateY(-1px); background: var(--card); box-shadow: var(--shadow); }
.diario-estado-folder-icon {
  font-size: 18px; flex-shrink: 0; width: 36px; height: 36px; display: flex;
  align-items: center; justify-content: center; border-radius: 10px;
}
.diario-estado-folder-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.diario-estado-folder-name { font-size: 13px; font-weight: 800; overflow-wrap: anywhere; }
.diario-estado-folder-count { font-size: 11px; color: var(--muted); }

.diario-estado-breadcrumb { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.diario-estado-breadcrumb-label { font-size: 14px; font-weight: 800; }

.diario-obra-group-label { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 10px; }
.diario-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.diario-obra-card-wrap { display: flex; align-items: stretch; gap: 6px; min-width: 0; }
.diario-obra-estado-btn { flex-shrink: 0; align-self: center; }

/* Cartão de seleção de obra — o mesmo modelo (cor só na borda esquerda,
   fundo neutro, leve elevação ao passar o mouse) usado em toda tela que
   escolhe uma obra: Relatório Diário, Medição de Terceirizados, Relatório de
   Obras, Estoque, Ponto, Ata de Reunião e Cronograma de Suprimentos. Uma
   mudança aqui (cor, formato, tipo) vale pra todas de uma vez — é por isso
   que fica num lugar só, em vez de cada tela ter seu próprio estilo de
   cartão. */
.obra-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); gap: 10px; margin-bottom: 16px; }
.obra-card {
  flex: 1; width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 8px; min-width: 0;
  padding: 10px 14px; border-radius: 12px; border-left: 3px solid var(--st-color, var(--border));
  border-top: 1px solid var(--border); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  background: var(--card); cursor: pointer;
  font-size: 13px; font-weight: 700; font-family: inherit; color: var(--text);
  text-align: left;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.obra-card:hover { transform: translateY(-1px); background: var(--card-soft); }
.obra-card.active { background: color-mix(in srgb, var(--blue) 12%, var(--card)); box-shadow: inset 0 0 0 1px var(--blue); }
/* min-width evita que um selo comprido (ex.: "3 pacote(s)") espremesse o
   nome até sobrar 1 letra por linha — se não couber tudo numa linha só, o
   selo é que quebra pra linha de baixo (flex-wrap no .obra-card), não o nome. */
.obra-card-name { flex: 1 1 auto; min-width: 80px; overflow-wrap: break-word; }
.obra-card-badge { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 999px; color: white; white-space: nowrap; flex-shrink: 0; }

/* Activity cards (Atividades tab) */
.grid.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.activity-card {
  display: flex; flex-direction: column; align-items: stretch; gap: 10px;
  margin-bottom: 0; border-radius: var(--radius);
}
.activity-card:hover, .card:hover {
  transform: translateY(-3px);
  box-shadow: 0 30px 56px -18px rgba(0,0,0,0.5), 0 6px 16px rgba(0,0,0,0.2);
}
:root[data-theme="light"] .activity-card:hover, :root[data-theme="light"] .card:hover {
  box-shadow: 0 30px 56px -22px rgba(30,30,60,0.22), 0 6px 16px rgba(30,30,60,0.08);
}
.activity-card .ac-top { display: flex; align-items: center; gap: 10px; }
.activity-card .ac-title { flex: 1; min-width: 0; font-weight: 700; font-size: 14.5px; }
.activity-card .ac-title.strike { text-decoration: line-through; color: var(--muted); }
.activity-card .ac-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.activity-card .ac-desc {
  background: var(--card-soft); border-left: 3px solid var(--violet);
  border-radius: 12px; padding: 10px 12px; font-size: 13.5px; line-height: 1.45;
}
.activity-card .ac-desc-label {
  display: block; font-size: 10.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .04em; color: var(--violet); margin-bottom: 4px;
}
.activity-card .ac-footer { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 4px; }
.activity-card .ac-footer .avatar { width: 26px; height: 26px; font-size: 11px; }
.activity-card .ac-footer-text { display: flex; flex-direction: column; font-size: 12px; gap: 1px; }
.activity-card .ac-footer-text .muted { font-size: 11px; }

.tag { padding: 3px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 800; color: white; text-transform: uppercase; letter-spacing: .03em; }
.tag.overdue { background: var(--red); }
.tag.today { background: var(--amber); }
.tag.priority-alta { background: var(--red); }
.tag.priority-media { background: var(--amber); }
.tag.priority-baixa { background: var(--blue); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state .emoji { font-size: 40px; margin-bottom: 10px; }

.reuniao-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .03em;
  padding: 4px 9px; border-radius: 999px;
}
.reuniao-badge.ok { color: var(--green); background: rgba(34,197,94,0.14); }
.reuniao-badge.atencao { color: var(--amber); background: rgba(255,193,7,0.16); }
.reuniao-badge.risco { color: var(--red); background: rgba(239,68,68,0.14); }
.reuniao-badge.neutro { color: var(--muted); background: var(--card-soft); }

/* Checklist */
.checklist-card { margin-bottom: 16px; }
.checklist-progress-bar { height: 8px; border-radius: 999px; background: var(--card-soft); overflow: hidden; margin: 10px 0 14px; }
.checklist-progress-fill { height: 100%; background: var(--grad-ok); border-radius: 999px; transition: width .3s; }
.checklist-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green); cursor: pointer; }
.checklist-item span.done-text { text-decoration: line-through; color: var(--muted); }


/* Calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-dow { text-align: center; font-size: 11.5px; color: var(--muted); font-weight: 700; padding-bottom: 6px; }
.cal-day {
  min-height: 112px; min-width: 0; border-radius: 12px; background: var(--card); border: 1px solid var(--border);
  padding: 7px; font-size: 11.5px; cursor: pointer; position: relative; overflow: hidden;
  transition: background .15s ease, transform .15s ease;
}
.cal-day.empty { background: transparent; border-color: transparent; cursor: default; }
.cal-day.selected { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.cal-day.today { border-color: var(--violet); box-shadow: 0 0 0 1px var(--violet); }
.cal-day .d-num { font-weight: 700; font-size: 12.5px; }
.cal-day:hover { background: var(--card-soft); }
.cal-events { display: flex; flex-direction: column; gap: 3px; margin-top: 5px; min-width: 0; }
.cal-event {
  min-width: 0; max-width: 100%; box-sizing: border-box;
  background: var(--card-soft); border-left: 3px solid var(--violet); border-radius: 4px;
  padding: 2px 5px; font-size: 10px; font-weight: 600; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; cursor: pointer; transition: transform .1s ease;
}
.cal-event:hover { transform: translateX(1px); filter: brightness(1.15); }
.cal-event.done { opacity: .5; text-decoration: line-through; }
.cal-event-time { color: var(--muted); font-weight: 700; }
.cal-more { font-size: 10px; color: var(--muted); font-weight: 700; padding: 1px 5px; }
@media (max-width: 860px) {
  .cal-grid { gap: 4px; }
  .cal-day { min-height: 74px; font-size: 9px; padding: 4px; }
  .cal-event { font-size: 8px; padding: 1px 3px; }
  .cal-more { font-size: 8px; padding: 1px 3px; }
}

/* Reminders */
.reminder {
  display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 16px; margin-bottom: 10px;
  border-left: 4px solid var(--amber); background: var(--card); border-top: 1px solid var(--border); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  transition: transform .2s ease;
}
.reminder:hover { transform: translateY(-2px); }
.reminder.overdue { border-left-color: var(--red); }
.reminder.today { border-left-color: var(--amber); }
.reminder.soon { border-left-color: var(--blue); }

/* Socios cards */
.socio-card { display: flex; flex-direction: column; gap: 10px; }
.socio-head { display: flex; align-items: center; gap: 12px; }
.socio-stats { display: flex; gap: 14px; margin-top: 6px; }
.socio-stat { flex: 1; text-align: center; background: var(--card-soft); border-radius: 12px; padding: 9px 4px; }
.socio-stat b { display: block; font-size: 16px; }
.socio-stat span { font-size: 10.5px; color: var(--muted); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,6,20,0.6); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.open { display: flex; animation: fadein .2s ease; }
.modal {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 480px; max-height: 88vh; max-height: 88dvh; overflow-y: auto; padding: 26px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.5);
}
.modal h2 { margin: 0 0 18px; font-size: 19px; font-weight: 800; letter-spacing: -0.015em; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--glass); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border); color: var(--text);
  padding: 13px 22px; border-radius: 980px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .3s ease; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Color swatches */
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.swatch.selected { border-color: white; box-shadow: 0 0 0 2px var(--violet); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--card-soft); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

/* Mobile layout: sidebar becomes an off-canvas drawer, top bar with hamburger appears */
@media (max-width: 860px) {
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: fixed; top: 0; left: 0; right: 0; z-index: 80;
    background: #0e2138;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding: calc(10px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 10px calc(14px + env(safe-area-inset-left));
  }
  .brand-mini { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 800; color: #f2f5fb; }
  .mobile-topbar .icon-btn { background: rgba(255,255,255,0.06); color: #8d9bb5; border-color: rgba(255,255,255,0.1); }
  .mobile-topbar .icon-btn:hover { color: #f2f5fb; border-color: rgba(255,255,255,0.25); }
  .app { flex-direction: column; }
  /* a barra de cima agora é fixa (sempre visível); reserva o espaço dela */
  #appRoot { padding-top: calc(58px + env(safe-area-inset-top)); padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  /* barra de baixo: Voltar / Início / Menu — sempre ao alcance do polegar */
  .mobile-bottombar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 85;
    background: #0e2138; border-top: 1px solid rgba(255,255,255,0.1);
    padding: 6px calc(8px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
    gap: 6px;
  }
  .mobile-bottombar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    min-height: 48px; border: none; border-radius: 12px; background: transparent; color: #c4cee2;
    font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .mobile-bottombar button:active { background: rgba(255,255,255,0.1); }
  .mobile-bottombar .mbb-ico { font-size: 22px; line-height: 1; }
  .sidebar-overlay.open ~ .mobile-bottombar { z-index: 85; }
  /* gráficos de barras (EAP / Linha de Balanço): dica de deslizar */
  .gantt-dica { display: block; margin: 8px 2px 0; font-size: 11.5px; color: var(--muted); }
  .mobile-topbar-left { display: flex; gap: 8px; align-items: center; }
  .mobile-topbar-left .icon-btn { font-size: 20px; line-height: 1; }
  .mobile-topbar-left .icon-btn[hidden] { display: none; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh; z-index: 95;
    width: 250px; max-width: 82vw;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,0.4);
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-left: calc(14px + env(safe-area-inset-left));
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar.collapsed { width: 250px; }
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .sidebar-collapse-btn,
  .sidebar.collapsed .nav-item .label,
  .sidebar.collapsed .nav-item .nav-badge,
  .sidebar.collapsed .btn-ghost .label,
  .sidebar.collapsed .sync-status { display: revert; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 11px 12px; }
  .sidebar.collapsed .btn-ghost { justify-content: flex-start; }
  .content { padding: 18px 16px 60px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
}
@media (min-width: 861px) {
  .sidebar-collapse-btn { display: flex; }
}

/* Splash screen */
.splash-screen {
  position: fixed; inset: 0; z-index: 400;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #0b1d33;
  overflow: hidden;
  opacity: 1; transition: opacity .5s ease;
}
.splash-screen[hidden] { display: none; }
.splash-screen.hide { opacity: 0; pointer-events: none; }
.splash-content { display: flex; flex-direction: column; align-items: center; z-index: 1; }
.splash-logo {
  width: 96px; height: 96px; border-radius: 22px;
  box-shadow: 0 16px 40px -8px rgba(255,122,0,0.4);
  margin-bottom: 22px;
  animation: splash-in .6s ease;
}
.splash-wordmark { font-size: 40px; font-weight: 800; color: #fff; letter-spacing: .01em; }
.splash-tagline {
  font-size: 12.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: #8d9bb5; margin-top: 10px;
}
.splash-tagline span { color: var(--orange); font-weight: 800; }
.splash-skyline { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 22vh; height: 22dvh; min-height: 120px; max-height: 200px; }
@keyframes splash-in { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Login gate (multi-user access) — always dark, matches brand splash regardless of app theme */
.login-gate {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 100% -10%, #4a2c1f 0%, transparent 60%),
              radial-gradient(1000px 500px at -10% 110%, #0d3350 0%, transparent 55%),
              #0b1d33;
  padding: 20px;
}
.login-gate[hidden] { display: none; }
.login-card {
  width: 100%; max-width: 380px; text-align: center;
  display: flex; flex-direction: column; align-items: center;
  color: #f2f5fb;
}
.login-card .brand-badge.lg { box-shadow: 0 16px 40px -8px rgba(255,122,0,0.4); }
.login-wordmark { font-size: 20px; font-weight: 800; letter-spacing: .01em; margin-top: 14px; }
.login-card h2 { margin: 18px 0 6px; font-weight: 800; letter-spacing: -0.02em; font-size: 22px; }
.login-card .muted { margin-bottom: 24px; color: #8d9bb5; }
.login-card .field { text-align: left; width: 100%; }
.login-card .field label { color: #8d9bb5; }
.login-card select, .login-card input {
  width: 100%; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: #f2f5fb;
}
.login-card select:focus, .login-card input:focus { border-color: var(--blue); }
.login-card .btn { background: var(--blue); box-shadow: 0 8px 20px -6px rgba(18,107,255,0.45); }
.password-field { position: relative; }
.password-field input { padding-right: 42px; }
.password-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; cursor: pointer; font-size: 15px;
  width: 32px; height: 32px; border-radius: 8px; opacity: .7;
}
.password-toggle:hover { opacity: 1; background: rgba(255,255,255,0.08); }
.login-footer { font-size: 11.5px; color: #66738f; margin: 28px 0 0; }
.login-error {
  color: var(--red); font-size: 12.5px; font-weight: 700;
  background: rgba(239,68,68,0.12); border-radius: 10px; padding: 8px 10px; margin: -4px 0 14px;
  width: 100%;
}
#appRoot[hidden] { display: none; }

/* Orçamentos: kanban board */
/* Grid com 1 coluna por status, encolhendo pra caber tudo numa página só sem scroll horizontal. */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; padding-bottom: 12px; align-items: start; }
.kanban-col {
  min-width: 0; background: var(--card-soft); border: 1px solid var(--border);
  border-radius: var(--radius); max-height: calc(100vh - 180px); max-height: calc(100dvh - 180px); overflow-y: auto; overflow-x: hidden;
}
/* Cabeçalho da coluna fica fixo no topo enquanto os cards rolam por baixo. */
.kanban-col-head {
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 12.5px;
  position: sticky; top: 0; z-index: 2; background: var(--card-soft);
  padding: 12px 12px 10px; margin: 0;
}
.kanban-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.kanban-col-body { display: flex; flex-direction: column; gap: 10px; padding: 0 12px 12px; }
.budget-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; transition: transform .2s ease, box-shadow .2s ease;
  min-width: 0; overflow-wrap: anywhere;
}
.budget-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.budget-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px 8px; flex-wrap: wrap; }
.budget-card-top .actions { display: flex; gap: 4px; flex-shrink: 0; margin-left: auto; }
.budget-card .icon-btn { width: 24px; height: 24px; font-size: 11px; border-radius: 8px; flex-shrink: 0; }
.budget-client { font-weight: 700; font-size: 12.5px; line-height: 1.3; overflow-wrap: anywhere; min-width: 0; }
.budget-value { font-size: 16px; font-weight: 800; margin: 6px 0; overflow-wrap: anywhere; background: var(--grad-text); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.budget-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.budget-meta .tag { overflow-wrap: anywhere; white-space: normal; text-align: center; }
.participa-btn.is-on { color: var(--green); border-color: var(--green); }
.participa-btn.is-off { color: var(--muted); }
.budget-clock { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 6px; }
.clock-row { display: flex; align-items: center; gap: 4px 6px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.clock-row b { color: var(--text); margin-left: auto; font-weight: 700; }
.clock-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--border); }
.clock-dot.on { background: var(--green); }
.clock-dot.pending { background: var(--amber); }
.clock-dot.late { background: var(--red); }
.clock-row.ok { color: var(--green); font-weight: 700; }
.clock-row.late { color: var(--red); font-weight: 700; }
.clock-btn { width: 100%; margin-top: 2px; }
.clock-alert { font-size: 11px; font-weight: 700; padding: 6px 8px; border-radius: 8px; line-height: 1.35; }
.clock-alert.alta { color: var(--red); background: color-mix(in srgb, var(--red) 14%, transparent); }
.clock-alert.media { color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); }
.budget-declined { padding-top: 8px; border-top: 1px dashed var(--border); }
@media (max-width: 1100px) {
  .kanban { display: flex; overflow-x: auto; }
  .kanban-col { flex: 0 0 260px; }
}
@media (max-width: 700px) {
  .kanban-col { flex: 0 0 82vw; }
}

/* Orçamentos: indicadores */
.budget-bars { display: flex; align-items: flex-end; gap: 14px; height: 160px; padding-top: 10px; }
.budget-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.budget-bar-fill { width: 100%; max-width: 46px; border-radius: 8px 8px 4px 4px; min-height: 2px; transition: height .3s ease; }
.budget-bar-value { font-size: 12px; font-weight: 800; }
.budget-bar-label { font-size: 10.5px; color: var(--muted); text-align: center; line-height: 1.3; }

.conversion-bar { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: var(--card-soft); }
.conversion-seg { height: 100%; transition: width .3s ease; }
.conversion-legend { display: flex; gap: 18px; margin-top: 14px; font-size: 12.5px; flex-wrap: wrap; }
.conversion-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.budget-trend-svg { width: 100%; height: 220px; display: block; }

/* Reunião Semanal: entradas previstas por obra */
.fluxo-entradas-list { display: flex; flex-direction: column; gap: 10px; }
.fluxo-entrada-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 4px; }
.fluxo-entrada-bar { height: 6px; background: var(--card-soft); border-radius: 4px; overflow: hidden; }
.fluxo-entrada-fill { height: 100%; background: var(--grad-ok); border-radius: 4px; }

/* Orçamentos: linha do tempo de elaboração */
.budget-timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline-row { display: flex; align-items: center; gap: 10px; }
.timeline-label { flex: 0 0 130px; font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-track { position: relative; flex: 1; height: 12px; background: var(--card-soft); border-radius: 8px; }
.timeline-bar { position: absolute; top: 0; height: 100%; border-radius: 8px; min-width: 4px; transition: left .3s ease, width .3s ease; }
.timeline-bar.in-progress {
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.3) 0 6px, transparent 6px 12px);
  animation: timelinePulse 1.6s ease-in-out infinite;
}
@keyframes timelinePulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.timeline-deadline { position: absolute; top: -4px; width: 2px; height: 20px; background: var(--muted); border-radius: 1px; }
.timeline-dur { flex: 0 0 100px; font-size: 11.5px; font-weight: 700; text-align: right; white-space: nowrap; }
@media (max-width: 700px) {
  .timeline-label { flex-basis: 90px; }
  .timeline-dur { flex-basis: 78px; font-size: 10.5px; }
}

/* Chat */
.chat-layout {
  display: flex; height: calc(100vh - 170px); height: calc(100dvh - 170px); min-height: 420px;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: var(--card);
}
.chat-sidebar { width: 280px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; }
.chat-sidebar-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.chat-section-label { padding: 12px 16px 6px; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.chat-conv-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border); }
.chat-conv-item:hover, .chat-conv-item.active { background: var(--card-soft); }
.chat-conv-item .cname { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; }
.chat-conv-item .cpreview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-thread-header { padding: 16px; border-bottom: 1px solid var(--border); font-weight: 800; font-size: 14.5px; flex-shrink: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-bubble { max-width: 68%; padding: 10px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.45; word-wrap: break-word; }
.chat-bubble.mine { align-self: flex-end; background: var(--grad-main); color: white; border-bottom-right-radius: 4px; }
.chat-bubble.theirs { align-self: flex-start; background: var(--card-soft); border-bottom-left-radius: 4px; }
.chat-bubble .csender { font-size: 11px; font-weight: 800; margin-bottom: 3px; opacity: .8; }
.chat-bubble .ctime { font-size: 10px; opacity: .65; margin-top: 4px; text-align: right; }
.chat-compose { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-compose input { flex: 1; }
.chat-empty-thread { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13.5px; }
@media (max-width: 780px) {
  .chat-layout { flex-direction: column; height: calc(100vh - 220px); height: calc(100dvh - 220px); }
  .chat-sidebar { width: auto; max-height: 200px; border-right: none; border-bottom: 1px solid var(--border); }
}

/* Painel de Gestão */
.gestao-card { margin-bottom: 14px; }
.gestao-rank { font-size: 13px; font-weight: 800; color: var(--muted); width: 28px; flex-shrink: 0; }
.gestao-rate { font-size: 22px; font-weight: 800; flex-shrink: 0; }
.gestao-bar { height: 8px; border-radius: 999px; background: var(--card-soft); overflow: hidden; margin: 12px 0 14px; }
.gestao-bar-fill { height: 100%; border-radius: 999px; transition: width .3s ease; }
.gestao-open-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.gestao-open-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }

/* Obras */
.obra-card { margin-bottom: 14px; }

/* Boletim de Medição */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.boletim-table { border-collapse: collapse; width: 100%; min-width: 900px; font-size: 12px; white-space: nowrap; }
.boletim-table th, .boletim-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: right; }
.boletim-table th:nth-child(1), .boletim-table th:nth-child(2),
.boletim-table td:nth-child(1), .boletim-table td:nth-child(2) { text-align: left; white-space: normal; }
.boletim-table thead th { background: var(--card-soft); font-weight: 800; text-align: center; font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; }
.boletim-table tbody tr:hover { background: var(--card-soft); }
.boletim-table .boletim-k-input { width: 80px; text-align: right; }
.boletim-group-row { font-weight: 800; background: var(--card-soft); }

/* Espelho do Período (Ponto) — grade dia-a-dia por funcionário */
.ponto-grade { border-collapse: collapse; font-size: 11px; white-space: nowrap; }
.ponto-grade th, .ponto-grade td { border: 1px solid var(--border); padding: 4px 6px; text-align: center; min-width: 30px; }
.ponto-grade thead th { background: var(--card-soft); font-weight: 800; font-size: 9.5px; text-transform: uppercase; }
.ponto-grade .pg-dow { font-weight: 400; font-size: 8.5px; color: var(--muted); }
.ponto-grade .pg-nome { text-align: left; white-space: nowrap; position: sticky; left: 0; background: var(--card); font-weight: 700; min-width: 130px; }
.ponto-grade thead .pg-nome { background: var(--card-soft); z-index: 1; }
.ponto-grade .pg-fds { background: var(--card-soft); color: var(--muted); }
.ponto-grade .pg-ok { color: var(--muted); }
.ponto-grade .pg-extra { background: rgba(34,197,94,0.18); color: #16a34a; font-weight: 800; }
.ponto-grade .pg-falta { background: rgba(239,68,68,0.18); color: #dc2626; font-weight: 800; }
.ponto-grade .pg-just { background: rgba(255,193,7,0.22); color: #b45309; font-weight: 800; }
.ponto-grade .pg-num { font-weight: 800; }
.terc-card { cursor: pointer; border: 2px solid transparent; transition: border-color .15s ease; }
.terc-card:hover { border-color: var(--border); }
.terc-card-active { border-color: #126bff; }

#printBoletimContainer { display: none; }
#printBoletimContainer table { color: #000; }
#printBoletimContainer th, #printBoletimContainer td { border-color: #999; }


/* ===================== Celular / tablet pequeno =====================
   O menu lateral já vira gaveta em <=860px (mais acima). Aqui entram as regras
   das páginas internas: cabeçalhos que quebram linha em vez de espremer o
   título, grades que nunca esticam a página (min-width:0), cartões mais
   compactos, formulários empilhados, modais como "folha" que sobe de baixo,
   campos com 16px (abaixo disso o iPhone dá zoom sozinho ao tocar num campo e
   a página parece quebrada), e tabelas largas que rolam dentro do próprio
   contêiner em vez de empurrar a página inteira pro lado. */
@media (max-width: 860px) {
  /* clip (e não hidden): hidden transformava o body em contêiner de rolagem, e aí a
     barra de cima deixava de ficar presa no iPhone */
  html, body { max-width: 100%; overflow-x: clip; }
  .content { overflow-x: clip; }
  .content, .view, .card, .grid > *, .section-row > *, .field, .field-row > * { min-width: 0; }
  .topbar { margin-bottom: 18px; }
  .topbar h1 { font-size: 26px; overflow-wrap: anywhere; }
  .topbar .muted { font-size: 12.5px; }
  .page-title-badge { display: block; margin: 6px 0 0; width: fit-content; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1 1 auto; }

  .sidebar-collapse-btn { display: none; }
  .nav-item { min-height: 46px; }
  /* cartão do painel com largura fixa inline (ex.: gauge "Saúde da carteira") ocupa a linha toda */
  .content [style*="flex:0 0 240px"] { flex: 1 1 100% !important; }
  .grid { gap: 12px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
  /* Cartões de indicador (KPI) lado a lado, 2 por linha, mais baixos */
  .grid:has(> .kpi-card) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid:has(> .kpi-card) > .kpi-card:last-child:nth-child(odd) { grid-column: span 2; }
  .socio-stats { flex-wrap: wrap; gap: 8px; }
  .socio-stat { flex: 1 1 96px; min-width: 0; }
  .socio-stat b { font-size: 14px; overflow-wrap: anywhere; }
  .budget-bars { gap: 6px; }
  .budget-bar-col { min-width: 0; }
  .budget-bar-label { overflow-wrap: anywhere; }
  .kpi-card { padding: 14px; }
  .kpi-card .kpi-icon { font-size: 18px; }
  .kpi-card .kpi-value { font-size: 20px; margin: 4px 0 0; overflow-wrap: break-word; }
  .kpi-card .kpi-value.small { font-size: 16px; }
  .kpi-card .kpi-label { font-size: 11px; }
  .card { padding: 16px; }

  /* Cabeçalho de seção: título numa linha, botões embaixo (sem espremer) */
  .section-row { flex-wrap: wrap; align-items: flex-start; gap: 10px; margin: 22px 0 12px; }
  .section-row h2, .section-row h3 { flex: 1 1 100%; font-size: 17px; overflow-wrap: anywhere; }
  .section-row > div { max-width: 100%; }
  .filters { gap: 6px; }

  /* Seletor de obra: faixa que rola pro lado (15 obras empilhadas ocupavam
     várias telas só pra escolher uma) */
  .obra-card-grid { display: flex; overflow-x: auto; gap: 8px; padding-bottom: 8px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  .obra-card-grid > .obra-card { flex: 0 0 min(78%, 280px); margin-bottom: 0; scroll-snap-align: start; }

  /* Formulários empilhados e campos sem zoom do iOS */
  .field-row:not(.wrap) { flex-direction: column; gap: 0; }
  input, select, textarea { font-size: 16px; max-width: 100%; }
  input[type="date"], input[type="time"], input[type="number"] { min-width: 0; }
  .btn { padding: 11px 16px; }
  .btn.small { padding: 8px 12px; min-height: 36px; }
  .icon-btn { width: 36px; height: 36px; }

  /* Modais viram folha que sobe da base da tela */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 20px 20px 0 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  }
  .modal h2 { font-size: 17px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 auto; }

  .toast { max-width: calc(100vw - 32px); text-align: center; bottom: calc(18px + env(safe-area-inset-bottom)); }

  /* Tabelas largas rolam dentro do contêiner (app.js envolve as que estiverem soltas) */
  .tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; border-radius: 10px; }
  .tbl-scroll > table { max-width: none; }
  .view img { max-width: 100%; }
}


/* Tabelas-lista viram cartões no celular (marcadas com data-cards no app.js) */
@media (max-width: 600px) {
  table[data-cards] { min-width: 0 !important; width: 100% !important; display: block; border: none !important; }
  table[data-cards] thead { display: none; }
  table[data-cards] tbody { display: block; }
  table[data-cards] tr { display: block; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; padding: 6px 12px; background: var(--card); }
  table[data-cards] td {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    border: none !important; border-bottom: 1px dashed var(--border) !important;
    padding: 6px 0 !important; white-space: normal !important; text-align: right !important;
    font-size: 12.5px !important; overflow-wrap: anywhere;
  }
  table[data-cards] td:last-child { border-bottom: none !important; }
  table[data-cards] td [style*="white-space:nowrap"] { white-space: normal !important; }
  table[data-cards] td::before {
    content: attr(data-label); flex: 0 0 34%; text-align: left; font-weight: 700;
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
  }
  table[data-cards] td[data-label=""]::before { display: none; }
  table[data-cards] td[data-label=""] { justify-content: flex-end; }
  table[data-cards] td[data-vazio], table[data-cards] td[data-label="#"], table[data-cards] td[data-label="SEQ"] { display: none; }
  /* o wrapper com rolagem deixa de ser necessário (e de esconder cartões) */
  div:has(> table[data-cards]) { overflow-x: visible !important; }
}

@media print {
  .sidebar, .topbar-actions, .sidebar-overlay { display: none !important; }
  .content { padding: 0; max-width: none; }
  .view:not(.active) { display: none !important; }
  .filters { display: none !important; }
  body.printing-boletim > *:not(#printBoletimContainer) { display: none !important; }
  body.printing-boletim #printBoletimContainer {
    display: block !important; color: #000; background: #fff; padding: 0; margin: 0;
    width: 100%; max-width: 100%; overflow: visible;
  }
  #printBoletimContainer h1 { font-size: 16px; margin: 0 0 8px; }
  #printBoletimContainer p { font-size: 10.5px; margin: 3px 0; }
  #printBoletimContainer .boletim-table {
    min-width: 0; width: 100%; max-width: 100%; table-layout: fixed;
    font-size: 6.5px; white-space: normal; word-break: break-word;
  }
  #printBoletimContainer .boletim-table th,
  #printBoletimContainer .boletim-table td { padding: 2px 3px; }
  #printBoletimContainer .table-wrap { overflow: visible; border: none; }
}

/* Replanejamento de pacotes: aviso, modal e selos */
.replan-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin: 0 0 14px; border-radius: 14px; background: rgba(220,38,38,.08); border: 1px solid rgba(220,38,38,.35); font-size: 12.5px; line-height: 1.5; }
.replan-banner .replan-txt { flex: 1 1 260px; min-width: 0; }
.replan-resumo { padding: 8px 12px; border-radius: 10px; background: var(--card-soft); font-size: 12.5px; margin-bottom: 10px; }
.replan-lista { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; }
.replan-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--card); }
.replan-item input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: #dc2626; }
.replan-tit { font-weight: 800; font-size: 13px; }
.replan-tag { font-size: 10.5px; font-weight: 800; padding: 2px 8px; border-radius: 999px; color: #fff; vertical-align: 1px; }
.replan-tag.dir { background: #dc2626; } .replan-tag.prop { background: #ea580c; }
.pacote-atraso { margin-top: 8px; font-size: 10.5px; font-weight: 700; color: #dc2626; display: flex; align-items: center; gap: 5px; }
.pacote-atraso.ok { color: var(--muted); font-weight: 600; }

/* Teste grátis: faixa no topo do app */
.trial-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; padding: 10px 16px; border-radius: 14px; background: rgba(18,107,255,.10); border: 1px solid rgba(18,107,255,.35); font-size: 13px; }
.trial-banner[hidden] { display: none; }
.trial-banner span { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.trial-banner.urgente { background: rgba(255,122,0,.12); border-color: rgba(255,122,0,.5); }

/* escolha de plano no "Quero assinar" */
.plano-lista { display: flex; flex-direction: column; gap: 8px; }
.plano-opc { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--card); font-size: 13px; }
.plano-opc > div:nth-child(2) { flex: 1; min-width: 0; }
.plano-opc input { width: 18px; height: 18px; flex: none; accent-color: var(--orange); }
.plano-preco { white-space: nowrap; text-align: right; font-size: 13px; }
