:root{
  --navy:#24206a; --navy-2:#342f8b; --sidebar-bg:#1c1852; --sidebar-active:#322c86;
  --gold:#f8c32c; --gold-dark:#e5aa02; --gold-bg:#fff8e1;
  --purple:#7c5cff; --purple-bg:#efeaff;
  --ok:#16a34a; --ok-bg:#e9f9ef;
  --warn:#d97706; --warn-bg:#fef3e0;
  --danger:#dc2626; --danger-bg:#fdeeee;
  --blue:#2563eb; --blue-bg:#eaf1fd;
  --gray:#6b7280; --gray-bg:#f3f4f6;
  --ink:#1e2130; --ink-muted:#6b7280; --border:#e8e9ef; --surface:#ffffff; --bg:#f5f6fb;
  --sidebar-w:250px;
}
*{box-sizing:border-box;}
body{margin:0; font-family:'Plus Jakarta Sans',sans-serif; background:var(--bg); color:var(--ink); font-size:14px;}
a{text-decoration:none; color:inherit;}

/* ---------- login ---------- */
.tela-login{display:flex; align-items:center; justify-content:center; min-height:100vh; background:linear-gradient(135deg,var(--navy),var(--navy-2));}
.login-card{background:var(--surface); border-radius:16px; padding:36px 40px; width:100%; max-width:380px; box-shadow:0 20px 60px rgba(0,0,0,.25);}
.login-titulo{margin:0 0 4px; font-size:22px; font-weight:800; color:var(--navy);}
.login-sub{margin:0 0 20px; color:var(--ink-muted); font-size:13px;}

