:root {
  --bg: #f1f1f3;
  --surface: #ffffff;
  --surface-2: #f7f7f9;
  --text: #181b20;
  --muted: #6b6f7a;
  --border: #e4e4e9;
  --brand: #16181d;
  --accent: #6e33f5;
  --accent-soft: #f1ebfe;
  --accent-forte: #4f1fc9;      /* texto sobre fundo violeta claro */
  --accent-anel: rgba(110, 51, 245, .28);
  --ok: #1f9d55;
  --ok-soft: #e6f6ec;
  --info: #2f6fdb;
  --info-soft: #e8f0fd;
  --warn: #b7791f;
  --warn-soft: #fdf5e3;
  --danger: #d64545;
  --danger-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --nav-h: 64px;
  --menu-fundo: linear-gradient(180deg, #16181d 0%, #191626 100%);
  /* Paleta dos gráficos (fatias e barras sem cor própria). */
  --g1: #6e33f5; --g2: #2f6fdb; --g3: #1f9d55; --g4: #d97706; --g5: #db2777; --g6: #0d9488; --g7: #9333ea; --g8: #8b8fa3;
  --rosca-fundo: #ecebf2;
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 15px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
a { color: var(--info); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 23px; font-weight: 600; letter-spacing: -.015em; }
h2, h3 { font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
img { display: block; max-width: 100%; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--menu-fundo); color: #b9bcc6; padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  /* Menu maior que a tela rola por dentro, sem vazar para fora do fundo escuro. */
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
}
.sidebar > * { flex-shrink: 0; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 21px; padding: 4px 10px 18px; letter-spacing: -.01em; }
.marca-simbolo { width: 34px; height: 34px; flex: none; display: block; }
.marca b { font-weight: 700; }
.marca span { font-weight: 300; }
.empresa-box {
  display: flex; align-items: center; gap: 6px; margin: 0 4px 10px; padding: 10px 12px; border-radius: 10px;
  background: rgba(255,255,255,.06); color: #fff; line-height: 1.25;
}
.empresa-box strong { display: block; font-size: 14px; }
.empresa-mobile { display: none; font-weight: 400; }
.trocar-mobile { display: none; }
.aviso { background: var(--warn-soft); color: var(--warn); padding: 10px 24px; font-weight: 600; font-size: 14px; border-bottom: 1px solid #f3e2b8; }
.aviso.erro { background: var(--danger-soft); color: var(--danger); border-color: #f5c9c9; }
button.lista-item { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--border); font: inherit; text-align: left; cursor: pointer; align-items: center; }
button.lista-item:hover { background: var(--surface-2); }
button.lista-item svg { width: 18px; height: 18px; color: var(--muted); }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: #b9bcc6; font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,.06); }
.nav-link.ativo { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(110,51,245,.35); }
.nav-link svg { width: 20px; height: 20px; flex: none; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7d808c; padding: 16px 12px 6px; }
.sidebar .user-box { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.sidebar .user-box strong { color: #fff; display: block; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar .titulo { flex: 1; min-width: 0; font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .logo-mobile { display: none; }
.topbar .logo-mobile .marca-simbolo { width: 32px; height: 32px; }
.conteudo { padding: 24px; max-width: 1180px; width: 100%; margin: 0 auto; }

.bottom-nav { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar .logo-mobile { display: grid; }
  .topbar .titulo { font-size: 15px; line-height: 1.2; }
  .empresa-mobile { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
  .trocar-mobile { display: block; }
  .aviso { padding: 8px 16px; font-size: 13px; }
  .conteudo { padding: 16px 16px calc(var(--nav-h) + 24px); }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 11px; color: var(--muted); font-weight: 500;
  }
  .bottom-nav a.ativo { color: var(--accent); }
  .bottom-nav svg { width: 22px; height: 22px; }
}

/* ---------- componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pre { white-space: pre-line; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  min-height: 40px;
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 18px; height: 18px; }
.btn.primario { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primario:hover { filter: brightness(.95); }
.btn.escuro { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.perigo { color: var(--danger); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.pequeno { padding: 6px 10px; min-height: 32px; font-size: 13px; }
.btn.icone { padding: 8px; min-width: 40px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-bloco { width: 100%; }

.icon-btn { position: relative; border: 0; background: transparent; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; display: block; }
.badge-dot {
  position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}

.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.tag.aberta, .tag.em_cotacao { background: var(--info-soft); color: var(--info); }
.tag.aguardando_aprovacao { background: var(--accent-soft); color: var(--accent-forte); }
.tag.aprovada { background: var(--ok-soft); color: var(--ok); }
.tag.recusada, .tag.cancelada { background: var(--danger-soft); color: var(--danger); }
.tag.solicitado, .tag.planejamento, .tag.teste { background: var(--warn-soft); color: var(--warn); }
.tag.comprado, .tag.em_andamento { background: var(--info-soft); color: var(--info); }
.tag.recebido, .tag.concluida, .tag.ativa { background: var(--ok-soft); color: var(--ok); }
.tag.cancelado, .tag.pausada, .tag.bloqueada { background: var(--danger-soft); color: var(--danger); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi { padding: 16px; }
.kpi .valor { font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.kpi { transition: border-color .15s, box-shadow .15s; }
a.kpi:hover { border-color: #d6c8fd; box-shadow: 0 6px 18px rgba(110,51,245,.10); }
.kpi .rotulo { color: var(--muted); font-size: 13px; }
@media (max-width: 860px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

.grid-obras { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.obra-card { overflow: hidden; display: flex; flex-direction: column; color: inherit; }
.obra-capa { aspect-ratio: 16/9; background: linear-gradient(135deg, #2a2440, #16181d); position: relative; }
.obra-capa img { width: 100%; height: 100%; object-fit: cover; }
.obra-capa .tag { position: absolute; top: 10px; left: 10px; }
.obra-capa .vazio { position: absolute; inset: 0; display: grid; place-items: center; color: #7d808c; }
.obra-card .corpo { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; }

.progresso { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progresso > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* No computador as abas quebram linha (todas ficam visíveis); no celular rolam de lado, com barra fina. */
.tabs { display: flex; flex-wrap: wrap; gap: 0 4px; border-bottom: 1px solid var(--border); }
@media (max-width: 860px) {
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
}
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.ativo { color: var(--text); border-color: var(--accent); }

.vazio-box { padding: 40px 20px; text-align: center; color: var(--muted); }
.vazio-box svg { width: 40px; height: 40px; margin: 0 auto 10px; opacity: .5; }

/* ---------- formulários ---------- */
label.campo { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: #344054; }
input, select, textarea {
  font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid #d0d5dd; border-radius: 9px; background: #fff; color: var(--text); width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-anel); border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }

/* ---------- tabelas / listas ---------- */
.tabela { width: 100%; border-collapse: collapse; }
.tabela th, .tabela td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabela th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
.tabela tr:last-child td { border-bottom: 0; }
.tabela tr.clicavel { cursor: pointer; }
.tabela tr.clicavel:hover td { background: var(--surface-2); }
@media (max-width: 700px) {
  .tabela.responsiva thead { display: none; }
  .tabela.responsiva tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .tabela.responsiva td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; }
  .tabela.responsiva td::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
}

.lista-item { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); align-items: flex-start; color: inherit; }
.lista-item:last-child { border-bottom: 0; }

/* ---------- diário ---------- */
.dia-nav { display: flex; align-items: center; gap: 8px; }
.dia-nav input[type=date] { width: auto; }
.dia-titulo { font-size: 18px; font-weight: 700; }

.calendario { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendario .dsem { font-size: 11px; color: var(--muted); text-align: center; font-weight: 600; padding: 4px 0; }
.calendario button {
  aspect-ratio: 1; border: 1px solid transparent; background: transparent; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px;
  position: relative; color: var(--text);
}
.calendario button:hover { background: var(--surface-2); }
.calendario button.fora { color: #c0c6cf; }
.calendario button.tem { font-weight: 700; background: var(--accent-soft); color: var(--accent-forte); }
.calendario button.tem::after { content: ""; position: absolute; bottom: 5px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--accent); }
.calendario button.sel { border-color: var(--accent); outline: 1px solid var(--accent); }
.calendario button.hoje { text-decoration: underline; }

.diario-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 960px) { .diario-layout { grid-template-columns: 1fr; } }

.registro { padding: 16px 18px; }
.registro + .registro { border-top: 1px solid var(--border); }
.registro .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); margin-top: 4px; }

.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.foto { margin: 0; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); cursor: zoom-in; }
.foto img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.foto figcaption { padding: 7px 9px; font-size: 13px; }
@media (max-width: 500px) { .galeria { grid-template-columns: repeat(2, 1fr); } }

.upload-zona {
  border: 2px dashed #cfd5dd; border-radius: 12px; padding: 18px; text-align: center; background: var(--surface-2);
}
.upload-lista { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.upload-item { display: grid; grid-template-columns: 84px 1fr auto; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px; }
.upload-item img { width: 84px; height: 64px; object-fit: cover; border-radius: 7px; }

/* ---------- linha do tempo ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-dia { position: relative; margin-bottom: 22px; }
.tl-dia::before { content: ""; position: absolute; left: -24px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid var(--accent-soft); }
.tl-fotos { display: flex; gap: 10px; overflow-x: auto; padding: 8px 0 4px; scroll-snap-type: x mandatory; }
.tl-fotos .foto { flex: 0 0 200px; scroll-snap-align: start; }

.comparador { position: relative; overflow: hidden; border-radius: 12px; aspect-ratio: 4/3; background: #111; user-select: none; touch-action: none; }
.comparador img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.comparador .depois-wrap { position: absolute; inset: 0; clip-path: inset(0 0 0 50%); }
.comparador .divisor { position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; background: #fff; transform: translateX(-50%); pointer-events: none; }
.comparador .divisor::after {
  content: "⟷"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; border-radius: 50%;
  background: #fff; display: grid; place-items: center; font-weight: 700; color: var(--brand); box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.comparador .rot { position: absolute; top: 10px; padding: 3px 10px; border-radius: 99px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 600; }
.comparador .rot.a { left: 10px; } .comparador .rot.b { right: 10px; }

/* ---------- cronograma ---------- */
.gantt-linha { display: grid; grid-template-columns: minmax(140px, 240px) 1fr 60px; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.gantt-linha:last-child { border-bottom: 0; }
.gantt-trilho { position: relative; height: 22px; background: var(--surface-2); border-radius: 6px; }
.gantt-barra { position: absolute; top: 3px; bottom: 3px; border-radius: 5px; background: #cdd5df; overflow: hidden; min-width: 4px; }
.gantt-barra > i { display: block; height: 100%; background: var(--accent); }
.gantt-hoje { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--danger); }
@media (max-width: 600px) {
  .gantt-linha { grid-template-columns: 1fr 50px; }
  .gantt-linha .gantt-trilho { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- pedido ---------- */
.etapas-status { display: flex; gap: 0; margin: 4px 0; }
.etapas-status .passo { flex: 1; text-align: center; position: relative; font-size: 12px; color: var(--muted); }
.etapas-status .passo .bola { width: 30px; height: 30px; border-radius: 50%; margin: 0 auto 6px; background: var(--surface-2); border: 2px solid var(--border); display: grid; place-items: center; font-weight: 700; position: relative; z-index: 1; }
.etapas-status .passo::before { content: ""; position: absolute; top: 15px; left: -50%; right: 50%; height: 2px; background: var(--border); }
.etapas-status .passo:first-child::before { display: none; }
.etapas-status .passo.feito .bola { background: var(--ok); border-color: var(--ok); color: #fff; }
.etapas-status .passo.feito::before { background: var(--ok); }
.etapas-status .passo.feito { color: var(--text); font-weight: 600; }

/* ---------- modal / lightbox / toast ---------- */
.modal-fundo { position: fixed; inset: 0; background: rgba(16,24,40,.55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 640px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal .modal-corpo { padding: 20px; overflow-y: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
@media (max-width: 600px) {
  .modal-fundo { padding: 0; align-items: flex-end; }
  .modal { max-width: none; border-radius: 16px 16px 0 0; max-height: 94vh; }
  .modal footer { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .modal footer .btn { flex: 1; }
}

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 200; display: flex; flex-direction: column; color: #fff; }
.lightbox .lb-img { flex: 1; display: grid; place-items: center; min-height: 0; padding: 12px; }
.lightbox .lb-img img { max-height: 100%; max-width: 100%; object-fit: contain; }
.lightbox .lb-info { padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); background: rgba(0,0,0,.5); }
.lightbox .lb-top { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; }
.lightbox button { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 50%; width: 44px; height: 44px; font-size: 20px; cursor: pointer; }
.lightbox .lb-prev, .lightbox .lb-next { position: absolute; top: 50%; transform: translateY(-50%); }
.lightbox .lb-prev { left: 10px; } .lightbox .lb-next { right: 10px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
#toast div { background: var(--brand); color: #fff; padding: 11px 18px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-weight: 500; }
#toast div.erro { background: var(--danger); }
@media (max-width: 860px) { #toast { bottom: calc(var(--nav-h) + 20px); } }

.notif-painel { position: fixed; right: 12px; top: 60px; width: min(380px, calc(100vw - 24px)); max-height: 70vh; overflow-y: auto; z-index: 50; }
.notif { display: block; padding: 12px 16px; border-bottom: 1px solid var(--border); color: inherit; }
.notif.nova { background: var(--accent-soft); }
.notif:last-child { border-bottom: 0; }

/* ---------- painel personalizável ---------- */
.painel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.widget { overflow: hidden; }
.widget.largo { grid-column: 1 / -1; }
.widget-topo { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.widget .grid-obras { padding: 16px; }
.kpis-mini { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; }
.kpi-mini { display: block; padding: 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: inherit; }
.kpi-mini:hover { border-color: #cfd5dd; }
.kpi-mini .valor { font-size: 22px; font-weight: 700; line-height: 1.15; }
.kpi-mini .rotulo { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.txt-perigo { color: var(--danger); font-weight: 600; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-forte); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.widget-cfg { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.widget-cfg select { width: auto; padding: 6px 8px; font-size: 14px; }
.widget-cfg.arrastando { opacity: .5; border-style: dashed; }
.widget-cfg .alca { cursor: grab; color: var(--muted); display: flex; }
.widget-cfg .alca svg { width: 18px; height: 18px; }
@media (max-width: 860px) {
  .painel-grid { grid-template-columns: 1fr; }
  .widget-cfg { flex-wrap: wrap; }
  .widget-cfg .alca { display: none; }
}

/* ---------- avisos, filtros ---------- */
.aviso-card { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-forte); font-weight: 500; }
.aviso-card.info { background: var(--info-soft); color: #1d4f9e; }
.aviso-card svg { width: 20px; height: 20px; flex: none; }
.filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filtros select, .filtros input { width: auto; font-size: 14px; padding: 8px 10px; }
.filtros label { display: flex; align-items: center; gap: 6px; }
.filtros input[name=busca] { flex: 1; min-width: 180px; }
[data-ir] { cursor: pointer; }

/* ---------- cotações ---------- */
.cab-titulo { min-width: min(100%, 300px); }
.tabela-rolagem { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.comparativo th, .comparativo td { white-space: nowrap; }
.comparativo th:first-child, .comparativo td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; white-space: normal; min-width: 160px; }
.comparativo thead th:first-child { background: var(--surface-2); }
.comparativo .cel-melhor { background: var(--ok-soft); color: #136b3a; font-weight: 700; }
.comparativo th.col-melhor { box-shadow: inset 0 3px 0 var(--ok); }
.comparativo th.col-vencedora { background: var(--ok-soft); }
.comparativo .linha-total td { font-weight: 700; font-size: 15px; border-top: 2px solid var(--border); }
.comparativo tfoot td { background: var(--surface-2); }
.comparativo tfoot td.cel-melhor { background: var(--ok-soft); }
.rank { display: inline-grid; place-items: center; min-width: 28px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; }
.rank.incompleta { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.sugestao { border-color: #b7e4c7; background: linear-gradient(180deg, #f3fbf6, #fff); }
.sugestao h3 { display: flex; align-items: center; gap: 6px; color: #136b3a; }
.sugestao h3 svg { width: 18px; height: 18px; }
.valor-grande { font-size: 24px; font-weight: 800; color: #136b3a; }
.mensagens { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); align-self: flex-start; }
.msg.minha { align-self: flex-end; background: var(--accent-soft); border-color: #ddd0fc; }
.opcao-aprovar { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.opcao-aprovar:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opcao-aprovar input { width: auto; }

/* ---------- capa e cabeçalho da obra ---------- */
.capa-vazia {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #fff;
  background: radial-gradient(circle at 80% 15%, rgba(110,51,245,.65), transparent 55%), linear-gradient(135deg, #241d3d, #16181d);
}
.capa-vazia span { font-size: 34px; font-weight: 600; letter-spacing: .04em; opacity: .95; }
.capa-vazia small { font-size: 12px; opacity: .6; padding: 0 16px; text-align: center; }
.obra-cabecalho { display: flex; gap: 18px; padding: 16px; align-items: stretch; }
.obra-cab-foto { width: 180px; min-height: 120px; border-radius: 12px; object-fit: cover; flex: none; position: relative; overflow: hidden; }
.obra-cab-foto.capa-vazia { position: relative; inset: auto; }
.fatos { display: flex; flex-wrap: wrap; gap: 10px 28px; }
.fatos > div { display: flex; flex-direction: column; min-width: 110px; }
.fatos span { font-size: 12px; color: var(--muted); }
.fatos strong { font-size: 15px; font-weight: 600; }
.fatos small { font-size: 12px; color: var(--muted); }
.fato-progresso { min-width: 180px !important; flex: 1; max-width: 260px; }
.fato-progresso .progresso { margin-top: 4px; }
@media (max-width: 700px) {
  .obra-cabecalho { flex-direction: column; padding: 12px; }
  .obra-cab-foto { width: 100%; height: 150px; }
}

/* ---------- projetos ---------- */
.tag.nao_iniciado, .tag.substituida { background: var(--surface-2); color: var(--muted); }
.tag.em_desenvolvimento, .tag.enviada { background: var(--info-soft); color: var(--info); }
.tag.em_revisao, .tag.aguardando { background: var(--accent-soft); color: var(--accent-forte); }
.tag.aprovado { background: var(--ok-soft); color: var(--ok); }
.tag.liberado_execucao { background: var(--ok); color: #fff; }
.tag.ajustes { background: var(--warn-soft); color: var(--warn); }
.grid-ambientes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.amb-card { overflow: hidden; color: inherit; display: flex; flex-direction: column; transition: box-shadow .15s, border-color .15s; }
.amb-card:hover { border-color: #d6c8fd; box-shadow: 0 8px 22px rgba(110,51,245,.10); }
.amb-capa { aspect-ratio: 16/10; position: relative; background: linear-gradient(135deg, #2a2440, #16181d); display: grid; place-items: center; }
.amb-capa img { width: 100%; height: 100%; object-fit: cover; }
.amb-capa > span:not(.tag) { font-size: 42px; color: rgba(255,255,255,.85); font-weight: 300; }
.amb-capa .tag { position: absolute; top: 10px; left: 10px; }
.amb-card .corpo { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.ambientes-mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; padding: 12px 16px 16px; }
.amb-mini { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; color: inherit; }
.amb-mini:hover { border-color: #d6c8fd; }
.amb-mini .grow { display: flex; flex-direction: column; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips a { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; white-space: nowrap; }
.chips a.ativo { background: var(--accent); border-color: var(--accent); color: #fff; }
.revisao { padding: 14px 16px; }
.revisao + .revisao { border-top: 1px dashed var(--border); }
.revisao.atual { background: linear-gradient(180deg, #faf8ff, #fff); }
.rev-num { font-weight: 700; font-size: 15px; background: var(--brand); color: #fff; padding: 2px 9px; border-radius: 8px; }
.obs-rev { margin-top: 8px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; font-size: 14px; }
.decisao { margin-top: 8px; padding: 8px 12px; border-radius: 10px; font-size: 13.5px; display: flex; gap: 8px; align-items: flex-start; }
.decisao svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.decisao.ok { background: var(--ok-soft); color: #136b3a; }
.decisao.ajustes { background: var(--warn-soft); color: #8a5a12; }
.arquivos { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.arquivo { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.arquivo .grow { display: flex; flex-direction: column; min-width: 0; }
.arquivo .nome { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ext { min-width: 44px; height: 32px; border-radius: 7px; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.ext-pdf { background: #fdecec; color: #c0392b; border-color: #f5c9c9; }
.ext-dwg, .ext-dxf { background: #e8f0fd; color: #2f6fdb; border-color: #cddcf7; }
.ext-rvt, .ext-ifc, .ext-skp { background: #f1ebfe; color: #4f1fc9; border-color: #ddd0fc; }
.ext-jpg, .ext-jpeg, .ext-png, .ext-webp { background: #e6f6ec; color: #1f9d55; border-color: #c4e8d1; }
.galeria-proj { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin-top: 10px; }
.galeria-proj img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.historico-rev summary { padding: 10px 16px; cursor: pointer; color: var(--muted); font-size: 13.5px; border-top: 1px solid var(--border); }
.historico-rev[open] summary { color: var(--text); }

/* ---------- histórico da obra ---------- */
.evento { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; color: inherit; }
.evento .grow { display: flex; flex-direction: column; }
.ev-titulo { font-weight: 500; }
.ev-icone { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.ev-icone svg { width: 15px; height: 15px; }
.ev-aprovacao .ev-icone, .ev-recebimento .ev-icone { background: var(--ok-soft); color: var(--ok); }
.ev-revisao .ev-icone, .ev-cotacao .ev-icone { background: var(--accent-soft); color: var(--accent-forte); }
.ev-ajustes .ev-icone { background: var(--warn-soft); color: var(--warn); }
.ev-pedido .ev-icone, .ev-compra .ev-icone { background: var(--info-soft); color: var(--info); }

/* ---------- fluxo de caixa, empresa ---------- */
.fluxo-grafico { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; height: 180px; align-items: end; }
.fluxo-mes { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.fluxo-mes .barras { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.fluxo-mes .barras i { width: 38%; max-width: 18px; border-radius: 4px 4px 0 0; min-height: 2px; }
.fluxo-mes span { font-size: 11px; color: var(--muted); }
.fluxo-mes.atual span { color: var(--accent-forte); font-weight: 700; }
.ent { background: #1f9d55; }
.sai { background: #e05252; }
i.leg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.logo-preview { width: 200px; height: 80px; border: 1px dashed var(--border); border-radius: 12px; display: grid; place-items: center; overflow: hidden; background: #fff; }
.logo-preview img { max-width: 90%; max-height: 90%; object-fit: contain; }
.oc-linha { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: #fff; gap: 10px; }
@media (max-width: 600px) { .fluxo-grafico { gap: 2px; } .fluxo-mes span { font-size: 9px; } }

/* ---------- 1ª entrega de melhorias: atraso, modos de exibição, projetos por obra ---------- */
.tag.atrasado { background: var(--danger); color: #fff; display: inline-flex; align-items: center; gap: 4px; }
.tag.atrasado svg { width: 12px; height: 12px; }
.kpi-mini.alerta { border-color: #f5c9c9; background: var(--danger-soft); animation: pulsa 2.4s ease-in-out infinite; }
@keyframes pulsa { 50% { box-shadow: 0 0 0 4px rgba(214,69,69,.12); } }
.alternador { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.alternador a { padding: 8px 10px; color: var(--muted); display: grid; place-items: center; }
.alternador a + a { border-left: 1px solid var(--border); }
.alternador a.ativo { background: var(--accent-soft); color: var(--accent-forte); }
.alternador svg { width: 18px; height: 18px; }
.grid-obras.pequeno { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.grid-obras.pequeno .obra-capa { aspect-ratio: 16/7; }
.grid-obras.pequeno .capa-vazia span { font-size: 22px; }
.grid-obras.pequeno .capa-vazia small { display: none; }
.grid-obras.pequeno .corpo { padding: 10px 12px 12px; gap: 6px; }
.grid-obras.pequeno .corpo > .small.muted:first-of-type { display: none; }
.obra-linha { align-items: center; }
.obra-linha .grow { display: flex; flex-direction: column; }
.obra-mini { width: 54px; height: 40px; border-radius: 8px; overflow: hidden; flex: none; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 14px;
  background: radial-gradient(circle at 80% 15%, rgba(110,51,245,.65), transparent 55%), linear-gradient(135deg, #241d3d, #16181d); }
.obra-mini img { width: 100%; height: 100%; object-fit: cover; }
.obra-linha-prog { width: 120px; display: flex; flex-direction: column; gap: 3px; text-align: right; }
@media (max-width: 700px) { .obra-linha-prog { display: none; } }
.projeto-obra { display: flex; gap: 18px; align-items: center; padding: 16px 18px; color: inherit; transition: border-color .15s, box-shadow .15s; }
.projeto-obra:hover { border-color: #d6c8fd; box-shadow: 0 8px 22px rgba(110,51,245,.10); }
.projeto-obra .grow { display: flex; flex-direction: column; gap: 6px; }
.amb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.projeto-obra-prog { width: 150px; display: flex; flex-direction: column; gap: 2px; text-align: right; flex: none; }
.projeto-obra-prog strong { font-size: 22px; font-weight: 600; }
@media (max-width: 700px) { .projeto-obra { flex-direction: column; align-items: stretch; } .projeto-obra-prog { width: auto; text-align: left; } }
.endereco { padding: 0; }
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }

/* ---------- 2ª entrega: catálogo, custos, subetapas ---------- */
.sugestoes { position: fixed; z-index: 400; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 14px 34px rgba(16,24,40,.18);
  max-height: 360px; overflow-y: auto; padding: 4px; }
.sugestao-item { display: flex; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 8px; font: inherit; cursor: pointer; color: var(--text); }
.sugestao-item .grow { display: flex; flex-direction: column; gap: 2px; }
.sugestao-item.ativo, .sugestao-item:hover { background: var(--accent-soft); }
.sugestao-vazia { padding: 10px; }
.fase-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 9px 2px 7px; border-radius: 99px;
  background: color-mix(in srgb, var(--cor) 14%, white); color: color-mix(in srgb, var(--cor) 80%, black); }
.fase-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--cor); }
.custos-graficos { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.barra-linha .progresso { margin-top: 3px; }
.mes-barras { display: flex; align-items: flex-end; gap: 6px; height: 150px; }
.mes-barras > div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.mes-barras i { width: 70%; max-width: 30px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.mes-barras span { font-size: 11px; color: var(--muted); }
.gantt-linha.sub { padding-left: 54px; background: var(--surface-2); }
.gantt-linha.sub strong { font-weight: 500; }
.gantt-barra.mestra { background: #b9b2d6; }
.abrir-etapa { flex: none; }
/* Arrastar etapas pela alça (mouse e toque). */
.alca-etapa { flex: none; display: grid; place-items: center; width: 24px; height: 32px; margin-left: -6px; border-radius: 6px; color: var(--muted); cursor: grab; touch-action: none; user-select: none; }
.alca-etapa:hover { background: var(--surface-2); color: var(--accent); }
.alca-etapa svg { width: 18px; height: 18px; }
.etapa-item.arrastando { position: relative; z-index: 2; opacity: .9; box-shadow: 0 8px 24px var(--accent-anel); outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface); cursor: grabbing; }
.etapa-item.arrastando .alca-etapa { cursor: grabbing; }
@media (max-width: 600px) { .gantt-linha.sub { padding-left: 28px; } }

/* ---------- login ---------- */
.login-tela { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 85% 10%, rgba(110,51,245,.55), transparent 45%), linear-gradient(160deg, #16181d 0%, #1f1b2e 60%, #2b1d5c 100%); }
.login-card { width: 100%; max-width: 400px; padding: 28px; }
.login-card .logo { color: var(--text); padding: 0 0 6px; font-size: 26px; }
.login-card .logo .marca-simbolo { width: 40px; height: 40px; }

.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: gira .8s linear infinite; margin: 40px auto; }
@keyframes gira { to { transform: rotate(360deg); } }

@media print {
  .sidebar, .topbar, .bottom-nav, .btn { display: none !important; }
  .layout { display: block; }
}

/* ---------- mão de obra ---------- */
.presenca-lista { display: flex; flex-direction: column; gap: 8px; }
.presenca-linha { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); flex-wrap: wrap; }
.presenca-linha .grow strong { display: block; }
.presenca-linha .grow .small { display: block; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex: none; }
.seg-op { font: inherit; font-size: 14px; font-weight: 600; padding: 10px 14px; min-height: 44px; border: 0; border-right: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; }
.seg-op:last-child { border-right: 0; }
.seg-op:disabled { cursor: default; opacity: .75; }
.seg-op.inteira.ativo { background: var(--ok); color: #fff; }
.seg-op.meia.ativo { background: var(--warn); color: #fff; }
.seg-op.falta.ativo { background: var(--danger); color: #fff; }
@media (max-width: 600px) { .seg { width: 100%; } .seg-op { flex: 1; padding: 10px 6px; } }
.equipe-dia { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.equipe-dia h3 { display: flex; align-items: center; gap: 8px; }
.equipe-dia h3 svg { width: 18px; height: 18px; color: var(--accent); }
.pessoa-dia { display: inline-block; padding: 3px 10px; margin: 0 6px 6px 0; border-radius: 99px; background: var(--ok-soft); }
.quadro-rolagem { overflow-x: auto; }
.quadro-presenca { border-collapse: collapse; width: 100%; font-size: 13px; }
.quadro-presenca th, .quadro-presenca td { border-bottom: 1px solid var(--border); padding: 6px 4px; text-align: center; white-space: nowrap; }
.quadro-presenca tbody th { text-align: left; padding: 6px 12px 6px 16px; position: sticky; left: 0; background: var(--surface); min-width: 150px; }
.quadro-presenca tbody th span { display: block; font-weight: 600; }
.quadro-presenca tbody th small { color: var(--muted); font-weight: 400; }
.quadro-presenca thead th:first-child { text-align: left; padding-left: 16px; position: sticky; left: 0; background: var(--surface); }
.quadro-presenca thead button { font: inherit; font-size: 11.5px; font-weight: 600; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 4px 2px; border-radius: 6px; position: relative; }
.quadro-presenca thead button:hover { background: var(--accent-soft); color: var(--accent-forte); }
.quadro-presenca th.hoje button { color: var(--accent); }
.quadro-presenca th.domingo button { color: var(--danger); }
.fechado-ponto { position: absolute; top: 0; right: -2px; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.quadro-presenca td.p-inteira { color: var(--ok); font-size: 15px; }
.quadro-presenca td.p-meia { color: var(--warn); font-size: 15px; }
.quadro-presenca td.p-falta { color: var(--danger); }
.quadro-presenca td.pago, .pago-mini { opacity: .45; }
.mo-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.mo-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.mo-numeros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mo-numeros > div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.mo-numeros span, .mo-numeros small { display: block; font-size: 11.5px; color: var(--muted); }
.mo-numeros strong { display: block; font-size: 14px; overflow-wrap: anywhere; }
.vale-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); font-weight: 600; margin: 2px 2px 0 0; }
.vale-chip.descontado { background: var(--surface-2); color: var(--muted); }
.link-x { border: 0; background: none; color: inherit; font-size: 15px; line-height: 1; cursor: pointer; padding: 0 2px; }
.acerto-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.acerto-item:last-child { border-bottom: 0; }
.acerto-item > input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.acerto-item .grow > span { display: block; }
.acerto-valor { font-size: 16px; white-space: nowrap; }

/* visão geral da mão de obra */
.mo-painel-grade { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.lista-proximos { max-height: 340px; overflow-y: auto; }
.proximo-linha { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; }
.proximo-linha:last-child { border-bottom: 0; }
.proximo-linha:hover { background: var(--surface-2); }
.proximo-linha .grow { min-width: 0; }
.proximo-linha .grow > span { display: block; }
.proximo-linha > strong { white-space: nowrap; }
@media (max-width: 860px) { .mo-painel-grade { grid-template-columns: 1fr; } }

/* prestação de contas (obra por administração) */
.prestacao-resumo { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: center; }
.prestacao-resumo > div:first-child { container-type: inline-size; min-width: 0; }
@container (max-width: 420px) {
  .prestacao-resumo .rosca { grid-template-columns: 1fr; justify-items: center; }
  .prestacao-resumo .legenda { width: 100%; }
}
.prestacao-resumo .total-linha { border-top: 1px solid var(--border); padding-top: 8px; font-size: 16px; }
.fechar-mes { border-left: 4px solid var(--accent); }
@media (max-width: 700px) { .prestacao-resumo { grid-template-columns: 1fr; } }

/* ---------- temas de cor: roxo escuro e escuro (o claro é o :root) ---------- */
[data-tema="roxo"] {
  --bg: #150f29; --surface: #1f1838; --surface-2: #2a2148; --text: #eeeaf8; --muted: #a8a1c4; --border: #3a2f60;
  --brand: #0f0a1f; --accent: #8b5cff; --accent-soft: #33275e; --accent-forte: #cbb8ff; --accent-anel: rgba(139, 92, 255, .4);
  --ok: #3fd07f; --ok-soft: #173b2c; --info: #74a8ff; --info-soft: #1d2c52; --warn: #f2b955; --warn-soft: #3b2f18; --danger: #ff6f7a; --danger-soft: #42192a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .25);
  --menu-fundo: linear-gradient(180deg, #110a26 0%, #1c1043 100%);
  --g1: #9b6dff; --g2: #5b8ff0; --g3: #3fd07f; --g4: #f2a33a; --g5: #f062a8; --g6: #2fc4b2; --g7: #c084fc; --g8: #8c86a8;
  --rosca-fundo: #2e2550;
  color-scheme: dark;
}
[data-tema="escuro"] {
  --bg: #0e1014; --surface: #171a21; --surface-2: #1f232c; --text: #e8eaef; --muted: #9399a5; --border: #2b303b;
  --brand: #0a0b0f; --accent: #8b5cff; --accent-soft: #261f3d; --accent-forte: #c7b3ff; --accent-anel: rgba(139, 92, 255, .4);
  --ok: #3fd07f; --ok-soft: #15301f; --info: #74a8ff; --info-soft: #172338; --warn: #f2b955; --warn-soft: #33290f; --danger: #ff6f7a; --danger-soft: #3a1a20;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 8px rgba(0, 0, 0, .3);
  --menu-fundo: linear-gradient(180deg, #0a0b0f 0%, #121419 100%);
  --g1: #9b6dff; --g2: #5b8ff0; --g3: #3fd07f; --g4: #f2a33a; --g5: #f062a8; --g6: #2fc4b2; --g7: #c084fc; --g8: #8a909c;
  --rosca-fundo: #262a34;
  color-scheme: dark;
}
/* Peças que tinham fundo branco ou cor fixa clara. */
:is([data-tema="roxo"], [data-tema="escuro"]) :is(input, select, textarea) { background: var(--surface-2); border-color: var(--border); color: var(--text); }
:is([data-tema="roxo"], [data-tema="escuro"]) label.campo { color: var(--text); }
:is([data-tema="roxo"], [data-tema="escuro"]) :is(.upload-item, .widget-cfg, .arquivo, .oc-linha, .logo-preview) { background: var(--surface-2); }
:is([data-tema="roxo"], [data-tema="escuro"]) .logo-preview img { background: #fff; }
:is([data-tema="roxo"], [data-tema="escuro"]) .aviso { border-color: transparent; }
:is([data-tema="roxo"], [data-tema="escuro"]) .aviso-card.info { color: var(--info); }
:is([data-tema="roxo"], [data-tema="escuro"]) :is(.sugestao, .revisao.atual) { background: var(--surface); }
:is([data-tema="roxo"], [data-tema="escuro"]) :is(.sugestao h3, .valor-grande, .comparativo .cel-melhor, .decisao.ok) { color: var(--ok); }
:is([data-tema="roxo"], [data-tema="escuro"]) .decisao.ajustes { color: var(--warn); }
:is([data-tema="roxo"], [data-tema="escuro"]) .calendario button.fora { color: #5d6270; }
:is([data-tema="roxo"], [data-tema="escuro"]) .gantt-barra { background: #3a3f4c; }
:is([data-tema="roxo"], [data-tema="escuro"]) .gantt-barra.mestra { background: #4d4373; }
:is([data-tema="roxo"], [data-tema="escuro"]) .fase-chip { background: color-mix(in srgb, var(--cor) 22%, transparent); color: color-mix(in srgb, var(--cor) 55%, white); }
:is([data-tema="roxo"], [data-tema="escuro"]) :is(.ext-pdf, .ext-dwg, .ext-dxf, .ext-rvt, .ext-ifc, .ext-skp, .ext-jpg, .ext-jpeg, .ext-png, .ext-webp) { background: var(--surface-2); border-color: var(--border); }
:is([data-tema="roxo"], [data-tema="escuro"]) :is(a.kpi:hover, .kpi-mini:hover, .amb-card:hover, .projeto-obra:hover) { border-color: var(--accent); }
:is([data-tema="roxo"], [data-tema="escuro"]) .kpi-mini.alerta { border-color: var(--danger); }
:is([data-tema="roxo"], [data-tema="escuro"]) .login-card .logo { color: var(--text); }
.tag svg { width: 12px; height: 12px; }

/* Escolha do tema: miniatura com fundo, menu e destaque de cada um. */
.temas { display: flex; flex-wrap: wrap; gap: 10px; }
.tema-opcao { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; cursor: pointer; padding: 8px; border-radius: 12px; border: 2px solid transparent; }
.tema-opcao.ativo { border-color: var(--accent); background: var(--accent-soft); }
.tema-opcao:focus-within { outline: 2px solid var(--accent-anel); }
.tema-opcao input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
/* Tabela larga dentro de cartão rola de lado, sem empurrar a página. */
.card:has(> table.tabela) { overflow-x: auto; }
.tema-mini { width: 96px; height: 62px; border-radius: 9px; position: relative; overflow: hidden; border: 1px solid var(--border); background: #f1f1f3; }
.tema-mini i { position: absolute; left: 0; top: 0; bottom: 0; width: 26px; background: #17181d; }
.tema-mini b { position: absolute; left: 34px; right: 8px; top: 10px; height: 16px; border-radius: 4px; background: #fff; }
.tema-mini u { position: absolute; left: 34px; width: 30px; top: 34px; height: 12px; border-radius: 4px; background: #6e33f5; }
.tema-mini[data-amostra="roxo"] { background: #150f29; }
.tema-mini[data-amostra="roxo"] i { background: #1c1043; }
.tema-mini[data-amostra="roxo"] b { background: #2a2148; }
.tema-mini[data-amostra="roxo"] u { background: #8b5cff; }
.tema-mini[data-amostra="escuro"] { background: #0e1014; }
.tema-mini[data-amostra="escuro"] i { background: #0a0b0f; }
.tema-mini[data-amostra="escuro"] b { background: #1f232c; }
.tema-mini[data-amostra="escuro"] u { background: #8b5cff; }

/* ---------- cartões de número com ícone ---------- */
.kpi-grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi-card { --tom: var(--accent); --tom-soft: var(--accent-soft); display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: inherit; transition: border-color .15s, transform .15s; min-width: 0; }
.kpi-card:hover { border-color: var(--tom); transform: translateY(-1px); }
.kpi-card .kpi-icone { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--tom-soft); color: var(--tom); flex: none; }
.kpi-card .kpi-icone svg { width: 21px; height: 21px; }
.kpi-card .valor { display: block; font-size: 22px; font-weight: 700; line-height: 1.15; letter-spacing: -.015em; overflow-wrap: anywhere; }
.kpi-card .rotulo { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi-card .detalhe { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-card.tom-ok { --tom: var(--ok); --tom-soft: var(--ok-soft); }
.kpi-card.tom-info { --tom: var(--info); --tom-soft: var(--info-soft); }
.kpi-card.tom-warn { --tom: var(--warn); --tom-soft: var(--warn-soft); }
.kpi-card.tom-danger { --tom: var(--danger); --tom-soft: var(--danger-soft); }
.kpi-card.tom-neutro { --tom: var(--muted); --tom-soft: var(--surface-2); }
.kpi-card.alerta { border-color: var(--danger); background: var(--danger-soft); animation: pulsa 2.4s ease-in-out infinite; }
.widget { container-type: inline-size; }
.widget .kpi-grade { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.widget .kpi-card { background: var(--surface-2); padding: 12px; gap: 10px; }
.widget .kpi-card .kpi-icone { width: 36px; height: 36px; border-radius: 10px; }
.widget .kpi-card .valor { font-size: 20px; }
/* Bloco estreito (metade da tela): gráfico e lista um embaixo do outro. */
@container (max-width: 620px) {
  .widget .grafico-par { grid-template-columns: 1fr; }
}
@container (max-width: 360px) {
  .widget .rosca, .widget-grafico .grafico-par .rosca { grid-template-columns: 1fr; justify-items: center; }
  .widget .legenda { width: 100%; }
  .widget .kpi-grade { grid-template-columns: 1fr 1fr; }
}

/* ---------- gráficos ---------- */
.rosca { display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: center; }
.rosca svg { width: 150px; height: 150px; display: block; }
.rosca-fundo { stroke: var(--rosca-fundo); }
.rosca circle { transition: opacity .15s; }
.rosca svg:hover circle:not(.rosca-fundo) { opacity: .75; }
.rosca svg circle:not(.rosca-fundo):hover { opacity: 1; }
.rosca-centro { font-size: 17px; font-weight: 700; fill: var(--text); }
.rosca-sub { font-size: 10px; fill: var(--muted); }
.legenda { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 13px; }
.legenda li, .legenda li a { display: flex; align-items: center; gap: 8px; color: inherit; min-width: 0; }
.legenda li a { flex: 1; }
.legenda li a:hover .grow { text-decoration: underline; }
.legenda i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legenda .grow { line-height: 1.25; overflow-wrap: anywhere; }
.rosca-centro.longo { font-size: 13px; }
.legenda strong { white-space: nowrap; }
.legenda small { color: var(--muted); min-width: 34px; text-align: right; }
.grafico-par { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.widget-grafico .grafico-par .rosca { grid-template-columns: 130px 1fr; }
.widget-grafico .grafico-par .rosca svg { width: 130px; height: 130px; }
.grafico-vazio { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 13px; border: 1px dashed var(--border); border-radius: 10px; }
.barras-mes { display: flex; align-items: stretch; gap: 6px; height: 140px; }
.barras-mes .col { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.barras-mes .pilha { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 3px; border-bottom: 1px solid var(--border); }
.barras-mes .pilha i { flex: 1; max-width: 22px; border-radius: 4px 4px 0 0; min-height: 2px; transition: filter .15s; }
.barras-mes .col:hover .pilha i { filter: brightness(1.15); }
.barras-mes span { font-size: 11px; color: var(--muted); text-align: center; }
.barras-mes .col.atual span { color: var(--accent); font-weight: 700; }
.legenda-linha { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legenda-linha span { display: inline-flex; align-items: center; gap: 6px; }
.legenda-linha i { width: 10px; height: 10px; border-radius: 3px; }
.form-grid.compras-graficos { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.compras-graficos > .card { container-type: inline-size; min-width: 0; }
@container (max-width: 400px) {
  .compras-graficos .rosca { grid-template-columns: 1fr; justify-items: center; }
  .compras-graficos .legenda { width: 100%; }
}
@media (max-width: 860px) {
  .grafico-par { grid-template-columns: 1fr; }
  .rosca, .widget-grafico .grafico-par .rosca { grid-template-columns: 120px 1fr; gap: 12px; }
  .rosca svg, .widget-grafico .grafico-par .rosca svg { width: 120px; height: 120px; }
  .form-grid.compras-graficos { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .rosca, .widget-grafico .grafico-par .rosca { grid-template-columns: 1fr; justify-items: center; }
  .legenda { width: 100%; }
}

/* ---------- perfis de acesso ---------- */
.perfis-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.perfil-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.perfil-card:hover { border-color: var(--accent); }
.perfil-card h3 { display: flex; align-items: center; gap: 8px; }
.perfil-card h3 svg { width: 18px; height: 18px; color: var(--accent); }
.perfil-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.perfil-chip { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--info-soft); color: var(--info); }
.perfil-chip.tudo { background: var(--ok-soft); color: var(--ok); }
.perfil-chip.so-ver { background: var(--surface-2); color: var(--muted); }
.matriz th, .matriz-celula { text-align: center; width: 76px; }
.matriz th:first-child { text-align: left; width: auto; }
.matriz-check { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; cursor: pointer; }
.matriz-check:hover { background: var(--accent-soft); }
.matriz-check input { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
@media (max-width: 860px) {
  .matriz tbody tr { display: grid; grid-template-columns: repeat(4, 1fr); }
  .matriz tbody td:first-child { grid-column: 1 / -1; }
  .matriz-celula { width: auto; }
}

/* ---------- meu plano ---------- */
.plano-topo { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.planos-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; align-items: stretch; }
.plano-card { display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.plano-card.atual { border: 2px solid var(--accent); box-shadow: 0 8px 24px var(--accent-anel); }
.plano-card .btn-bloco { margin-top: auto; }
.plano-preco { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.plano-preco small { font-size: 13px; font-weight: 500; color: var(--muted); }
.plano-limites { list-style: none; margin: 0; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.plano-limites li { display: flex; justify-content: space-between; gap: 10px; }
.plano-limites span { color: var(--muted); }
.plano-itens { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.plano-itens li { display: flex; gap: 8px; align-items: flex-start; }
.plano-itens svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.plano-itens li.tem svg { color: var(--ok); }
.plano-itens li.nao { color: var(--muted); }
.plano-itens li.nao span { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent); }
