/* Camada visual do Jurídico (identidade Barbieri): carregada DEPOIS de ti.css, juridico.css e uniforme.css.
   Só usa os tokens da marca (vermelho #ac2c23, grafite #222d31, Poppins, vidro) e acrescenta hierarquia, profundidade e movimento.
   Não muda nenhum comportamento: se esta folha sair do ar, as telas voltam ao visual anterior sem perder função.
   Respeita "reduzir movimento" do sistema e o tema escuro (usa só tokens e transparências). */

:root {
  --jv-sombra-1: 0 1px 2px rgba(20, 26, 31, .05), 0 6px 18px -10px rgba(20, 26, 31, .14);
  --jv-sombra-2: 0 2px 4px rgba(20, 26, 31, .06), 0 16px 34px -14px rgba(20, 26, 31, .22);
  --jv-vermelho-suave: rgba(172, 44, 35, .08);
  --jv-vermelho-linha: rgba(172, 44, 35, .22);
  --jv-ease: cubic-bezier(.22, .8, .24, 1);
}

/* ── Fundo com ambiência discreta ── */
body {
  background:
    radial-gradient(900px 480px at 100% -8%, var(--jv-vermelho-suave), transparent 62%),
    radial-gradient(760px 420px at -6% 108%, rgba(34, 45, 49, .07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
.ti-content { scroll-behavior: smooth; }

/* ── Entrada suave das telas ── */
@keyframes jv-sobe { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes jv-entra { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }
.ti-view.active > .ti-content > * { animation: jv-sobe .38s var(--jv-ease) both; }
.ti-view.active > .ti-content > *:nth-child(2) { animation-delay: .05s; }
.ti-view.active > .ti-content > *:nth-child(3) { animation-delay: .1s; }
.ti-view.active > .ti-content > *:nth-child(n+4) { animation-delay: .14s; }

/* ── Menu lateral: item ativo com barra vermelha e brilho ── */
.ti-nav-item { position: relative; transition: background .18s, color .18s, transform .18s var(--jv-ease); }
.ti-nav-item:hover:not(.active) { background: rgba(255, 255, 255, .07); color: #fff; transform: translateX(2px); }
.ti-nav-item.active {
  background: linear-gradient(90deg, rgba(210, 68, 56, .34), rgba(210, 68, 56, .08));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
  color: #fff;
}
.ti-nav-item.active::before {
  background: var(--brand-red-light);
  border-radius: 0 3px 3px 0;
  bottom: 22%;
  box-shadow: 0 0 12px rgba(210, 68, 56, .85);
  content: '';
  left: -.75rem;
  position: absolute;
  top: 22%;
  width: 4px;
}
.ti-nav-section { letter-spacing: .12em; }

/* ── Cabeçalho da tela ── */
.ti-topbar { padding: 1rem 1.75rem; }
.ti-topbar .eyebrow { align-items: center; color: var(--brand-red); display: flex; gap: .45rem; letter-spacing: .12em; }
.ti-topbar .eyebrow::before { background: var(--brand-red); border-radius: 2px; content: ''; height: 2px; width: 16px; }
.ti-topbar h1 { font-size: 1.2rem; letter-spacing: -.01em; line-height: 1.2; }
.ti-content { padding: 1.5rem 1.75rem 2.5rem; }

/* ── Cartões ── */
.jr-card {
  border: 1px solid rgba(20, 26, 31, .05);
  box-shadow: var(--jv-sombra-1);
  transition: box-shadow .25s var(--jv-ease), border-color .25s;
}
.jr-card:hover { border-color: rgba(20, 26, 31, .09); box-shadow: var(--jv-sombra-2); }
.jr-card > h2, .jr-card-topo h2 {
  align-items: center; display: flex; font-size: 14px; font-weight: 700; gap: .55rem; letter-spacing: -.005em;
}
.jr-card > h2::before, .jr-card-topo h2::before {
  background: linear-gradient(180deg, var(--brand-red-light), var(--brand-red));
  border-radius: 3px; content: ''; flex: none; height: 15px; width: 4px;
}
.jr-card h2 small { color: var(--muted); font-weight: 500; }
.jr-nota { line-height: 1.55; }
.jr-erro, .jr-aviso { border-radius: 14px; padding: .8rem 1rem; }

/* ── Indicadores ── */
.metric-card { overflow: hidden; position: relative; animation: jv-entra .45s var(--jv-ease) both; }
.metric-card::before {
  background: linear-gradient(90deg, var(--brand-red), var(--brand-red-light));
  content: ''; height: 3px; left: 0; opacity: .85; position: absolute; right: 0; top: 0; transform-origin: left; transform: scaleX(.28);
  transition: transform .5s var(--jv-ease);
}
.metric-card:hover::before { transform: scaleX(1); }
.metric-card.blue::before { background: linear-gradient(90deg, #1d6fb8, #4a9be0); }
.metric-card.green::before { background: linear-gradient(90deg, #12805c, #34b48a); }
.metric-card.orange::before { background: linear-gradient(90deg, #b45309, #e08a2c); }
.metric-card-value { font-size: clamp(1.5rem, 2.6vw, 2.1rem); letter-spacing: -.02em; }
.metric-grid > .metric-card:nth-child(2) { animation-delay: .04s; }
.metric-grid > .metric-card:nth-child(3) { animation-delay: .08s; }
.metric-grid > .metric-card:nth-child(4) { animation-delay: .12s; }
.metric-grid > .metric-card:nth-child(n+5) { animation-delay: .16s; }

/* ── Botões ── */
.btn { transition: background .18s, box-shadow .18s, transform .18s var(--jv-ease), opacity .15s; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.985); }
.btn:focus-visible { box-shadow: var(--u-foco); outline: none; }
.btn-primary { background: linear-gradient(180deg, var(--brand-red-light) -40%, var(--brand-red) 55%); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, var(--brand-red) -30%, var(--brand-red-dark) 70%); }
.btn-secondary { background: var(--surface); box-shadow: 0 1px 2px rgba(20, 26, 31, .05); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-soft); border-color: var(--line-strong); }

/* ── Abas e grupos ── */
.jr-abas, .jr-subabas { gap: .45rem; }
.jr-aba {
  background: var(--surface); border-color: var(--line); box-shadow: 0 1px 2px rgba(20, 26, 31, .04); font-weight: 500;
  transition: background .18s, color .18s, border-color .18s, transform .18s var(--jv-ease), box-shadow .18s;
}
.jr-aba:hover:not(.active) { border-color: var(--jv-vermelho-linha); color: var(--brand-red); transform: translateY(-1px); }
.jr-aba.active {
  background: linear-gradient(180deg, var(--brand-red-light) -40%, var(--brand-red) 55%); border-color: var(--brand-red);
  box-shadow: 0 8px 18px -8px rgba(172, 44, 35, .6); color: #fff; font-weight: 600;
}

/* ── Etiquetas: ponto de cor antes do texto ── */
.jr-sit, .jr-chip { font-weight: 600; letter-spacing: .01em; padding: .16rem .65rem; }
.jr-sit.ok::before, .jr-sit.off::before, .jr-sit.erro::before {
  background: currentColor; border-radius: 50%; content: ''; display: inline-block; height: 6px; margin-right: .4rem; opacity: .75; vertical-align: 1px; width: 6px;
}

/* ── Tabelas ── */
.ti-table { border-collapse: separate; border-spacing: 0; }
.ti-table th { background: var(--surface-soft); border-bottom: 1px solid var(--line-strong); color: var(--muted); font-size: 10.5px; letter-spacing: .08em; white-space: nowrap; }
.ti-table tbody tr td { transition: background .15s; }
.ti-table tbody tr:nth-child(even) td { background: rgba(20, 26, 31, .018); }
.ti-table tbody tr:hover td { background: var(--jv-vermelho-suave); }
.ti-table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--brand-red); }
.jr-tabela td, .jr-tabela th { vertical-align: top; }
.jr-tabela-rolagem { background: var(--surface); box-shadow: var(--jv-sombra-1); }
body .sv-rolagem thead th { background: var(--surface-soft); }
body .sv-rolagem { scrollbar-color: var(--brand-red) var(--surface-sunken); }
body .sv-rolagem::-webkit-scrollbar-track { background: var(--surface-sunken); }
body .sv-rolagem::-webkit-scrollbar-thumb { background: var(--brand-red); border-color: var(--surface-sunken); }
.jr-clicavel { cursor: pointer; }
.empty-state { padding: 2.5rem 1rem; }

/* ── Barras de percentual: preenchem ao aparecer ── */
@keyframes jv-enche { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.jg-barra { background: var(--surface-sunken); height: 8px; overflow: hidden; }
.jg-barra > span { animation: jv-enche .8s var(--jv-ease) both; background: linear-gradient(90deg, #3a484d, var(--brand-blue)); transform-origin: left; }
.jg-barra.acordo > span { background: linear-gradient(90deg, #e08a2c, var(--warning)); }
.jg-barra.cliente > span { background: linear-gradient(90deg, #34b48a, var(--success)); }

/* ── Campos e filtros ── */
.fl, .ms-filtros { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6); }
input:focus, select:focus, textarea:focus { border-color: var(--brand-red) !important; box-shadow: var(--u-foco) !important; }
.sv-barra .btn, .jr-campos .btn { align-self: flex-end; }

/* ── Seções recolhíveis ── */
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details.sv-mais > summary, details.sv-ajuda > summary { align-items: center; display: flex; gap: .5rem; }
details.sv-mais > summary::before, details.sv-ajuda > summary::before {
  border-bottom: 2px solid var(--muted); border-right: 2px solid var(--muted); content: ''; height: 7px; margin: 0 .2rem 2px .1rem; transform: rotate(-45deg); transition: transform .2s var(--jv-ease); width: 7px;
}
details.sv-mais[open] > summary::before, details.sv-ajuda[open] > summary::before { transform: rotate(45deg); }
details.sv-ajuda { margin: .25rem 0 .5rem; }
details.sv-ajuda > summary { color: var(--muted); font-size: 12.5px; font-weight: 600; }
details.sv-ajuda[open] > summary { color: var(--brand-red); }
details.sv-ajuda > p { animation: jv-sobe .25s var(--jv-ease) both; }

/* ── Aviso rápido (toast) ── */
.jr-toast { animation: jv-sobe .3s var(--jv-ease) both; backdrop-filter: blur(10px); border-radius: 14px; box-shadow: var(--jv-sombra-2); }

/* ── Carregando: pulsação suave ── */
@keyframes jv-pulsa { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.empty-state .spinner + p { animation: jv-pulsa 1.4s ease-in-out infinite; }

/* ── Rolagem fina ── */
.ti-content::-webkit-scrollbar, .ti-sidebar::-webkit-scrollbar { width: 10px; }
.ti-content::-webkit-scrollbar-thumb { background: rgba(20, 26, 31, .18); border: 3px solid transparent; border-radius: 8px; background-clip: padding-box; }
.ti-content::-webkit-scrollbar-thumb:hover { background: rgba(172, 44, 35, .5); background-clip: padding-box; }
.ti-sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 8px; }

/* ── Painel Ações dos servidores ── */
.as-frases { display: grid; gap: .6rem; list-style: none; margin: 0; padding: 0; }
.as-frases li {
  background: linear-gradient(90deg, var(--jv-vermelho-suave), transparent 70%); border-left: 3px solid var(--brand-red); border-radius: 0 12px 12px 0; font-size: 13.5px; line-height: 1.5; padding: .6rem .9rem;
}

/* ── Tela estreita ── */
@media (max-width: 800px) {
  .ti-topbar { padding: .85rem 1rem; }
  .ti-content { padding: 1rem 1rem 2rem; }
}

/* ── Quem prefere menos movimento ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
.jr-tabela td:first-child { min-width: 9rem; }

/* ══ Tabela de Servidores: colunas de ação com arrastar e soltar ══ */
.sv-tipos { align-items: center; display: flex; flex-wrap: wrap; gap: .4rem; margin: .25rem 0 .75rem; }
.sv-tipos-rot { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; margin-right: .3rem; text-transform: uppercase; }
.sv-tipo {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 999px; color: var(--text); cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 500; padding: .32rem .85rem;
  transition: background .18s, border-color .18s, color .18s, transform .18s var(--jv-ease), box-shadow .18s;
}
.sv-tipo:hover:not(.ativo) { border-color: var(--jv-vermelho-linha); color: var(--brand-red); transform: translateY(-1px); }
.sv-tipo.ativo { background: linear-gradient(180deg, var(--brand-red-light) -40%, var(--brand-red) 55%); border-color: var(--brand-red); box-shadow: 0 8px 18px -8px rgba(172, 44, 35, .6); color: #fff; font-weight: 600; }
.sv-dica-arrastar { margin: 0 0 .6rem; }

.sv-tab-acoes th.sv-th-piso { box-shadow: inset 0 -3px 0 #ac2c23; }
.sv-tab-acoes th.sv-th-hora { box-shadow: inset 0 -3px 0 #1d6fb8; }
.sv-tab-acoes th.sv-th-dificil { box-shadow: inset 0 -3px 0 #12805c; }
.sv-tab-acoes th.sv-th-outras { box-shadow: inset 0 -3px 0 #8a949b; }
.sv-tab-acoes td.sv-zona { min-width: 15rem; padding: .5rem; transition: background .15s, box-shadow .15s; vertical-align: top; }
.sv-tab-acoes td.sv-zona .sv-vazio { color: var(--faint); padding: .25rem .4rem; }
.sv-tab-acoes tbody tr:hover td.sv-zona { background: transparent; box-shadow: none; }
body.sv-arrastando .sv-tab-acoes td.sv-zona { background: var(--surface-soft); box-shadow: inset 0 0 0 1.5px dashed var(--line-strong); outline: 1.5px dashed var(--line-strong); outline-offset: -4px; }
body.sv-arrastando .sv-tab-acoes td.sv-zona.alvo { background: var(--jv-vermelho-suave); outline: 2px dashed var(--brand-red); }

.sv-proc {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--line-strong); border-radius: 12px; box-shadow: 0 1px 2px rgba(20, 26, 31, .05); cursor: grab; display: grid; gap: .2rem;
  margin-bottom: .45rem; padding: .45rem .6rem; text-align: left; transition: box-shadow .18s, transform .18s var(--jv-ease), border-color .18s, opacity .18s; white-space: normal;
}
.sv-proc:hover { box-shadow: var(--jv-sombra-1); transform: translateY(-1px); }
.sv-proc:active { cursor: grabbing; }
.sv-proc.arrastando { opacity: .4; transform: scale(.97); }
.sv-zona-piso .sv-proc { border-left-color: #ac2c23; }
.sv-zona-hora .sv-proc { border-left-color: #1d6fb8; }
.sv-zona-dificil .sv-proc { border-left-color: #12805c; }
.sv-proc.manual { background: linear-gradient(90deg, var(--jv-vermelho-suave), var(--surface) 60%); }
.sv-proc-topo { align-items: center; display: flex; gap: .4rem; justify-content: space-between; }
.sv-proc-num { font-size: 12.5px; font-variant-numeric: tabular-nums; font-weight: 600; }
.sv-proc-man { color: var(--brand-red); font-size: 11px; font-weight: 600; }
.sv-proc small { display: block; line-height: 1.35; }
.sv-mv { background: transparent; border: 0; border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 17px; line-height: 1; padding: .1rem .45rem; transition: background .15s, color .15s; }
.sv-mv:hover { background: var(--surface-soft); color: var(--brand-red); }
.sv-ign { background: transparent; border: 1px dashed var(--line-strong); border-radius: 999px; color: var(--muted); cursor: pointer; font: inherit; font-size: 11px; margin-top: .2rem; padding: .15rem .6rem; }
.sv-ign:hover { border-color: var(--brand-red); color: var(--brand-red); }

.sv-menu {
  animation: jv-entra .14s var(--jv-ease) both; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--jv-sombra-2); display: grid; min-width: 15rem; padding: .35rem; position: fixed; z-index: 9999;
}
.sv-menu button { background: transparent; border: 0; border-radius: 9px; color: var(--text); cursor: pointer; font: inherit; font-size: 13px; padding: .5rem .75rem; text-align: left; transition: background .12s, color .12s; }
.sv-menu button:hover { background: var(--jv-vermelho-suave); color: var(--brand-red); }
.sv-menu button.sv-menu-perigo { color: var(--danger); }

/* ══ Ferramentas de B.I. nos gráficos e tabelas ══ */
.jr-card[data-bi-tb] { position: relative; }
.bi-tb {
  align-items: center; display: flex; flex-wrap: wrap; gap: .35rem; justify-content: flex-end; margin: -.2rem 0 .5rem auto;
  max-width: 100%;
}
.bi-bt, .bi-sel {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; color: var(--text); cursor: pointer; font: inherit; font-size: 11.5px; font-weight: 600; padding: .28rem .7rem;
  transition: background .15s, border-color .15s, color .15s, transform .15s var(--jv-ease);
}
.bi-sel { padding: .26rem .55rem; }
.bi-bt:hover, .bi-sel:hover { border-color: var(--brand-red); color: var(--brand-red); transform: translateY(-1px); }
.bi-bt-baixar { background: linear-gradient(180deg, var(--brand-red-light) -40%, var(--brand-red) 55%); border-color: var(--brand-red); color: #fff; }
.bi-bt-baixar:hover { color: #fff; filter: brightness(1.06); }
.bi-menu { position: relative; }
.bi-menu-lista {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--jv-sombra-2); display: none; min-width: 12.5rem; padding: .3rem; position: absolute; right: 0; top: calc(100% + 4px); z-index: 60;
}
.bi-menu.aberto .bi-menu-lista { animation: jv-entra .14s var(--jv-ease) both; display: grid; }
.bi-menu-lista button { background: transparent; border: 0; border-radius: 9px; color: var(--text); cursor: pointer; font: inherit; font-size: 12.5px; padding: .45rem .7rem; text-align: left; }
.bi-menu-lista button:hover { background: var(--jv-vermelho-suave); color: var(--brand-red); }
.bi-tela-acoes { display: flex; flex-wrap: wrap; gap: .4rem; margin-left: auto; }
.ti-topbar-actions > .bi-tela-acoes { margin-left: 0; }
.bi-menu-tela { min-width: 14rem; }
.bi-menu-grupo { color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: .06em; padding: .5rem .7rem .2rem; text-transform: uppercase; }
.bi-menu-grupo:not(:first-child) { border-top: 1px solid var(--line); margin-top: .25rem; }
/* Filtro por clique nas roscas */
.bi-fatia, .bi-leg-item { cursor: pointer; }
.bi-leg-item { border-radius: 8px; padding: .12rem .4rem; margin: -.12rem -.4rem; transition: background .15s, opacity .15s; }
.bi-leg-item:hover { background: var(--jv-vermelho-suave); }
.bi-leg-item.ativa { background: var(--jv-vermelho-suave); font-weight: 600; }
.bi-leg-item.apagada { opacity: .45; }
.bi-chips { align-items: center; display: flex; flex-wrap: wrap; gap: .45rem; margin: 0 0 .9rem; }
.bi-chip { background: var(--jv-vermelho-suave); border: 1px solid var(--brand-red); border-radius: 999px; color: var(--brand-red); cursor: pointer; font: inherit; font-size: 12px; padding: .25rem .75rem; }
.bi-chip:hover { filter: brightness(.96); }
.bi-modo-tabela > :not(.bi-tb):not(h2):not(h3):not(.bi-tabela-dados):not(.jr-card-topo) { display: none !important; }
.bi-tabela-dados { margin-top: .5rem; }

/* Tela cheia de um bloco */
.jr-card.bi-cheio { background: var(--surface); border-radius: 0; inset: 0; margin: 0; overflow: auto; padding: 1.5rem 2rem; position: fixed; z-index: 9000; }
body.bi-com-cheio { overflow: hidden; }

/* Capturando a tela inteira em PDF: sem animação e sem barras */
body.bi-capturando *, body.bi-capturando *::before, body.bi-capturando *::after { animation: none !important; transition: none !important; }
body.bi-capturando .bi-tb { display: none !important; }

/* Imprimir só o bloco escolhido */
@media print {
  body.bi-imprimindo * { visibility: hidden !important; }
  body.bi-imprimindo .bi-alvo-impressao, body.bi-imprimindo .bi-alvo-impressao * { visibility: visible !important; }
  body.bi-imprimindo .bi-alvo-impressao { box-shadow: none !important; inset: 0 auto auto 0; margin: 0; position: absolute; width: 100%; }
  body.bi-imprimindo .bi-tb { display: none !important; }
}

/* Janela da ficha do cliente: larga, por cima da tela atual */
.jr-modal-cli { max-width: min(1180px, 96vw); }
.jr-modal-cli .jr-card { box-shadow: none; }

/* Painéis personalizados: filtro cruzado por clique */
.pn-clicavel { cursor: pointer; transition: opacity .15s, background .15s; }
.pn-bh-linha.pn-clicavel:hover, .pn-bv-col.pn-clicavel:hover, .pn-legenda li.pn-clicavel:hover, tr.pn-clicavel:hover { background: var(--jv-vermelho-suave); border-radius: 6px; }
circle.pn-clicavel:hover { stroke: var(--brand-red); stroke-width: 1.5; }
.pn-sel { font-weight: 700; }
.pn-bh-linha.pn-sel, .pn-bv-col.pn-sel, .pn-legenda li.pn-sel, tr.pn-sel { background: var(--jv-vermelho-suave); border-radius: 6px; }
.pn-apagado { opacity: .38; }
.pn-w.pn-filtrado { border-color: var(--brand-red); }