.field{margin-bottom:14px;}
.field label{display:flex; align-items:center; gap:6px; font-size:12.5px; font-weight:600; color:var(--ink-muted); margin-bottom:5px;}
.field label svg{width:14px; height:14px; flex-shrink:0;}
.field input, .field select{width:100%; padding:9px 11px; border:1px solid var(--border); border-radius:8px; font-size:14px; font-family:inherit; background:#fff;}
.field input:focus, .field select:focus{outline:2px solid var(--navy-2); outline-offset:-1px;}
.field input:disabled{background:#f7f7fa; color:var(--ink-muted);}

.btn{display:inline-flex; align-items:center; justify-content:center; gap:7px; padding:9px 16px; border-radius:9px; font-weight:700; font-size:13px; cursor:pointer; border:none; transition:filter .15s;}
.btn svg{width:16px; height:16px;}
.btn:hover{filter:brightness(.95);}
.btn-primary{background:var(--navy); color:#fff;}
.btn-secondary{background:#eef0f5; color:var(--ink);}
.btn-danger{background:var(--danger-bg); color:var(--danger);}
.btn-sm{padding:6px 12px; font-size:12px;}

.alert{padding:10px 14px; border-radius:8px; font-size:13px; margin-bottom:14px;}
.alert.erro{background:var(--danger-bg); color:var(--danger);}
.alert.ok{background:var(--ok-bg); color:var(--ok);}

/* ================== APP SHELL: sidebar fixa + conteúdo ================== */
.app-shell{min-height:100vh;}

.sidebar{
  position:fixed; top:0; left:0; bottom:0; width:var(--sidebar-w);
  background:var(--sidebar-bg); color:#d8d5f2; display:flex; flex-direction:column;
  z-index:200; padding:18px 14px;
}
.sidebar-brand{display:flex; align-items:center; gap:10px; padding:6px 8px 22px;}
.sidebar-brand-mark{width:34px; height:34px; border-radius:9px; background:linear-gradient(135deg,var(--purple),#5b3fd6); display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.sidebar-brand-mark svg{width:19px; height:19px; color:#fff;}
.sidebar-brand-text{font-size:15px; font-weight:800; color:#fff; line-height:1.15;}
.sidebar-brand-text small{font-size:11px; font-weight:600; color:#a9a4d8; letter-spacing:.3px;}

.sidebar-nav{flex:1; display:flex; flex-direction:column; gap:3px; overflow-y:auto;}
.side-link{display:flex; align-items:center; gap:11px; padding:10px 12px; border-radius:10px; font-size:13.5px; font-weight:600; color:#c3bfe8; transition:background .15s, color .15s;}
.side-link svg{width:18px; height:18px; flex-shrink:0;}
.side-link:hover{background:rgba(255,255,255,.06); color:#fff;}
.side-link.active{background:var(--sidebar-active); color:#fff; font-weight:700; box-shadow:0 4px 14px rgba(50,44,134,.5);}
.side-badge{margin-left:auto; background:var(--danger); color:#fff; font-size:11px; font-weight:800; min-width:19px; height:19px; padding:0 5px; border-radius:999px; display:inline-flex; align-items:center; justify-content:center;}

.sidebar-footer{border-top:1px solid rgba(255,255,255,.1); padding-top:14px; margin-top:10px;}
.sidebar-user{display:flex; align-items:center; gap:10px; padding:4px 6px 12px;}
.sidebar-user-avatar{width:34px; height:34px; border-radius:50%; background:var(--gold); color:#4a3400; font-weight:800; font-size:12.5px; display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.sidebar-user-info{display:flex; flex-direction:column; min-width:0;}
.sidebar-user-nome{font-size:12.5px; font-weight:700; color:#fff; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.sidebar-user-papel{font-size:11px; color:#a9a4d8;}
.sidebar-sair{display:flex; align-items:center; gap:9px; padding:9px 12px; border-radius:10px; font-size:13px; font-weight:600; color:#e5a3a3; background:rgba(220,38,38,.12);}
.sidebar-sair svg{width:16px; height:16px;}
.sidebar-sair:hover{background:rgba(220,38,38,.22);}

.sidebar-overlay{display:none; position:fixed; inset:0; background:rgba(10,8,40,.5); z-index:190;}
.sidebar-overlay.show{display:block;}

.mobile-menu-btn{display:none; background:#fff; border:1px solid var(--border); border-radius:9px; width:38px; height:38px; align-items:center; justify-content:center; cursor:pointer; margin-bottom:14px;}
.mobile-menu-btn svg{width:19px; height:19px; color:var(--ink);}

.content-area{margin-left:var(--sidebar-w); padding:26px 30px 40px; max-width:1400px;}

@media (max-width:900px){
  .sidebar{transform:translateX(-100%); transition:transform .2s ease; box-shadow:0 0 30px rgba(0,0,0,.3);}
  .sidebar.mobile-open{transform:translateX(0);}
  .content-area{margin-left:0;}
  .mobile-menu-btn{display:flex;}
}

/* ---------- cabeçalho de página ---------- */
.page-head-row{display:flex; align-items:flex-start; justify-content:space-between; gap:16px; flex-wrap:wrap; margin-bottom:22px;}
.page-title{margin:0 0 4px; font-size:23px; font-weight:800;}
.page-sub{margin:0; color:var(--ink-muted); font-size:13.5px; max-width:640px;}
.periodo-pill{display:flex; align-items:center; gap:8px; background:#fff; border:1px solid var(--border); border-radius:10px; padding:9px 14px; font-size:13px; font-weight:700; color:var(--navy); white-space:nowrap;}
.periodo-pill svg{width:16px; height:16px; color:var(--purple);}
.periodo-pill .lbl{color:var(--ink-muted); font-weight:600; margin-right:2px;}

.panel{background:var(--surface); border:1px solid var(--border); border-radius:14px; margin-bottom:20px; overflow:hidden;}
.panel-head{padding:16px 20px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap;}
.panel-head h2{margin:0; font-size:15px; font-weight:800; display:flex; align-items:center; gap:7px;}
.panel-head h2 svg{width:17px; height:17px; flex-shrink:0; color:var(--purple);}
.panel-body{padding:20px;}
.muted{color:var(--ink-muted); font-size:12.5px;}

.filtros-inline{display:flex; align-items:end; gap:14px; flex-wrap:wrap;}
.filtros-inline .field{margin-bottom:0; min-width:170px;}
.filtros-inline .field:first-child{min-width:230px;}
.filtros-inline .field.campo-tecnico{min-width:240px; flex:1 1 260px;}
.filtros-inline .field.cta{margin-left:auto;}

/* ---------- placeholder de página em construção ---------- */
.em-construcao{padding:44px 20px; text-align:center; color:var(--ink-muted);}
.em-construcao svg{width:38px; height:38px; color:var(--purple); margin-bottom:12px;}

/* ---------- estado vazio (nenhum boletim gerado ainda) ---------- */
.estado-vazio{padding:40px 20px; text-align:center; color:var(--ink-muted);}
.estado-vazio svg{width:34px; height:34px; color:var(--purple); margin-bottom:10px;}

/* ---------- cards de resumo ---------- */
.stat-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:20px;}
.stat-card{background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:18px 18px 16px; position:relative; overflow:hidden; transition:box-shadow .15s ease, transform .15s ease;}
.stat-card:hover{box-shadow:0 8px 20px rgba(24,20,80,.08); transform:translateY(-2px);}
.stat-card::before{content:''; position:absolute; left:0; top:0; bottom:0; width:4px; background:var(--accent, var(--purple));}
.stat-card-top{display:flex; align-items:center; gap:12px; margin-bottom:12px;}
.stat-card-icon{width:38px; height:38px; border-radius:10px; background:var(--accent-bg, var(--purple-bg)); display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.stat-card-icon svg{width:19px; height:19px; color:var(--accent, var(--purple));}
.stat-card-label{font-size:12.5px; font-weight:700; color:var(--ink-muted);}
.stat-card-n{font-size:26px; font-weight:800; line-height:1.1;}
.stat-card-n.cor{color:var(--accent, var(--ink));}
.stat-card-sub{font-size:12px; color:var(--ink-muted); margin-top:3px;}
.stat-card.roxo{--accent:var(--purple); --accent-bg:var(--purple-bg);}
.stat-card.vermelho{--accent:var(--danger); --accent-bg:var(--danger-bg);}
.stat-card.verde{--accent:var(--ok); --accent-bg:var(--ok-bg);}
.stat-card.azul{--accent:var(--blue); --accent-bg:var(--blue-bg);}
.stat-card.cinza{--accent:var(--gray); --accent-bg:var(--gray-bg);}

.pill{display:inline-flex; padding:4px 10px; border-radius:999px; font-size:12px; font-weight:700;}

/* ---------- grid duas colunas (tabela + gráfico / heatmap + insights) ---------- */
.row-2col{display:grid; grid-template-columns:1.05fr 1fr; gap:20px; align-items:stretch;}
.row-2col.heat{grid-template-columns:1fr 320px;}
@media (max-width:1100px){ .row-2col, .row-2col.heat{grid-template-columns:1fr;} }

.tabela-wrap{overflow-x:auto;}
table.tbl{width:100%; border-collapse:collapse; font-size:13px;}
table.tbl th{background:#fafbfc; text-align:left; font-size:11px; font-weight:800; text-transform:uppercase; color:var(--ink-muted); padding:10px 12px; border-bottom:1px solid var(--border); letter-spacing:.2px;}
table.tbl td{text-align:left; padding:10px 12px; border-bottom:1px solid #f0f1f5;}
table.tbl tr.linha-reincidente{background:var(--danger-bg);}
table.tbl tr.linha-reincidente td:first-child{border-left:3px solid var(--danger);}
.tabela-rodape-msg{padding:11px 16px; font-size:12.5px; color:var(--danger); background:#fff6f6; border-top:1px solid var(--border); font-weight:600;}
.tabela-rodape-msg.ok{color:var(--ok); background:#f4fcf7;}

/* ---------- gráfico de evolução (SVG) ---------- */
.grafico-wrap{position:relative; padding:8px 4px 0;}
.grafico-tooltip{position:absolute; pointer-events:none; background:var(--navy); color:#fff; font-size:11.5px; font-weight:600; padding:6px 10px; border-radius:8px; transform:translate(-50%,-115%); white-space:nowrap; opacity:0; transition:opacity .1s; z-index:5;}
.grafico-tooltip.show{opacity:1;}
.grafico-tooltip .d{color:#c9c4f0; font-weight:600; font-size:10.5px;}
.grafico-legenda-meta{display:flex; align-items:center; gap:6px; font-size:11px; color:var(--ink-muted); justify-content:flex-end; margin-top:2px;}
.grafico-legenda-meta .linha{width:14px; height:0; border-top:2px dashed var(--danger); display:inline-block;}

/* ---------- heatmap diário ---------- */
.dia-grid{display:grid; grid-template-columns:repeat(auto-fill, minmax(78px,1fr)); gap:8px;}
.dia-cell{border-radius:10px; padding:8px 6px; text-align:center; border:1px solid var(--border); background:var(--gray-bg);}
.dia-cell.vazio{opacity:.45;}
.dia-cell.excelente{background:var(--ok-bg); border-color:#c9edd6;}
.dia-cell.atencao{background:var(--warn-bg); border-color:#f6ddb0;}
.dia-cell.critico{background:var(--danger-bg); border-color:#f6cccc;}
.dia-num{font-weight:800; font-size:11px; color:var(--ink-muted); margin-bottom:2px;}
.dia-os{font-size:10.5px; color:var(--ink-muted); margin-bottom:1px;}
.dia-fal{font-size:9.5px; font-weight:800; color:#fff; background:var(--danger); border-radius:5px; padding:1px 5px; display:inline-block; margin-bottom:2px; line-height:1.3;}
.dia-fal.oculto{visibility:hidden;}
.dia-irr{font-size:12px; font-weight:800;}
.dia-irr .seta{font-size:10px; margin-left:2px;}
.dia-irr .seta.seta-up{color:var(--danger);}
.dia-irr .seta.seta-down{color:var(--ok);}
.dia-irr .seta.seta-flat{color:var(--ink-muted);}
.dia-cell.excelente .dia-irr{color:var(--ok);}
.dia-cell.atencao .dia-irr{color:var(--warn);}
.dia-cell.critico .dia-irr{color:var(--danger);}
.dia-cell.vazio .dia-irr{color:var(--ink-muted); font-weight:600;}

.heatmap-legenda{display:flex; gap:16px; flex-wrap:wrap; padding:14px 20px; border-top:1px solid var(--border); font-size:11.5px; color:var(--ink-muted);}
.heatmap-legenda span{display:inline-flex; align-items:center; gap:6px;}
.heatmap-legenda i{width:10px; height:10px; border-radius:3px; display:inline-block;}
.heatmap-legenda i.excelente{background:var(--ok);}
.heatmap-legenda i.atencao{background:var(--warn);}
.heatmap-legenda i.critico{background:var(--danger);}
.heatmap-legenda i.vazio{background:#c7c9d4;}

/* ---------- insights / dicas ---------- */
.insight-item{display:flex; gap:11px; padding:11px 0; border-bottom:1px solid var(--border);}
.insight-item:last-child{border-bottom:none;}
.insight-icon{width:32px; height:32px; border-radius:9px; background:var(--purple-bg); display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.insight-icon svg{width:16px; height:16px; color:var(--purple);}
.insight-titulo{font-size:12.5px; font-weight:700; margin-bottom:2px;}
.insight-desc{font-size:11.5px; color:var(--ink-muted); line-height:1.4;}

.card-incentivo{border-radius:14px; padding:16px 18px; display:flex; gap:12px; align-items:flex-start; margin-top:16px;}
.card-incentivo.positivo{background:linear-gradient(135deg,#eafcf1,#f2fbe8); border:1px solid #c9edd6;}
.card-incentivo.alerta{background:linear-gradient(135deg,#fdeeee,#fdf3ea); border:1px solid #f6cccc;}
.card-incentivo-icon{width:34px; height:34px; border-radius:10px; display:flex; align-items:center; justify-content:center; flex-shrink:0; font-size:17px;}
.card-incentivo.positivo .card-incentivo-icon{background:#d6f5e0;}
.card-incentivo.alerta .card-incentivo-icon{background:#f9dada;}
.card-incentivo-titulo{font-size:13px; font-weight:800; margin-bottom:3px;}
.card-incentivo.positivo .card-incentivo-titulo{color:#0d7a3d;}
.card-incentivo.alerta .card-incentivo-titulo{color:#b91c1c;}
.card-incentivo-desc{font-size:12px; color:var(--ink-muted); line-height:1.45;}

.nota-rodape{display:flex; align-items:center; gap:9px; background:#fff; border:1px solid var(--border); border-radius:12px; padding:13px 18px; font-size:12.5px; color:var(--ink-muted); margin-top:4px;}
.nota-rodape svg{width:16px; height:16px; color:var(--purple); flex-shrink:0;}

.pill.status-novo{background:var(--gray-bg); color:var(--gray);}
.pill.status-avaliado_supervisor{background:var(--warn-bg); color:var(--warn);}
.pill.status-ciente_tecnico{background:var(--blue-bg); color:var(--blue);}
.pill.status-revisado_supervisor{background:var(--purple-bg); color:var(--purple);}
.pill.status-encerrado{background:var(--ok-bg); color:var(--ok);}
.texto-atrasado{color:var(--danger); font-weight:700;}

.timeline{display:flex; flex-direction:column; gap:0;}
.timeline-item{display:flex; gap:14px; padding:16px 0; border-bottom:1px solid var(--border);}
.timeline-item:last-child{border-bottom:none;}
.timeline-dot{width:32px; height:32px; border-radius:50%; background:var(--purple-bg); color:var(--purple); display:flex; align-items:center; justify-content:center; flex-shrink:0; font-weight:800; font-size:12px;}
.timeline-head{display:flex; justify-content:space-between; align-items:baseline; gap:10px; flex-wrap:wrap;}
.timeline-titulo{font-weight:700; font-size:13.5px;}
.timeline-quando{font-size:11.5px; color:var(--ink-muted);}
.timeline-texto{font-size:13px; color:var(--ink); margin-top:6px; white-space:pre-wrap;}
.timeline-texto .rotulo{font-size:11px; font-weight:800; text-transform:uppercase; color:var(--ink-muted); display:block; margin-bottom:2px;}
.timeline-assinado{display:inline-flex; align-items:center; gap:5px; font-size:11px; font-weight:700; color:var(--ok); margin-top:8px;}
.timeline-assinado svg{width:13px; height:13px;}

.caso-form textarea{width:100%; min-height:90px; padding:10px 12px; border:1px solid var(--border); border-radius:10px; font-family:inherit; font-size:13.5px; resize:vertical;}
.caso-form label{display:block; font-size:12.5px; font-weight:700; color:var(--ink-muted); margin:14px 0 6px;}
.caso-form label:first-child{margin-top:0;}
.caso-check{display:flex; align-items:center; gap:9px; margin-top:16px; padding:12px 14px; background:var(--gray-bg); border-radius:10px; font-size:13px;}
.caso-check input{width:17px; height:17px;}

@media (max-width:900px){ .stat-grid{grid-template-columns:repeat(2,1fr);} }
@media (max-width:520px){ .stat-grid{grid-template-columns:1fr;} }

.page-head-right{display:flex; align-items:center; gap:10px; flex-wrap:wrap;}

/* ---------- cartão de exportação (gerado fora da tela, capturado em imagem) ---------- */
.export-card-wrap{position:fixed; top:-99999px; left:-99999px; z-index:-1; pointer-events:none;}
.export-card{width:760px; background:#ffffff; font-family:'Plus Jakarta Sans',sans-serif; overflow:hidden;}
.export-card-section{margin:0 38px 24px;}
.export-card-section h3{font-size:12px; font-weight:800; text-transform:uppercase; letter-spacing:.3px; color:#6b7280; margin:0 0 12px;}
.export-card-section table.tbl{font-size:11.5px;}
.export-card-section table.tbl th{padding:6px 8px; font-size:9.5px;}
.export-card-section table.tbl td{padding:6px 8px;}
.export-card-vazio{background:#f7f7fb; border-radius:10px; padding:16px; text-align:center; font-size:13px; color:#6b7280;}
.export-card-mais{font-size:11px; color:#9aa0b4; margin-top:6px; text-align:center;}
.export-card-section .dia-grid{grid-template-columns:repeat(8,1fr); gap:6px;}
.export-card-section .dia-cell{padding:5px 3px; border-radius:7px;}
.export-card-section .dia-num{font-size:8.5px; margin-bottom:1px;}
.export-card-section .dia-os{font-size:7.5px;}
.export-card-section .dia-fal{font-size:7px; padding:0 3px; margin-bottom:1px;}
.export-card-section .dia-irr{font-size:9px;}
.export-card-section .dia-irr .seta{font-size:8px;}
.export-card-header{background:linear-gradient(135deg,var(--navy),var(--navy-2)); color:#fff; padding:34px 38px 28px;}
.export-card-brand{display:flex; align-items:center; gap:11px; margin-bottom:22px;}
.export-card-brand-mark{width:38px; height:38px; border-radius:10px; background:linear-gradient(135deg,var(--purple),#5b3fd6); display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.export-card-brand-mark svg{width:21px; height:21px; color:#fff;}
.export-card-brand-nome{font-size:14px; font-weight:800; color:#fff; line-height:1.2;}
.export-card-brand-nome small{display:block; font-size:11px; font-weight:600; color:#a9a4d8;}
.export-card-titulo{font-size:16px; font-weight:700; margin:0; color:#c9c4f0; text-transform:uppercase; letter-spacing:.5px;}
.export-card-sub{font-size:26px; font-weight:800; color:#ffffff; margin-top:6px; letter-spacing:.2px;}
.export-card-body{padding:32px 38px 8px;}
.export-card-stats{display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:8px;}
.export-card-stats.cols-4{grid-template-columns:1fr 1fr;}
.export-card-stat{border-radius:14px; padding:18px 20px; background:#f7f7fb; border-left:4px solid var(--accent,var(--purple));}
.export-card-stat .lbl{font-size:11.5px; font-weight:800; color:#6b7280; text-transform:uppercase; letter-spacing:.3px;}
.export-card-stat .val{font-size:28px; font-weight:800; margin-top:5px; color:var(--accent-txt,var(--ink));}
.export-card-stat .sub{font-size:11.5px; color:#9aa0b4; margin-top:2px;}
.export-card-ribbon{margin:6px 38px 26px; border-radius:12px; padding:13px 18px; font-size:13.5px; font-weight:700; text-align:center;}
.export-card-ribbon.ok{background:var(--ok-bg); color:var(--ok);}
.export-card-ribbon.alerta{background:var(--danger-bg); color:var(--danger);}
.export-card-footer{padding:16px 38px 24px; display:flex; justify-content:space-between; align-items:center; border-top:1px solid #eee; font-size:11px; color:#9aa0b4;}
