/* ===== v2.63 (nov/2026): ajustes gerais — celular comum, dobráveis e Duo (vertical e horizontal), atividades e impressão ===== */

/* nada passa da largura da tela (sem rolagem lateral desnecessária); tabelas largas rolam só dentro da própria caixa */
html, body { max-width: 100%; }
.wrap { min-width: 0; }
img, video, canvas, iframe { max-width: 100%; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.panel, .proc-form > *, .panel-head > * { min-width: 0; }
.panel-head h2 { overflow-wrap: anywhere; }

/* toque confortável em telas de toque */
@media (pointer: coarse) {
  .btn:not(.sm), .tab, button.link-btn { min-height: 44px; }
  .btn.sm { min-height: 38px; }
  .td-check { min-width: 28px; min-height: 28px; }
  input[type=checkbox], input[type=radio] { min-width: 20px; min-height: 20px; }
}

/* celular: campos empilhados, letra 16px (o iPhone não dá zoom ao tocar), botões do rodapé dos formulários em largura cheia */
@media (max-width: 760px) {
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px !important; }
  .proc-form { grid-template-columns: minmax(0, 1fr) !important; }
  .proc-form .wide, .proc-form .wide-all { grid-column: 1 / -1 !important; }
  .proc-form .form-end { flex-wrap: wrap; }
  .proc-form .form-end .note { flex: 1 1 100%; }
  .proc-form .form-end .btn { flex: 1 1 auto; }
  .panel-head { flex-wrap: wrap; }
  dialog, .proc-dlg, .fin-dlg { max-width: calc(100vw - 16px) !important; max-height: calc(100dvh - 16px) !important; overflow: auto; }
  .tabs { flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; justify-content: flex-start !important; max-width: 100%; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab { flex: 0 0 auto !important; white-space: nowrap; }
}
/* aparelho dobrável aberto, Duo numa tela só deitado, tablet pequeno: duas colunas nos formulários */
@media (min-width: 561px) and (max-width: 900px) {
  .proc-form { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .proc-form .wide-all, .proc-form .form-end { grid-column: 1 / -1 !important; }
  .proc-form .wide { grid-column: span 2 !important; }
}
/* Duo / dupla tela: nada fica escondido embaixo da dobradiça */
@media (horizontal-viewport-segments: 2) {
  .wrap { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .proc-form { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; column-gap: calc(env(viewport-segment-left 1 0, 0px) - env(viewport-segment-right 0 0, 0px) + 16px) !important; }
  .proc-form .wide { grid-column: auto !important; }
  .td-wrap { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; column-gap: calc(env(viewport-segment-left 1 0, 0px) - env(viewport-segment-right 0 0, 0px) + 16px) !important; }
}
@media (vertical-viewport-segments: 2) {
  dialog, .proc-dlg, .fin-dlg { max-height: calc(env(viewport-segment-height 0 0, 50dvh) - 16px) !important; }
}

/* ===== Atividades ===== */
.td-por { color: var(--muted, #77706a); }
.td-aud { position: fixed; inset: 0; z-index: 99999; background: rgba(20, 16, 14, .55); display: flex; align-items: center; justify-content: center; padding: 12px; }
.td-aud-c { background: #fff; border-radius: 16px; max-width: 480px; width: 100%; padding: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.td-aud-c h3 { margin: 0 0 8px; font-size: 18px; }
.td-aud-c p { margin: 0 0 14px; color: #4a443e; font-size: 14.5px; }
.td-aud-b { display: flex; flex-wrap: wrap; gap: 8px; }
.td-aud-b .btn { flex: 1 1 auto; text-align: center; text-decoration: none; justify-content: center; }
.td-hist { list-style: none; }
.td-hist-f { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 0 0 8px; }
.td-hist-f .lbl { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.td-hist-f input, .td-hist-f select { min-height: 38px; font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.td-hist-a { display: flex; gap: 6px; margin-left: auto; }
.td-hist-t tr[data-open] { cursor: pointer; }
.td-hist-t small { color: var(--muted, #77706a); }
body.td-hist-on #td-add, body.td-hist-on .td-head-r, body.td-hist-on #td-busca { display: none !important; }
/* celular: listas viram uma faixa de botões que rola para o lado; a atividade aberta ocupa a tela */
@media (max-width: 760px) {
  .td-side { flex-direction: row !important; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 6px !important; padding: 8px !important; scrollbar-width: none; }
  .td-side::-webkit-scrollbar { display: none; }
  .td-side .td-nav, .td-side .td-lrow { flex: 0 0 auto; }
  .td-side .td-nav { white-space: nowrap; min-height: 40px; }
  .td-side .td-sep { display: none; }
  .td-det:not([hidden]) { position: fixed !important; inset: 0; z-index: 9500; border-radius: 0 !important; max-height: none !important; overflow: auto !important; padding: calc(14px + env(safe-area-inset-top)) 14px calc(20px + env(safe-area-inset-bottom)) !important; }
  .td-det-acts { flex-wrap: wrap; }
  .td-det-acts .btn { flex: 1 1 auto; min-height: 44px; }
  .td-hist-a { margin-left: 0; width: 100%; }
  .td-hist-a .btn { flex: 1; }
  .td-add-opts { flex-wrap: wrap; }
}

/* ===== Impressão: só o conteúdo (relatórios, histórico de atividades) ===== */
@media print {
  .nsi-modbar, header.top .who, .td-side, .td-det, #td-add, .td-head-r, #td-busca, .td-hist-f, .proc-toast, .docm-top, .docm-foot { display: none !important; }
  .td-wrap { display: block !important; }
  .panel, .td-main { box-shadow: none !important; border: 0 !important; }
  .scroll { overflow: visible !important; }
  body { background: #fff !important; }
}
/* barra "Voltar / Continuar para emitir" do cadastro no celular: no computador ela não aparece (antes sobrava no rodapé) */
@media (min-width: 761px) { .docm-top, .docm-foot { display: none !important; } }
/* v2.64: pergunta "de quem é o cliente" dentro da atividade */
.td-item:has(.td-perg) { flex-wrap: wrap; }
.td-perg { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0 2px 36px; padding: 8px 10px; border-radius: 10px; background: #fff4e0; color: #8a5a00; font-weight: 600; font-size: 13.5px; }
.td-perg select { min-height: 36px; font: inherit; font-weight: 400; padding: 4px 8px; border: 1px solid #e3cfa5; border-radius: 8px; background: #fff; color: #1b1a19; flex: 1 1 180px; }
@media (max-width: 760px) { .td-perg { margin-left: 0; } .td-perg .btn { flex: 1 1 100%; min-height: 44px; } }
/* v2.65: suas audiências em destaque (página inicial e Pauta) */
.aud-minhas { display: inline-block; margin-top: 4px; color: var(--accent, #7a1a1f); }
.aud-table tr.aud-minha td { background: #fff7e6 !important; }
.aud-table tr.aud-minha td:first-child { box-shadow: inset 4px 0 0 #e0a020; }
/* v2.65: Atividades fixas */
.fx-f { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; align-items: end; border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 0 0 14px; background: #fff; }
.fx-f h3 { grid-column: 1 / -1; margin: 0; font-size: 16px; }
.fx-f .lbl { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.fx-f input[type=text], .fx-f input[type=date], .fx-f input[type=number], .fx-f select { min-height: 40px; font: inherit; font-size: 14.5px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface, #fff); }
.fx-f .fx-w, .fx-f .fx-b, .fx-f [data-fx="semanal"] { grid-column: 1 / -1; }
.fx-dias { display: flex; flex-wrap: wrap; gap: 6px; }
.fx-dia { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.fx-dia:has(input:checked) { background: var(--accent-soft, #f7eced); border-color: var(--accent, #7a1a1f); }
.fx-b { display: flex; gap: 8px; flex-wrap: wrap; }
.fx-t tr.fx-off td { opacity: .55; }
.fx-acts { white-space: nowrap; }
.fx-acts .btn { margin: 2px; }
@media (max-width: 760px) { .fx-f { grid-template-columns: 1fr; } .fx-b .btn { flex: 1; min-height: 44px; } }
.fx-f, .fx-f h3, .fx-f .chk, .fx-f .note { color: #1b1a19 !important; }
.fx-f .note { color: #6b645c !important; }
.td-hist.fx > .scroll, .td-hist.fx > .note { background: #fff; color: #1b1a19; border-radius: 14px; padding: 6px 10px; }
.td-hist.fx .fx-t th, .td-hist.fx .fx-t td { color: #1b1a19; }

/* v2.75 — toda pauta de audiências (Pauta, Início, Contencioso): data enquadrada, colunas centralizadas, sem o lápis */
.aud-table th, .aud-table td { text-align: center; vertical-align: middle; }
.aud-table th:last-child:empty, .aud-table td.acts { text-align: right; }
.aud-table td.aud-data { width: 76px; min-width: 76px; padding-right: 14px; white-space: nowrap; }
.aud-dt, .aud-pt { display: block; min-width: 0; }
.aud-dt b, .aud-dt small, .aud-pt b, .aud-pt small { display: block; }
.aud-pt b { overflow-wrap: anywhere; }
.aud-table td.aud-partes { min-width: 220px; }
.aud-table .aud-ed { display: none !important; }
@media (max-width: 820px) {
  table.aud-table { min-width: 0 !important; width: 100% !important; }
  .aud-table td.aud-data, .aud-table td.aud-partes { width: auto; min-width: 0; padding-right: 0; }
  .aud-table td > .aud-dt, .aud-table td > .aud-pt { flex: 1 1 auto; text-align: center; }
  .aud-dt { display: flex !important; justify-content: center; align-items: baseline; gap: 8px; }
  .aud-table td { text-align: center; }
}
.aud-pt-ed{color:inherit;text-decoration:none}.aud-pt-ed:hover{text-decoration:underline}
@media (max-width: 820px) { .m-card > tbody > tr, .m-card > tfoot > tr { box-sizing: border-box; max-width: 100%; } }
/* v2.77: campo obrigatório "Cliente do" */
.obrig{color:#b3261e;font-weight:700}
.cnj-erro{outline:2px solid #b3261e !important;outline-offset:1px}
/* v2.77: ficha trabalhista — atalhos dos dias, contador do intervalo, assédio */
.pt-jpre{gap:6px}
.pt-cont{display:flex;align-items:center;gap:6px}.pt-cont output{min-width:58px;text-align:center;font-weight:700;color:var(--ink,#222);font-size:14px}
.pt-cont .btn{min-width:36px}
.pt-ass{display:flex;flex-direction:column;gap:8px}
.pt-agr .pt-horas{grid-template-columns:repeat(3,minmax(0,1fr))}
.pt-agr select{width:100%;box-sizing:border-box}
@media (max-width:820px){.pt-agr .pt-horas{grid-template-columns:1fr}}
/* v2.84.2: celular (iPhone) — o topo das janelas (✕ e Salvar) não fica embaixo da barra de status / notch */
@media (max-width: 760px) {
  dialog[open], dialog.fin-dlg[open], dialog.proc-dlg[open] { margin-top: calc(env(safe-area-inset-top, 0px) + 12px) !important; margin-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px) !important; max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px) !important; top: 0 !important; bottom: auto !important; }
  .fin-dlg-head { position: sticky; top: 0; z-index: 20; background: var(--surface, #fff); }
  .fin-dlg-head .fin-x, .fin-dlg-head .fin-salvar { min-height: 40px; }
}
