@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');
:root {
  --bg: #0f1117; --panel: #171a23; --border: #262a36; --text: #e6e8ee;
  --muted: #8a90a2; --accent: #4f7cff; --accent-hover: #3c66e0; --ok: #34d399;
  --pos: #7ee0a5; --neg: #ff8f8f;
  --critica: #ff5c5c; --alta: #ff8f4f; --media: #ffcf5c; --baixa: #7ee0a5;
  --urg: #ff8f4f;
  --sans: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: var(--sans);
  background: var(--bg); color: var(--text); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Dados (valores, IDs, datas, prazos) em mono tabular — leitura de operador */
.mono, .pill, .num, .tag.val, .tag.countdown, .stat .v, .data, .cd {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Nav */
.nav {
  display: flex; align-items: center; gap: 4px; padding: 10px 20px;
  border-bottom: 1px solid var(--border); background: #12141c; flex-wrap: wrap;
}
.nav .brand { font-weight: 700; font-size: 15px; margin-right: 12px; color: var(--text); }
.nav a.item {
  padding: 6px 12px; border-radius: 8px; color: var(--muted); font-size: 14px; font-weight: 500;
}
.nav a.item:hover { background: #0c0e14; color: var(--text); text-decoration: none; }
.nav a.item.on { color: var(--text); background: #0c0e14; }
.nav a.item.voltar { font-size: 17px; font-weight: 800; padding: 5px 11px; color: var(--text); }
.nav a.item.voltar:hover { background: #0c0e14; }
.nav { position: relative; }
.nav-items { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.hamburger { display: none; background: transparent; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 5px 11px; font-size: 16px; cursor: pointer; }
.nav .spacer { flex: 1; }

/* Status dos serviços: luz verde/vermelha por serviço, sempre no header. */
.status { display: flex; align-items: center; gap: 10px; margin-right: 6px; }
.status .st {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); white-space: nowrap;
  cursor: pointer; padding: 4px 6px; border-radius: 7px;
  border: 1px solid transparent; background: none;
}
.status .st:hover { background: #0c0e14; border-color: var(--border); }
.status .st:active { transform: translateY(1px); }
.status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); flex: none;
  box-shadow: 0 0 0 3px transparent; transition: background .2s, box-shadow .2s;
}
.status .st.ok  .dot { background: var(--ok);  box-shadow: 0 0 0 3px rgba(52, 211, 153, .16); }
.status .st.off .dot { background: var(--critica); box-shadow: 0 0 0 3px rgba(255, 92, 92, .18); }
.status .st.alerta .dot { background: var(--media); box-shadow: 0 0 0 3px rgba(255, 207, 92, .18); }
.status .st.ok  .rot { color: var(--pos); }
.status .st.off .rot { color: var(--neg); font-weight: 600; }
.status .st.alerta .rot { color: var(--media); font-weight: 600; }
/* Enquanto a primeira medição não volta, a luz pisca em cinza. */
.status .st.medindo .dot { animation: statusPulse 1s ease-in-out infinite; }
@keyframes statusPulse { 50% { opacity: .25; } }
.bell { position: relative; font-size: 18px; padding: 6px 10px; text-decoration: none; }
.bell .badge {
  position: absolute; top: -2px; right: -2px; background: var(--neg); color: #2a0d0d;
  font-size: 10px; font-weight: 800; border-radius: 20px; padding: 1px 5px; min-width: 16px; text-align: center;
}
.notif-wrap { position: relative; }
.notif-drop { position: absolute; right: 0; top: 40px; width: 340px; max-height: 420px; overflow: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 6px; z-index: 60;
  display: none; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.notif-drop.show { display: block; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; }
.notif-head b { font-size: 13px; }
.notif-item { display: block; padding: 9px 10px; border-radius: 8px; font-size: 13px; color: var(--text);
  border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: #0c0e14; text-decoration: none; }
.notif-item.nao-lida { border-left: 3px solid var(--accent); }
.notif-item .d { font-size: 11px; color: var(--muted); margin-top: 3px; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 20px 24px 60px; }
h1 { font-size: 20px; margin: 6px 0 2px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

/* Cards */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px;
}
.card .titulo { font-size: 15px; font-weight: 600; color: var(--text); }
.card .desc { color: var(--muted); font-size: 13px; margin-top: 6px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  font-size: 12px; padding: 2px 9px; border-radius: 20px; background: #0c0e14; border: 1px solid var(--border);
}
.tag.val { color: var(--pos); }
.tag.uf { color: var(--accent); }
.tag.open { color: var(--ok); border-color: #245a45; }
.tag.pub.quente { color: #ff8f8f; border-color: #6b2a2a; background: #241012; font-weight: 700; }
.tag.pub.morna  { color: #ffcf8f; border-color: #6b4a1f; background: #241a0c; font-weight: 700; }
.tag.cat { color: #c4b5fd; border-color: #4c3f8a; background: #1a1730; font-weight: 600; }
/* Modalidade Pregão Eletrônico (nº 1) e regime de Registro de Preço (ARP). */
.tag.mod-pe { color: var(--pos); border-color: rgba(52,211,153,.4); background: rgba(52,211,153,.14); font-weight: 700; }
.tag.srp { color: #c9adff; border-color: rgba(180,130,255,.4); background: rgba(180,130,255,.14); }

/* Textarea com destaque: um espelho atrás do campo pinta as linhas marcadas.
   Espelho e textarea precisam do MESMO box (fonte, padding, borda, quebra),
   senão o destaque desalinha do texto. */
.ta-hl { position: relative; background: #0c0e14; border-radius: 8px; }
.ta-hl > .ta-mirror, .ta-hl > textarea {
  box-sizing: border-box; width: 100%; margin: 0;
  font-family: inherit; font-size: 14px; line-height: 1.5;
  padding: 10px 12px; border: 1px solid transparent; border-radius: 8px;
  white-space: pre-wrap; overflow-wrap: break-word;
}
.ta-hl > .ta-mirror {
  position: absolute; inset: 0; overflow: hidden;
  color: transparent; pointer-events: none; user-select: none;
}
.ta-hl > textarea { position: relative; background: transparent; border-color: var(--border); }
.ta-hl > textarea:focus { border-color: var(--accent); }
.ta-mirror mark { color: transparent; background: #6b3a08; border-radius: 3px; }
.ta-mirror mark.alto { background: #8a4406; }
.ruido-item { font-size: 12px; color: var(--muted); padding: 3px 0; }
.ruido-item b { color: #f5a04a; }
.lido-lbl { display: none; color: var(--ok); font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.chk-lida:checked + .lido-lbl { display: inline; }
.pill { display: inline-block; font-size: 13px; font-weight: 800; padding: 3px 11px; border-radius: 20px; }
.pill.verde { background: #123a2a; color: var(--pos); border: 1px solid #245a45; }

/* SRP: a exigência é DESTACAR quando NÃO for ata de registro de preço — é o
   caso que muda a decisão (compra única, sem carona depois). "Não informado"
   fica apagado de propósito: não pode ser confundido com "não é". */
.tag.srp-sim { color: var(--pos); border-color: #245a45; background: #101c17; }
.tag.srp-nao { color: #ffcf8f; border-color: #6b4a1f; background: #241a0c; font-weight: 700; }
.tag.srp-off { color: var(--muted); border-color: var(--border); font-style: italic; }

/* Faixas de valor: escala de tamanho, não julgamento. Cinza (sem valor) -> azul
   (pequeno/médio) -> verde (alvo, a partir de R$ 3 mi) -> dourado (grande). */
.tag.val { font-weight: 600; }
.tag.val.semvalor { color: var(--muted); border-color: var(--border); font-weight: 400; font-style: italic; }
.tag.val.f1 { color: #93a4c8; border-color: #2f3850; background: #10141f; }
.tag.val.f2 { color: #8fb0ff; border-color: #2c3a63; background: #101527; }
.tag.val.f3 { color: var(--pos); border-color: #245a45; background: #101c17; }
.tag.val.f4 { color: #ffcf8f; border-color: #6b4a1f; background: #241a0c; font-weight: 700; }
.pill.amarelo { background: #3a3414; color: var(--media); border: 1px solid #5a5024; }
.countdown { font-weight: 700; }
.countdown.urg { color: var(--urg); }
.countdown.ok { color: var(--ok); }

.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
button, .btn {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
button.ghost, .btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
button.ghost:hover, .btn.ghost:hover { background: #0c0e14; color: var(--text); }
button.danger { background: transparent; border: 1px solid #6b2b2b; color: var(--neg); }
button.danger:hover { background: #241010; }

label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; }
input[type=text], input[type=number], textarea {
  width: 100%; background: #0c0e14; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 10px 12px; font-size: 14px; font-family: inherit; resize: vertical;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
#status { font-size: 13px; color: var(--muted); min-height: 18px; margin: 10px 0; }
#status.ok { color: var(--ok); } #status.err { color: #ff6b6b; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }

/* Toasts */
.toast-wrap { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { white-space: pre-line; background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 10px 14px; font-size: 13px; color: var(--text); box-shadow: 0 8px 24px rgba(0,0,0,.45);
  animation: toastin .2s ease; max-width: 340px; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--neg); }
.toast.out { animation: toastout .2s ease forwards; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastout { to { opacity: 0; transform: translateX(24px); } }

/* Skeletons */
.skel { background: linear-gradient(90deg, #171a23 25%, #212734 50%, #171a23 75%); background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear; border-radius: 6px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skel-card { height: 116px; margin-bottom: 12px; }
.skel-row { height: 40px; margin-bottom: 6px; }

/* Mobile */
@media (max-width: 680px) {
  .nav { padding: 8px 12px; gap: 6px; }
  .nav .brand { font-size: 14px; margin-right: 2px; }
  .nav .bell { padding: 6px 8px; }
  .status { gap: 7px; margin-right: 2px; }
  .status .st .rot { display: none; }
  .hamburger { display: inline-block; }
  .nav-items { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column;
    align-items: stretch; gap: 2px; background: #12141c; border-bottom: 1px solid var(--border);
    padding: 8px; z-index: 55; box-shadow: 0 10px 24px rgba(0,0,0,.5); }
  .nav-items.open { display: flex; }
  .nav-items a.item { padding: 11px 12px; font-size: 14px; }
  .wrap { padding: 16px 14px 50px !important; max-width: none !important; }
  .toast-wrap { left: 12px; right: 12px; }
  .toast { max-width: none; }
  .kbdhint { display: none; }
  .empgrid { grid-template-columns: 1fr !important; }
  .tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.tbl { font-size: 12px; }
  table.tbl td.obj { max-width: 180px; }
  .overlay { padding: 12px 10px; }
  .ficha { max-height: calc(100vh - 24px); border-radius: 12px; }
  .ficha .fh { padding: 14px 16px 12px; } .ficha h2 { font-size: 16px; }
  .ficha .fbody { padding: 14px 16px 18px; }
  .ficha .metas { grid-template-columns: 1fr; gap: 12px; }
  .addt { grid-template-columns: 1fr; }
  button, .btn { min-height: 38px; }
}

/* Ficha (modal compartilhada) ------------------------------------------
   A ficha é a tela mais densa do sistema: título longo, sete metadados,
   três eixos de fit, abas. Em coluna estreita tudo quebra em duas linhas e
   vira sopa. Por isso: caixa larga, rótulo em cima do valor (nunca
   "Rótulo: valor" numa linha só, que é o que quebrava) e cabeçalho fixo com
   o corpo rolando por dentro. */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; z-index: 50;
  align-items: flex-start; justify-content: center; padding: 32px 16px; overflow: auto;
  backdrop-filter: blur(2px); }
.overlay.show { display: flex; }
.ficha { width: 100%; max-width: 880px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,.6);
  display: flex; flex-direction: column; max-height: calc(100vh - 64px); overflow: hidden; }
.ficha .fh { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 20px 26px 14px; border-bottom: 1px solid var(--border); background: var(--panel); }
.ficha h2 { margin: 6px 0 0; font-size: 19px; line-height: 1.35; letter-spacing: -.2px; }
.ficha .idnum { font-size: 12px; color: var(--muted); }
.ficha .x { background: transparent; border: none; color: var(--muted); font-size: 22px; cursor: pointer;
  line-height: 1; padding: 4px 8px; border-radius: 8px; flex: none; }
.ficha .x:hover { background: #21252f; color: var(--text); }
.ficha .fbody { padding: 18px 26px 22px; overflow: auto; }

/* Metadados: rótulo em cima, valor embaixo. Colunas se ajustam sozinhas —
   nunca espremem um valor longo a ponto de quebrar. */
.ficha .metas { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px 24px; margin: 0 0 18px; }
.ficha .kv { font-size: 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ficha .kv b { color: var(--muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px; }
.ficha .kv .val { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; line-height: 1.4; }
.ficha .kv .tag { white-space: nowrap; }
.ficha .wide { grid-column: 1 / -1; }

/* Score de Fit: bloco próprio, uma linha por eixo, nota à esquerda. */
.ficha .fitbox { border: 1px solid var(--border); border-radius: 12px; background: #0c0e14;
  padding: 14px 16px; margin-bottom: 18px; }
.ficha .fitbox .cap { font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .5px; margin-bottom: 10px; }
.ficha .fitrow { display: flex; gap: 10px; align-items: baseline; font-size: 14px; padding: 5px 0; }
.ficha .fitrow + .fitrow { border-top: 1px solid #171a23; }
.ficha .fitrow .fit { min-width: 46px; text-align: center; font-size: 12px; padding: 5px 7px; }
.ficha .fitrow .txt { min-width: 0; line-height: 1.45; }
.ficha .fitrow .txt b { color: var(--muted); font-weight: 600; }

.ficha .acts { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button { background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--muted);
  border-radius: 0; padding: 8px 12px; font-weight: 600; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.pane { display: none; } .pane.on { display: block; }
.coment { background: #0c0e14; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.coment .t { font-size: 13px; white-space: pre-wrap; } .coment .d { font-size: 11px; color: var(--muted); margin-top: 4px; }
.addc { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.addc textarea { flex: 1; }
.tarefa { display: flex; align-items: flex-start; gap: 10px; background: #0c0e14; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.tarefa input[type=checkbox] { margin-top: 3px; width: 16px; height: 16px; }
.tarefa .td { flex: 1; font-size: 13px; }
.tarefa.done .td { text-decoration: line-through; color: var(--muted); }
.tarefa .due { font-size: 11px; color: var(--alta); margin-top: 3px; }
.tarefa .del { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 14px; }
.addt { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 10px; align-items: center; }
.addt input[type=datetime-local] { color-scheme: dark; }

/* --- Score de Fit (feed, busca e ficha) ---
   Três eixos independentes, sem nota composta. A banda `na` cobre tanto score
   ausente (—) quanto score incerto: falta de evidência não é nota ruim, então
   nunca pinta de vermelho. */
.fits { display:inline-flex; gap:4px; align-items:center; flex-wrap:wrap; }
.fit { font-family:var(--mono); font-size:11px; font-weight:700; line-height:1;
  padding:4px 7px; border-radius:6px; border:1px solid transparent; white-space:nowrap; cursor:help; }
.fit .rot { font-weight:500; opacity:.75; margin-right:3px; text-transform:uppercase; letter-spacing:.3px; }
.fit.alto  { background:rgba(34,197,94,.14); border-color:rgba(34,197,94,.45); color:#4ade80; }
.fit.medio { background:rgba(234,179,8,.14); border-color:rgba(234,179,8,.45); color:#facc15; }
.fit.baixo { background:rgba(239,68,68,.12); border-color:rgba(239,68,68,.40); color:#f87171; }
.fit.na    { background:transparent; border-color:var(--border); color:var(--muted); }
table.tbl td .fit { font-size:10px; padding:3px 6px; }

/* --- Tooltip em CSS (data-tip) -------------------------------------------
   Substitui o `title=` nativo: o do navegador demora ~1s, não quebra linha
   onde a gente quer, some sozinho e não aceita estilo. Como o software é novo
   para quem opera, a legenda precisa ser longa e legível — então: fundo preto,
   letra branca, várias linhas.

   Uso: <span class="tag" data-tip="Título&#10;Explicação longa">…</span>
   O `&#10;` vira quebra de linha de verdade (white-space: pre-line).
   `data-tip-pos="baixo"` joga o balão para baixo — para o que fica colado no
   topo da tela (cabeçalho de tabela, primeira linha). */
[data-tip] { position: relative; cursor: help; }
[data-tip]::after, [data-tip]::before {
  position: absolute; z-index: 90; opacity: 0; visibility: hidden;
  pointer-events: none;
  transition: opacity .12s ease .3s, visibility 0s linear .42s;
}
[data-tip]::after {
  content: attr(data-tip);
  bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%);
  background: #000; color: #fff; border: 1px solid #3a4152; border-radius: 8px;
  padding: 9px 11px;
  font-family: var(--sans); font-size: 12px; font-weight: 400; line-height: 1.5;
  letter-spacing: normal; text-transform: none; text-align: left;
  white-space: pre-line; width: max-content; max-width: min(360px, 78vw);
  box-shadow: 0 10px 28px rgba(0,0,0,.7);
}
[data-tip]::before {
  content: ''; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #000;
}
[data-tip]:hover::after, [data-tip]:hover::before,
[data-tip]:focus-visible::after, [data-tip]:focus-visible::before {
  opacity: 1; visibility: visible;
  transition: opacity .12s ease .3s, visibility 0s linear .3s;
}
/* Balão para baixo: mesma caixa, ancoragem invertida. */
[data-tip][data-tip-pos="baixo"]::after { bottom: auto; top: calc(100% + 9px); }
[data-tip][data-tip-pos="baixo"]::before {
  bottom: auto; top: calc(100% + 3px);
  border-top-color: transparent; border-bottom-color: #000;
}
/* Perto da borda direita o balão centralizado sairia da tela: alinha pela
   direita do próprio elemento. */
[data-tip][data-tip-pos="esq"]::after { left: auto; right: 0; transform: none; }
[data-tip][data-tip-pos="esq"]::before { left: auto; right: 12px; transform: none; }
/* Toque não tem hover: o balão nunca some. Some o balão, fica o texto do card. */
@media (hover: none) { [data-tip]::after, [data-tip]::before { display: none; } }
