:root {
  color-scheme: light;
  --primary: #1e40af; --primary-light: #dbeafe; --primary-dark: #1e3a8a;
  --success: #059669; --success-light: #d1fae5;
  --warning: #d97706; --warning-light: #fef3c7;
  --danger: #dc2626; --danger-light: #fee2e2;
  --purple: #7c3aed; --purple-light: #ede9fe;
  --gray-50:#f9fafb; --gray-100:#f3f4f6; --gray-200:#e5e7eb;
  --gray-300:#d1d5db; --gray-400:#9ca3af; --gray-500:#6b7280;
  --gray-600:#4b5563; --gray-700:#374151; --gray-900:#111827;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  /* Bloqueia pull-to-refresh nativo do browser — nova versão vem pelo banner "Atualizar" */
  overscroll-behavior-y: contain;
}
body { font-family: 'Segoe UI', system-ui, sans-serif; background: #f0f4f8; color: var(--gray-900); font-size: 14px; min-height: 100vh; }

header { background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%); color: white; padding: 14px 24px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 8px rgba(0,0,0,0.15); gap: 14px; flex-wrap: wrap; }
header h1 { font-size: 17px; font-weight: 700; }
header p { font-size: 12px; opacity: 0.75; margin-top: 2px; }
.role-badge { display: inline-block; margin-top: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .3px; }
.role-badge.role-admin { background: rgba(255,255,255,0.18); color: #fff; border: 1px solid rgba(255,255,255,0.35); }
.role-badge.role-gestor { background: var(--warning-light); color: #92400e; }
.hdr-actions { display: flex; align-items: center; gap: 8px; }
.hdr-badge { background: rgba(255,255,255,0.15); border-radius: 20px; padding: 4px 12px; font-size: 12px; font-weight: 500; }
.hdr-btn { background: rgba(255,255,255,0.12); color: white; border: 1px solid rgba(255,255,255,0.28); padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; transition: background 0.15s, border-color 0.15s; display: inline-flex; align-items: center; gap: 5px; }
.hdr-btn:hover { background: rgba(255,255,255,0.22); border-color: rgba(255,255,255,0.5); }
.hdr-btn.cloud-on { background: rgba(52,211,153,0.28); border-color: rgba(52,211,153,0.6); }

nav { background: white; border-bottom: 2px solid var(--gray-200); display: flex; padding: 0 20px; overflow-x: auto; }
.nav-tab { padding: 13px 18px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--gray-500); border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all 0.2s; white-space: nowrap; user-select: none; }
.nav-tab:hover { color: var(--primary); background: var(--gray-50); }
.nav-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.tab-content { display: none; padding: 20px; max-width: 1440px; margin: 0 auto; }
.tab-content.active { display: block; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: white; border-radius: 10px; padding: 16px 18px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); border: 1px solid var(--gray-100); }
.s-label { font-size: 11px; color: var(--gray-500); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.s-value { font-size: 26px; font-weight: 800; color: var(--gray-900); line-height: 1; }
.s-sub { font-size: 11px; color: var(--gray-400); margin-top: 5px; }
.sc-warn .s-value { color: var(--warning); }
.sc-danger .s-value { color: var(--danger); }
.sc-success .s-value { color: var(--success); }

.section { background: white; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); border: 1px solid var(--gray-100); margin-bottom: 18px; overflow: hidden; }
.sec-head { padding: 14px 18px; border-bottom: 1px solid var(--gray-100); display: flex; justify-content: space-between; align-items: center; background: var(--gray-50); }
.sec-head h2 { font-size: 13px; font-weight: 700; color: var(--gray-700); text-transform: uppercase; letter-spacing: 0.5px; }
.sec-body { padding: 16px 18px; }

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { background: var(--gray-50); padding: 9px 12px; text-align: left; font-weight: 700; color: var(--gray-700); border-bottom: 2px solid var(--gray-200); white-space: nowrap; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
td { padding: 8px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8faff; }
.td-money { text-align: right; font-family: 'Courier New', monospace; font-size: 12px; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 12px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.b-contrato { background: #dbeafe; color: #1e40af; }
.b-arp { background: #ede9fe; color: #5b21b6; }
.b-em-andamento { background: #dbeafe; color: #1d4ed8; }
.b-pendente { background: #fef3c7; color: #78350f; }
.b-diligencia { background: #fef9c3; color: #713f12; }
.b-liquidado { background: var(--success-light); color: #065f46; }
.b-critico { background: var(--danger-light); color: var(--danger); }
.b-encerrado { background: var(--gray-100); color: var(--gray-500); }
.b-especifico { background: var(--purple-light); color: var(--purple); }
.b-falta-ateste { background: #fff7ed; color: #9a3412; }
.b-aguard-pgto { background: #fef08a; color: #713f12; }
.b-dilig-fin { background: #faf5ff; color: #6d28d9; }

/* LOGIN GATE — tela de login obrigatória (Sessão 4) */
.login-gate {
  display: none;
  position: fixed; inset: 0;
  z-index: 3000;
  background: linear-gradient(150deg, #eef2f8 0%, #e2e8f2 55%, #d7dfea 100%);
  align-items: center; justify-content: center;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}
.login-gate.open { display: flex; }

/* ── SPLASH: ao abrir o app, o ícone surge grande e centralizado, depois
      encolhe e sobe virando o cabeçalho, enquanto o formulário aparece. ── */
.gate-brand { transition: transform 0.7s cubic-bezier(.4,0,.2,1); will-change: transform; }
#gate-form, #gate-setpw, #gate-offline {
  transition: opacity 0.5s ease 0.4s, transform 0.5s cubic-bezier(.34,1.1,.64,1) 0.4s;
}
.login-gate.splash .gate-brand { transform: translateY(min(22vh, 155px)) scale(1.55); }
.login-gate.splash #gate-form,
.login-gate.splash #gate-setpw,
.login-gate.splash #gate-offline { opacity: 0; transform: translateY(20px); pointer-events: none; }
/* Brilho azul pulsante na lupa durante o splash. */
.login-gate.splash .gate-logo { animation: splash-glow 1.15s ease-in-out infinite alternate; }
@keyframes splash-glow {
  from { filter: drop-shadow(0 0 2px rgba(59,130,246,0.15)); }
  to   { filter: drop-shadow(0 0 24px rgba(59,130,246,0.6)); }
}
@media (prefers-reduced-motion: reduce) {
  .gate-brand, #gate-form, #gate-setpw, #gate-offline { transition: none; }
  .login-gate.splash .gate-brand { transform: none; }
  .login-gate.splash #gate-form,
  .login-gate.splash #gate-setpw,
  .login-gate.splash #gate-offline { opacity: 1; transform: none; pointer-events: auto; }
  .login-gate.splash .gate-logo { animation: none; }
}
/* Ao entrar: o gate esmaece e amplia levemente, revelando o app por baixo. */
.login-gate.leaving { animation: gate-out 0.5s cubic-bezier(.4,0,.2,1) forwards; pointer-events: none; }
@keyframes gate-out { from { opacity: 1; } to { opacity: 0; transform: scale(1.06); } }
.login-gate.leaving .gate-card { animation: gate-card-out 0.5s cubic-bezier(.4,0,.2,1) forwards; }
@keyframes gate-card-out {
  30% { transform: translateY(0) scale(1.03); }
  100% { transform: translateY(-10px) scale(0.94); opacity: 0; }
}
/* Pulso no logo confirmando o acesso. */
.login-gate.leaving .gate-logo { animation: gate-logo-pop 0.45s cubic-bezier(.34,1.56,.64,1); }
@keyframes gate-logo-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
/* Enquanto travado, esconde o app por baixo pra não piscar */
body.gated > header,
body.gated > nav,
body.gated > .tab-content,
body.gated > #toast-container { visibility: hidden; }

.gate-card {
  background: transparent;
  width: 100%; max-width: 360px;
  border-radius: 16px;
  padding: 24px 24px;
}
.gate-brand { text-align: center; margin-bottom: 24px; }
.gate-logo { font-size: 44px; line-height: 1; margin-bottom: 12px; display: flex; justify-content: center; }
.gate-logo img { width: 88px; height: 88px; border-radius: 22px; box-shadow: 0 8px 22px rgba(30,58,138,0.22); display: block; }
.gate-brand h1 { font-size: 21px; font-weight: 800; color: var(--gray-900); line-height: 1.25; }
.gate-brand p { font-size: 12.5px; color: var(--gray-500); margin-top: 4px; }
.gate-field { margin-bottom: 14px; }
.gate-field label { display: block; font-size: 11px; font-weight: 700; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 5px; }
.gate-field input {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--gray-300); border-radius: 9px;
  font-size: 16px; /* 16px evita zoom no iOS */
  transition: border-color 0.15s, box-shadow 0.15s;
}
.gate-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,64,175,0.1); }
.gate-erro { display: none; font-size: 12.5px; color: var(--danger); background: var(--danger-light); border-radius: 7px; padding: 9px 12px; margin-bottom: 12px; line-height: 1.4; }
.gate-btn {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white; border: none; border-radius: 9px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: transform 0.1s, opacity 0.15s; min-height: 48px;
}
.gate-btn:hover { opacity: 0.94; }
.gate-btn:active { transform: scale(0.98); }
.gate-btn:disabled { opacity: 0.6; cursor: default; }
.gate-hint { font-size: 11px; color: var(--gray-400); text-align: center; margin-top: 16px; line-height: 1.5; }
.gate-loading { text-align: center; padding: 20px 0; }
.gate-loading p { font-size: 13px; color: var(--gray-500); margin-top: 12px; }
.gate-spinner {
  width: 34px; height: 34px; margin: 0 auto;
  border: 3px solid var(--gray-200); border-top-color: var(--primary);
  border-radius: 50%; animation: gate-spin 0.7s linear infinite;
}
@keyframes gate-spin { to { transform: rotate(360deg); } }
.gate-offline { text-align: center; }
.gate-offline-ico { font-size: 40px; margin-bottom: 10px; }
.gate-offline p { font-size: 13px; color: var(--gray-600); line-height: 1.55; margin-bottom: 10px; }
.gate-offline .gate-btn { margin-top: 8px; }

/* UPDATE BANNER — nova versão do PWA disponível */
#update-banner {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 2500;
  background: linear-gradient(90deg, #1e40af 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  animation: update-banner-in 0.25s ease-out;
  padding-top: env(safe-area-inset-top, 0);
}
#update-banner .ub-inner {
  display: flex; align-items: center; gap: 10px;
  max-width: 1440px; margin: 0 auto;
  padding: 10px 14px;
}
#update-banner .ub-msg { flex: 1; font-size: 13.5px; font-weight: 600; min-width: 0; }
#update-banner .ub-btn {
  background: white; color: var(--primary-dark);
  border: none; padding: 7px 16px; border-radius: 20px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  min-height: 34px; flex-shrink: 0;
  transition: transform 0.1s;
}
#update-banner .ub-btn:active { transform: scale(0.96); }
#update-banner .ub-close {
  background: rgba(255,255,255,0.15); color: white;
  border: none; width: 30px; height: 30px; border-radius: 50%;
  font-size: 14px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
#update-banner .ub-close:hover { background: rgba(255,255,255,0.25); }
@keyframes update-banner-in { from { transform: translateY(-100%); } to { transform: translateY(0); } }
@media (max-width: 768px) {
  #update-banner .ub-msg { font-size: 12.5px; }
  #update-banner .ub-btn { padding: 8px 14px; font-size: 13px; }
}

/* TOAST */
#toast-container { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { min-width: 260px; max-width: 380px; padding: 12px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.18); font-size: 13px; font-weight: 600; border-left: 4px solid; background: white; pointer-events: auto; animation: toast-in 0.22s ease-out; }
.toast.leaving { animation: toast-out 0.22s ease-in forwards; }
.toast-success { color: #065f46; border-left-color: var(--success); background: #f0fdf4; }
.toast-error   { color: #7f1d1d; border-left-color: var(--danger);  background: #fef2f2; }
.toast-warn    { color: #78350f; border-left-color: var(--warning); background: #fffbeb; }
.toast-info    { color: #1e3a8a; border-left-color: var(--primary); background: #eff6ff; }
@keyframes toast-in  { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { from { transform: translateX(0); opacity: 1; } to { transform: translateX(20px); opacity: 0; } }

/* FLASH — destaque de item recém-criado */
.pcard.flash-new { animation: flash-new 2s ease-out; }
@keyframes flash-new {
  0%   { background: #fef9c3; box-shadow: 0 0 0 3px #fde047; }
  60%  { background: #fefce8; box-shadow: 0 0 0 3px transparent; }
  100% { background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
}

/* HERO — botões grandes de ação no Painel */
.hero-actions { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.btn-hero { flex: 1 1 240px; padding: 14px 18px; border-radius: 10px; border: none; cursor: pointer; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 10px; transition: all 0.15s; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.btn-hero:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.btn-hero .h-ico { font-size: 22px; }
.btn-hero .h-title { font-size: 14px; font-weight: 800; }
.btn-hero .h-sub { font-size: 11px; opacity: 0.85; font-weight: 500; margin-top: 1px; }
.btn-hero.h-primary { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: white; }
.btn-hero.h-purple  { background: linear-gradient(135deg, var(--purple) 0%, #5b21b6 100%); color: white; }

/* pcard: botão de excluir */
.pcard-del { background: none; border: none; color: var(--gray-400); font-size: 15px; cursor: pointer; padding: 4px 6px; border-radius: 5px; margin-left: 6px; }
.pcard-del:hover { background: var(--danger-light); color: var(--danger); }
.pcard-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Modal delete-confirm — input de confirmação */
.del-warn { padding: 12px 14px; background: #fef2f2; border: 1px solid #fca5a5; border-radius: 8px; margin-bottom: 14px; color: #7f1d1d; font-size: 13px; line-height: 1.5; }
.del-warn b { color: var(--danger); }

.days-pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.dp-ok { background: var(--success-light); color: #065f46; }
.dp-warn { background: var(--warning-light); color: #92400e; }
.dp-crit { background: var(--danger-light); color: #7f1d1d; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; font-size: 12.5px; display: flex; align-items: flex-start; gap: 8px; border: 1px solid transparent; }
.alert-warn { background: #fffbeb; color: #78350f; border-color: #fcd34d; }
.alert-danger { background: #fff1f2; color: #7f1d1d; border-color: #fca5a5; }
.alert-info { background: #eff6ff; color: #1e3a8a; border-color: #93c5fd; }
.alert-purple { background: var(--purple-light); color: #4c1d95; border-color: #c4b5fd; }

.btn { padding: 7px 14px; border-radius: 7px; border: none; cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.15s; display: inline-flex; align-items: center; gap: 5px; }
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: white; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-purple { background: var(--purple); color: white; }
.btn-danger { background: var(--danger-light); color: var(--danger); border: 1px solid #fca5a5; }
.btn-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* Contrato / empresa ENCERRADO — permanece visível (registro), porém apagado. */
.ccard.is-encerrado, .emp-card.is-encerrado { opacity: 0.72; }
.ccard.is-encerrado { border-left: 3px solid var(--gray-400); }
.emp-card.is-encerrado { border-left: 3px solid var(--gray-400); }
.ccard.is-encerrado .ccard-title, .emp-card.is-encerrado .emp-name { text-decoration: line-through; text-decoration-color: var(--gray-400); }

.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.flt-btn { padding: 5px 13px; border-radius: 20px; border: 1.5px solid var(--gray-200); background: white; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--gray-600); transition: all 0.15s; }
.flt-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.flt-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* Select nativo de filtro (mobile-only, escondido em desktop) */
.filter-select {
  display: none;
  width: 100%;
  padding: 12px 40px 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  background: white;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%231e40af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
  min-height: 46px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.filter-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,64,175,0.1); }

.ccard { border: 1px solid var(--gray-200); border-radius: 10px; margin-bottom: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.06); transition: box-shadow 0.2s; }
.ccard:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.1); }
.ccard-head { padding: 13px 16px; background: var(--gray-50); display: flex; justify-content: space-between; align-items: center; cursor: pointer; gap: 12px; }
.ccard-head:hover { background: var(--primary-light); }
.ccard-title { font-weight: 700; font-size: 14px; }
.ccard-sub { font-size: 12px; color: var(--gray-500); margin-top: 3px; }
/* Aba Administração */
.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--gray-200); border-radius: 8px; background: var(--gray-50); flex-wrap: wrap; }
.admin-card-main { flex: 1; min-width: 150px; }
.admin-card-nome { font-weight: 600; font-size: 14px; }
.admin-you { font-weight: 500; color: var(--primary); font-size: 12px; }
.admin-card-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.admin-role { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.admin-role-fiscal { background: var(--primary-light); color: var(--primary-dark); }
.admin-role-gestor { background: var(--warning-light); color: #92400e; }
.admin-role-admin  { background: #ede9fe; color: #5b21b6; }
.admin-invite-note { margin-top: 16px; padding: 12px 14px; border: 1px dashed var(--gray-300); border-radius: 8px; font-size: 13px; color: var(--gray-600); line-height: 1.5; }
.ccard-body { display: none; border-top: 1px solid var(--gray-200); }
.ccard-body.open { display: block; }

.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; padding: 14px 16px; background: white; }
.m-label { font-size: 10px; color: var(--gray-400); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.m-val { font-size: 13px; font-weight: 600; margin-top: 2px; }

.fin-row { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 2px solid var(--gray-100); }
.fin-cell { padding: 12px 16px; text-align: center; border-right: 1px solid var(--gray-100); }
.fin-cell:last-child { border-right: none; }
.f-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; color: var(--gray-500); }
.f-val { font-size: 14px; font-weight: 800; margin-top: 4px; font-family: 'Courier New', monospace; }
.fc-emp .f-val { color: var(--primary); }
.fc-anu .f-val { color: var(--danger); }
.fc-liq .f-val { color: var(--success); }
.fc-sal .f-val { color: var(--warning); }

.emp-section { padding: 14px 16px; background: white; border-top: 1px solid var(--gray-100); }
.emp-section h4 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-500); margin-bottom: 10px; }

.doc-espec-strip { margin: 0 16px 0; padding: 10px 14px; background: var(--purple-light); border-radius: 8px; border-left: 3px solid var(--purple); display: flex; justify-content: space-between; align-items: center; }
.doc-espec-strip .de-info { font-size: 12px; color: #4c1d95; }
.doc-espec-strip .de-count { font-size: 13px; font-weight: 700; color: var(--purple); }

.obs-strip { margin: 0 16px 0; padding: 9px 12px; background: #fffbeb; border-radius: 6px; border-left: 3px solid var(--warning); font-size: 12px; color: #78350f; }

.ccard-actions { padding: 10px 16px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--gray-100); background: var(--gray-50); flex-wrap: wrap; }

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 11px; font-weight: 700; color: var(--gray-700); text-transform: uppercase; letter-spacing: 0.4px; }
select, input[type="text"], input[type="date"], textarea {
  padding: 8px 10px; border: 1.5px solid var(--gray-300); border-radius: 7px;
  font-size: 13px; color: var(--gray-900); background: white; width: 100%;
  transition: border-color 0.15s;
}
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,64,175,0.08); }
textarea { resize: vertical; min-height: 70px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

.cl-controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 20px; }
.cl-container { border-radius: 10px; border: 1px solid var(--gray-200); overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.cl-header { padding: 16px 18px; background: var(--primary-light); border-bottom: 1px solid var(--gray-200); }
.cl-header h3 { font-size: 15px; font-weight: 700; color: var(--primary-dark); }
.cl-header p { font-size: 12px; color: #3b5998; margin-top: 3px; }
.cl-body { padding: 16px 18px; background: white; }
.cl-group { margin-bottom: 18px; }
.cl-group-title { font-size: 11px; font-weight: 800; color: var(--gray-700); text-transform: uppercase; letter-spacing: 0.6px; padding-bottom: 6px; margin-bottom: 8px; border-bottom: 2px solid var(--gray-200); }
.cl-group-title.espec { color: var(--purple); border-bottom-color: var(--purple); }
.cl-item { display: flex; align-items: flex-start; gap: 10px; padding: 7px 6px; cursor: pointer; border-radius: 6px; transition: background 0.1s; }
.cl-item:hover { background: var(--gray-50); }
.cl-item input[type="checkbox"] { margin-top: 2px; width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); flex-shrink: 0; }
.cl-item .cl-text { font-size: 13px; color: var(--gray-900); line-height: 1.45; flex: 1; }
.cl-item.checked .cl-text { text-decoration: line-through; color: var(--gray-400); }
.cl-item.espec-item input { accent-color: var(--purple); }
.tag-obrig { font-size: 10px; background: #fee2e2; color: #dc2626; padding: 1px 6px; border-radius: 4px; font-weight: 700; flex-shrink: 0; margin-top: 2px; }
.tag-cond { font-size: 10px; background: #fff7ed; color: #c2410c; padding: 1px 6px; border-radius: 4px; font-weight: 700; flex-shrink: 0; margin-top: 2px; }
.tag-contrato { font-size: 10px; background: var(--purple-light); color: var(--purple); padding: 1px 6px; border-radius: 4px; font-weight: 700; flex-shrink: 0; margin-top: 2px; }
.tag-demo { font-size: 10px; background: #fff7ed; color: #9a3412; padding: 1px 6px; border-radius: 4px; font-weight: 700; flex-shrink: 0; margin-top: 2px; }
.tag-org { font-size: 10px; background: #eef2ff; color: #3730a3; padding: 1px 6px; border-radius: 4px; font-weight: 700; flex-shrink: 0; margin-top: 2px; }

/* CHECKLIST — status IA (visual sutil) */
.cl-item.status-ok       { border-left: 3px solid var(--success); padding-left: 8px; background: linear-gradient(90deg, #f0fdf4 0%, transparent 40%); }
.cl-item.status-ressalva { border-left: 3px solid var(--warning); padding-left: 8px; background: linear-gradient(90deg, #fffbeb 0%, transparent 40%); }
.cl-item.status-falta    { border-left: 3px solid var(--danger);  padding-left: 8px; background: linear-gradient(90deg, #fef2f2 0%, transparent 40%); }
.cl-status-ico { font-size: 14px; margin-right: 4px; flex-shrink: 0; margin-top: 1px; }
.cl-status-ico.ok       { color: var(--success); }
.cl-status-ico.ressalva { color: var(--warning); }
.cl-status-ico.falta    { color: var(--danger); }
.cl-item-note { font-size: 11px; color: var(--gray-600); margin-top: 3px; padding-left: 26px; line-height: 1.4; }
.cl-item.status-ok       .cl-item-note::before { content: '✓ '; color: var(--success); font-weight: 700; }
.cl-item.status-ressalva .cl-item-note::before { content: '⚠ '; color: var(--warning); font-weight: 700; }
.cl-item.status-falta    .cl-item-note::before { content: '✕ '; color: var(--danger); font-weight: 700; }

/* Resumo do checklist */
.cl-summary { display: flex; gap: 10px; flex-wrap: wrap; padding: 10px 12px; background: var(--gray-50); border-radius: 8px; margin-bottom: 12px; align-items: center; }
.cl-sum-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.cl-sum-pill.tot { background: var(--primary-light); color: var(--primary-dark); }
.cl-sum-pill.ok  { background: var(--success-light); color: #065f46; }
.cl-sum-pill.res { background: var(--warning-light); color: #78350f; }
.cl-sum-pill.fal { background: var(--danger-light); color: #7f1d1d; }
.cl-sum-pill.pen { background: var(--gray-100); color: var(--gray-700); }
.cl-sum-actions { margin-left: auto; display: flex; gap: 6px; }

/* CHECKLIST — botão remover item para este contrato */
.cl-item-remove { background: none; border: none; color: var(--gray-300); font-size: 14px; cursor: pointer; padding: 0 6px; border-radius: 4px; opacity: 0; transition: opacity 0.15s, color 0.15s; }
.cl-item:hover .cl-item-remove { opacity: 1; }
.cl-item-remove:hover { color: var(--danger); background: var(--danger-light); }
.cl-item-disabled { background: repeating-linear-gradient(45deg, var(--gray-50), var(--gray-50) 6px, transparent 6px, transparent 12px); border-radius: 6px; opacity: 0.8; }
.cl-item-reactivate { background: var(--success-light); color: #065f46; border: 1px solid #86efac; padding: 3px 10px; font-size: 11px; font-weight: 700; cursor: pointer; border-radius: 12px; margin-left: auto; }
.cl-item-reactivate:hover { background: var(--success); color: white; }
.cl-excluidos-strip { padding: 8px 12px; background: var(--gray-50); border: 1px dashed var(--gray-300); border-radius: 6px; margin-bottom: 12px; font-size: 12px; color: var(--gray-500); display: flex; justify-content: space-between; align-items: center; }

/* PROTOCOL — múltiplos AFs/Empenhos por liquidação */
.np-item-block { padding: 10px; background: var(--gray-50); border-radius: 8px; margin-bottom: 8px; border: 1px solid var(--gray-200); }
.np-item-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; align-items: center; }
.np-item-row input { padding: 6px 8px; font-size: 12px; }
.np-item-empty { font-size: 12px; color: var(--gray-400); padding: 6px 0 8px; font-style: italic; }
.np-item-picker {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--gray-300);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: white;
  color: var(--gray-900);
  margin-bottom: 6px;
  cursor: pointer;
}
.np-item-picker:focus { outline: none; border-color: var(--primary); }
.np-item-info {
  font-size: 11px;
  color: var(--gray-600);
  padding: 6px 8px;
  background: white;
  border-radius: 5px;
  margin-top: 6px;
  border-left: 3px solid var(--success);
}
.np-item-info b { color: var(--success); }
.np-item-info.np-item-warn {
  color: var(--danger);
  border-left-color: var(--danger);
  background: #fef2f2;
}
.np-item-info.np-item-warn b { color: var(--danger); }

/* RELATÓRIO MENSAL */
.rel-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
  padding: 12px 14px; background: white; border-radius: 10px;
  border: 1px solid var(--gray-200); box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.rel-mes { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rel-mes label { font-size: 11px; font-weight: 700; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.4px; }
.rel-mes select, .rel-mes input {
  padding: 6px 10px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--gray-300); border-radius: 6px;
  width: auto; min-width: 110px;
}
.rel-mes input#rel-ano { min-width: 90px; }
.rel-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.rel-preview { background: white; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); border: 1px solid var(--gray-100); padding: 24px 28px; }
.rel-doc { max-width: 780px; margin: 0 auto; font-family: 'Segoe UI', system-ui, sans-serif; }
.rel-head { text-align: center; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--gray-200); }
.rel-title { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; line-height: 1.4; }
.rel-sub { font-size: 14px; font-weight: 600; margin-top: 6px; }
.rel-people { text-align: center; font-size: 13px; margin-bottom: 18px; line-height: 1.8; }
.rel-people b { font-weight: 700; }
.rel-totais { padding: 12px 14px; background: #fef9c3; border-radius: 8px; font-size: 13px; line-height: 1.8; margin-bottom: 18px; border-left: 4px solid #eab308; }
.rel-totais b { color: #713f12; }
.rel-consid { margin-bottom: 22px; }
.rel-consid label { display: block; font-size: 11px; font-weight: 700; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }
.rel-consid textarea { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 13px; line-height: 1.6; min-height: 110px; resize: vertical; }
.rel-contracts { display: flex; flex-direction: column; gap: 14px; }
.rel-contract h4 { font-size: 14px; font-weight: 700; margin-bottom: 8px; color: var(--gray-900); }
.rel-contract ul { padding-left: 22px; }
.rel-contract li { font-size: 13px; line-height: 1.6; margin-bottom: 5px; }
.rel-empty { font-size: 12px; color: var(--gray-400); font-style: italic; padding: 4px 0; }

@media (max-width: 768px) {
  .rel-preview { padding: 14px; }
  .rel-title { font-size: 13px; }
  .rel-sub { font-size: 12.5px; }
  .rel-people { font-size: 12.5px; }
  .rel-totais { font-size: 12.5px; }
  .rel-contract h4 { font-size: 13px; }
  .rel-contract li { font-size: 12.5px; }
  .rel-actions .btn { flex: 1; justify-content: center; }
}

/* MODAL EMPENHOS — cadastro por contrato */
.emp-mod-row {
  padding: 10px 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  margin-bottom: 8px;
}
.emp-mod-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.emp-mod-grid div { display: flex; flex-direction: column; gap: 3px; }
.emp-mod-grid label {
  font-size: 10px; color: var(--gray-500); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.emp-mod-grid input {
  padding: 7px 9px; font-size: 13px;
  border: 1px solid var(--gray-300); border-radius: 6px;
  background: white;
}
.emp-mod-grid input:focus { outline: none; border-color: var(--primary); }
.emp-mod-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed var(--gray-200);
  gap: 8px; flex-wrap: wrap;
}
.emp-mod-saldo {
  font-size: 12px; color: var(--gray-700);
}
.emp-mod-saldo b { color: var(--success); font-family: 'Courier New', monospace; }
.emp-mod-saldo.semSaldo b { color: var(--danger); }
@media (max-width: 768px) {
  .emp-mod-grid { grid-template-columns: 1fr; }
  .emp-mod-grid input { font-size: 15px; padding: 10px 11px; }
}
.btn-icon-del { background: none; border: 1px solid var(--gray-200); color: var(--gray-500); width: 30px; height: 30px; border-radius: 6px; cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.btn-icon-del:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-light); }
.np-items-hint { padding: 8px 10px; background: var(--primary-light); border-radius: 6px; font-size: 11px; color: var(--primary-dark); margin-bottom: 8px; line-height: 1.4; }

/* PROTOCOL card — chips dos itens */
.p-itens-wrap { grid-column: 1 / -1; margin-top: 4px; }
.p-itens-title { font-size: 10px; color: var(--gray-400); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.p-item-chip { display: inline-block; padding: 3px 9px; margin: 2px 4px 2px 0; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 12px; font-size: 11.5px; color: var(--gray-700); font-family: 'Courier New', monospace; }
.p-item-chip b { color: var(--primary); font-weight: 700; }
.p-item-chip .p-val { color: var(--success); font-weight: 700; }

/* Badge do contrato: "usa próprio processo" */
.b-mesmo-processo { background: #eff6ff; color: var(--primary-dark); }
.b-dispensa-doc { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.b-demo { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.b-sem-rel { background: var(--gray-100); color: var(--gray-600); border: 1px solid var(--gray-300); }

/* ═══ Agenda ═══ */
.ag-grupo { margin-bottom: 18px; }
.ag-grupo-h { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.ag-card { display: flex; gap: 12px; align-items: flex-start; background: white; border: 1px solid var(--gray-200); border-left: 4px solid var(--gray-300); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.ag-card.ag-late { border-left-color: var(--danger); background: var(--danger-light); }
.ag-card.ag-today { border-left-color: var(--primary); background: var(--primary-light); }
.ag-card.ag-done { opacity: .6; }
.ag-card.ag-done .ag-titulo { text-decoration: line-through; }
.ag-when { flex-shrink: 0; width: 92px; text-align: center; }
.ag-date { font-size: 12.5px; font-weight: 800; color: var(--gray-900); font-family: 'Courier New', monospace; }
.ag-rel { font-size: 11px; color: var(--gray-500); margin-top: 2px; }
.ag-main { flex: 1; min-width: 0; }
.ag-titulo { font-size: 13.5px; font-weight: 700; color: var(--gray-900); }
.ag-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 5px; font-size: 11.5px; color: var(--gray-600); }
.ag-obs { font-size: 12px; color: var(--gray-600); margin-top: 5px; line-height: 1.4; white-space: pre-wrap; }
.ag-acoes { display: flex; gap: 5px; align-items: center; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.ag-auto { font-size: 10.5px; color: var(--gray-400); font-style: italic; flex-shrink: 0; align-self: center; }
@media (max-width: 640px) {
  .ag-card { flex-wrap: wrap; }
  .ag-when { width: auto; text-align: left; display: flex; gap: 8px; align-items: baseline; }
  .ag-acoes { width: 100%; justify-content: flex-start; }
}

/* Link no número (protocolo ou processo) */
.numero-link { color: var(--primary); text-decoration: none; border-bottom: 1px dashed var(--primary-light); transition: all 0.15s; }
.numero-link:hover { color: var(--primary-dark); border-bottom-color: var(--primary); }
.numero-link::after { content: ' ↗'; font-size: 0.85em; opacity: 0.6; }

/* Fiscais técnicos — bloco dinâmico e chips */
.fiscal-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.fiscal-row input { padding: 6px 8px; font-size: 12px; }
.fiscal-chip { display: inline-block; padding: 2px 9px; margin: 2px 4px 2px 0; background: var(--gray-100); border-radius: 10px; font-size: 12px; color: var(--gray-700); }

/* Botão pequeno pra copiar (aba IA) */
.btn-copy-inline { background: var(--gray-50); color: var(--gray-700); border: 1px solid var(--gray-300); padding: 5px 11px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; transition: all 0.15s; }
.btn-copy-inline:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }

/* EMPRESAS + CERTIDÕES */
.emp-card { border: 1px solid var(--gray-200); border-radius: 10px; margin-bottom: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.06); background: white; }
.emp-head { padding: 13px 16px; background: var(--gray-50); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.emp-name { font-weight: 700; font-size: 14px; color: var(--gray-900); }
.emp-sub  { font-size: 11.5px; color: var(--gray-500); margin-top: 2px; }
.emp-status-row { display: flex; gap: 6px; flex-wrap: wrap; }
.cert-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 14px; font-size: 11px; font-weight: 700; cursor: pointer; user-select: none; transition: transform 0.1s; border: 1px solid transparent; }
.cert-pill:hover { transform: translateY(-1px); }
.cert-pill.cert-ok       { background: var(--success-light); color: #065f46; border-color: #a7f3d0; }
.cert-pill.cert-warn     { background: var(--warning-light); color: #78350f; border-color: #fcd34d; }
.cert-pill.cert-vencida  { background: var(--danger-light);  color: #7f1d1d; border-color: #fca5a5; }
.cert-pill.cert-pendente { background: var(--gray-100);      color: var(--gray-500); border-color: var(--gray-300); }
.emp-body { padding: 14px 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; border-top: 1px solid var(--gray-100); }
.cert-card { border: 1px solid var(--gray-200); border-radius: 8px; padding: 10px 12px; background: var(--gray-50); }
.cert-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 6px; }
.cert-card-tipo { font-size: 11px; font-weight: 700; color: var(--gray-700); text-transform: uppercase; letter-spacing: 0.4px; }
.cert-card-body { font-size: 12px; color: var(--gray-500); line-height: 1.5; }
.cert-card-body .cert-val { font-weight: 700; color: var(--gray-900); font-family: 'Courier New', monospace; }
.cert-card-body .cert-dias-warn    { color: var(--warning); font-weight: 700; }
.cert-card-body .cert-dias-vencida { color: var(--danger);  font-weight: 700; }
.cert-card-body .cert-dias-ok      { color: var(--success); font-weight: 700; }
.emp-actions { padding: 10px 16px; display: flex; gap: 6px; justify-content: flex-end; border-top: 1px solid var(--gray-100); background: var(--gray-50); flex-wrap: wrap; }

/* CONTRATOS dentro do card de Empresa */
.emp-contracts-section { padding: 12px 16px 6px; border-top: 1px solid var(--gray-100); background: #fafbfd; }
.emp-contracts-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-bottom: 10px;
  font-size: 11px; font-weight: 700; color: var(--gray-600);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.emp-contracts-list .ccard { margin-bottom: 8px; }
.emp-contracts-list .ccard:last-child { margin-bottom: 0; }
.es-inline {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; background: white; border: 1px dashed var(--gray-300); border-radius: 8px;
  font-size: 12.5px; color: var(--gray-500);
}

/* PAINEL DE PROTOCOLOS DO CONTRATO */
.cp-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.cp-total-card { padding: 10px 12px; background: var(--gray-50); border-radius: 8px; border-left: 3px solid var(--primary); }
.cp-total-card.liq { border-left-color: var(--success); }
.cp-total-card.pend { border-left-color: var(--warning); }
.cp-total-card.and { border-left-color: var(--primary); }
.cp-total-card.dev { border-left-color: var(--danger); }
.cp-total-label { font-size: 10px; color: var(--gray-500); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.cp-total-value { font-size: 15px; font-weight: 800; font-family: 'Courier New', monospace; margin-top: 3px; }
.cp-total-count { font-size: 11px; color: var(--gray-400); margin-top: 2px; }
.cp-table { font-size: 12px; }
.cp-table th { font-size: 10.5px; }
.cp-table td { padding: 6px 8px; }
.cp-table .cp-af { font-family: 'Courier New', monospace; font-size: 11px; }
.cp-empty { padding: 30px 20px; text-align: center; color: var(--gray-400); font-size: 13px; }

/* HISTÓRICO */
.history-list { max-height: 400px; overflow-y: auto; }
.history-entry { padding: 10px 12px; border-left: 3px solid var(--gray-300); margin-bottom: 8px; background: var(--gray-50); border-radius: 0 8px 8px 0; }
.history-entry.action-created { border-left-color: var(--success); }
.history-entry.action-edited  { border-left-color: var(--primary); }
.history-entry.action-status  { border-left-color: var(--warning); }
.history-entry.action-deleted { border-left-color: var(--danger); }
.history-entry.action-note    { border-left-color: var(--purple); }
.history-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.history-action { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--gray-700); }
.history-at { font-size: 11px; color: var(--gray-500); font-family: 'Courier New', monospace; }
.history-by { font-size: 11px; color: var(--primary); }
.history-details { font-size: 12px; color: var(--gray-700); line-height: 1.5; }
.history-details .hc-change { display: block; margin-top: 3px; }
.history-details .hc-field { color: var(--gray-500); font-weight: 700; }
.history-details .hc-old { color: var(--danger); text-decoration: line-through; }
.history-details .hc-new { color: var(--success); font-weight: 600; }

/* Rodapé de "última edição" em modais */
.edit-footer { padding: 8px 12px; background: var(--gray-50); border-radius: 6px; font-size: 11px; color: var(--gray-500); margin-top: 12px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; }
.edit-footer .btn-hist-inline { background: none; border: none; color: var(--primary); font-size: 11px; font-weight: 700; cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.edit-footer .btn-hist-inline:hover { background: var(--primary-light); }

/* Config global — sidebar de usuário */
.user-config { display: flex; align-items: center; gap: 6px; font-size: 12px; color: rgba(255,255,255,0.85); background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); border-radius: 20px; padding: 4px 12px; cursor: pointer; transition: background 0.15s; }
.user-config:hover { background: rgba(255,255,255,0.18); }

/* IA & PROMPTS */
.ai-section { background: white; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); border: 1px solid var(--gray-100); margin-bottom: 18px; padding: 16px 18px; }
.ai-section-title { font-size: 13px; font-weight: 700; color: var(--gray-700); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.ai-prov-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.ai-prov-card { border: 1px solid var(--gray-200); border-radius: 8px; padding: 12px 14px; background: var(--gray-50); }
.ai-prov-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 8px; }
.ai-prov-name { font-weight: 700; font-size: 13px; color: var(--gray-900); }
.ai-prov-url { font-size: 11px; color: var(--primary); word-break: break-all; text-decoration: none; font-family: 'Courier New', monospace; }
.ai-prov-url:hover { text-decoration: underline; }
.ai-prov-actions { display: flex; gap: 4px; flex-shrink: 0; }
.ai-prompt-card { border: 1px solid var(--gray-200); border-radius: 8px; padding: 12px 14px; background: white; margin-bottom: 12px; }
.ai-prompt-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.ai-prompt-title { font-weight: 700; font-size: 13px; color: var(--gray-900); }
.ai-prompt-sub { font-size: 11px; color: var(--gray-500); margin-top: 2px; }
.ai-prompt-txt { width: 100%; font-family: 'Courier New', monospace; font-size: 12px; line-height: 1.5; min-height: 220px; }
.ai-placeholders { padding: 8px 10px; background: var(--primary-light); border-radius: 6px; font-size: 11px; color: var(--primary-dark); line-height: 1.6; margin-bottom: 8px; }
.ai-placeholders code { background: white; padding: 1px 5px; border-radius: 3px; font-family: 'Courier New', monospace; color: var(--primary-dark); font-size: 11px; }

/* Modal "Rodar IA" — preview do prompt */
.ai-run-info { padding: 10px 12px; background: var(--primary-light); border-radius: 7px; font-size: 12px; color: var(--primary-dark); line-height: 1.5; margin-bottom: 12px; }
.ai-run-info b { color: var(--primary-dark); }
.ai-run-preview { width: 100%; font-family: 'Courier New', monospace; font-size: 11.5px; line-height: 1.5; min-height: 260px; max-height: 400px; background: var(--gray-50); }
.ai-run-steps { padding: 10px 12px; background: #ecfdf5; border-left: 3px solid var(--success); border-radius: 6px; font-size: 12px; color: #065f46; line-height: 1.6; margin-top: 12px; }
.ai-run-steps ol { margin: 4px 0 0 18px; }

/* Parecer final destacado */
.parecer-final { padding: 12px 14px; border-radius: 8px; margin-top: 12px; font-size: 13px; font-weight: 700; border-left: 4px solid; }
.pf-apto     { background: #ecfdf5; color: #065f46; border-left-color: var(--success); }
.pf-pendente { background: #fef2f2; color: #7f1d1d; border-left-color: var(--danger); }
.pf-ressalva { background: #fffbeb; color: #78350f; border-left-color: var(--warning); }
.parecer-final .pf-detail { font-size: 12px; font-weight: 500; margin-top: 4px; line-height: 1.5; }

/* MODELOS DE DESPACHOS */
.modelo-card { border: 1px solid var(--gray-200); border-radius: 10px; padding: 14px 16px; background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 12px; }
.modelo-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.modelo-title { font-size: 14px; font-weight: 700; color: var(--gray-900); }
.modelo-cat { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-top: 4px; }
.mc-liquidacao   { background: var(--success-light); color: #065f46; }
.mc-diligencia   { background: var(--warning-light); color: #78350f; }
.mc-regularidade { background: var(--primary-light); color: var(--primary-dark); }
.mc-devolucao    { background: var(--danger-light);  color: #7f1d1d; }
.mc-reajuste     { background: var(--purple-light);  color: #4c1d95; }
.mc-outros       { background: var(--gray-100);      color: var(--gray-700); }
.modelo-preview { font-size: 12px; color: var(--gray-600); line-height: 1.5; max-height: 88px; overflow: hidden; position: relative; white-space: pre-wrap; padding: 10px 12px; background: var(--gray-50); border-radius: 6px; border-left: 3px solid var(--gray-300); font-family: 'Courier New', monospace; }
.modelo-preview::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 24px; background: linear-gradient(transparent, var(--gray-50)); pointer-events: none; }
.modelo-actions { display: flex; gap: 6px; flex-shrink: 0; }

.prog-wrap { margin-bottom: 14px; }
.prog-text { font-size: 12px; color: var(--gray-500); margin-bottom: 5px; font-weight: 600; }
.prog-bar { height: 7px; background: var(--gray-200); border-radius: 4px; overflow: hidden; }
.prog-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s, background 0.3s; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--gray-400); }
.es-icon { font-size: 52px; margin-bottom: 14px; }
.es-title { font-size: 15px; font-weight: 600; color: var(--gray-600); }
.es-sub { font-size: 13px; margin-top: 6px; max-width: 420px; margin-left: auto; margin-right: auto; line-height: 1.5; }

.pcard { border: 1px solid var(--gray-200); border-radius: 10px; margin-bottom: 10px; padding: 15px 17px; background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.pcard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.pcard-num { font-weight: 700; font-size: 14px; }
.pcard-emp { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.pcard-details { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding-top: 10px; border-top: 1px solid var(--gray-100); }
.pd-label { font-size: 10px; color: var(--gray-400); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.pd-val { font-size: 13px; font-weight: 600; margin-top: 2px; }
.pcard-obs { margin-top: 10px; padding: 8px 11px; background: var(--gray-50); border-radius: 6px; font-size: 12px; color: var(--gray-700); border-left: 3px solid var(--gray-300); white-space: pre-wrap; }
.hist-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-400); margin: 10px 0 6px; }
.hist-item { font-size: 12px; padding: 5px 0; border-bottom: 1px solid var(--gray-100); display: flex; gap: 10px; }
.hist-item:last-child { border-bottom: none; }
.hist-date { color: var(--gray-400); font-weight: 600; flex-shrink: 0; min-width: 85px; }
.pcard-hist-collapse { margin-top: 10px; border-top: 1px solid var(--gray-100); padding-top: 6px; }
.pcard-hist-collapse summary { cursor: pointer; font-size: 10.5px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; padding: 4px 6px; border-radius: 4px; user-select: none; list-style: none; display: flex; align-items: center; gap: 6px; }
.pcard-hist-collapse summary::-webkit-details-marker { display: none; }
.pcard-hist-collapse summary::before { content: '▶'; font-size: 8px; color: var(--gray-400); transition: transform 0.15s; }
.pcard-hist-collapse[open] summary::before { transform: rotate(90deg); }
.pcard-hist-collapse summary:hover { background: var(--gray-50); color: var(--primary); }
.pcard-hist-collapse[open] .hist-item { margin-left: 14px; }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { background: white; border-radius: 12px; width: 100%; max-width: 580px; max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal.modal-lg { max-width: 680px; }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--gray-200); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: white; z-index: 1; }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: var(--gray-100); border: none; font-size: 16px; cursor: pointer; color: var(--gray-500); width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--gray-200); }
.modal-body { padding: 20px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; }

.de-list { margin-bottom: 16px; }
.de-item { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border: 1px solid var(--gray-200); border-radius: 7px; margin-bottom: 6px; background: var(--gray-50); }
.de-item .de-txt { flex: 1; font-size: 13px; line-height: 1.4; }
.de-item .de-tags { display: flex; gap: 4px; flex-shrink: 0; }
.de-item .de-del { background: none; border: none; cursor: pointer; color: var(--gray-400); font-size: 16px; padding: 0 2px; flex-shrink: 0; }
.de-item .de-del:hover { color: var(--danger); }
.de-origem { font-size: 10px; color: var(--gray-400); margin-top: 2px; }

.divider { border: none; border-top: 2px dashed var(--gray-200); margin: 18px 0; }

.import-box { background: #f5f3ff; border: 1.5px dashed var(--purple); border-radius: 8px; padding: 14px; }
.import-box h4 { font-size: 12px; font-weight: 700; color: var(--purple); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.import-box p { font-size: 12px; color: #5b21b6; margin-bottom: 10px; line-height: 1.5; }
.import-box textarea { font-family: monospace; font-size: 12px; min-height: 100px; }

/* Título do header — variantes desktop/mobile */
.hdr-title { min-width: 0; flex: 1; }
.hdr-h1-short { display: none; }

/* NAV mobile — bottom bar fixa (escondida em desktop) */
.nav-mobile { display: none; }

/* Bottom sheet "Mais" — escondido por padrão */
.mobile-sheet-overlay { display: none; }

/* Feedback tátil universal para botões (útil desktop também) */
.btn:active, .btn-hero:active, .hdr-btn:active, .flt-btn:active,
.nav-tab:active, .nav-mobile-tab:active, .cert-pill:active,
.btn-copy-inline:active, .mobile-sheet-item:active {
  transform: scale(0.97);
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE — max-width: 768px
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  body {
    font-size: 15px;
    padding-bottom: 68px; /* espaço pro bottom nav fixo */
    -webkit-tap-highlight-color: transparent;
  }

  /* Header colapsado: só título curto + user badge */
  header {
    padding: 10px 14px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  header h1 { font-size: 15px; line-height: 1.2; }
  .hdr-h1-full  { display: none; }
  .hdr-h1-short { display: inline; }
  header p#hdr-date { font-size: 11px; margin-top: 1px; }
  .hdr-btn-desktop { display: none; } /* export/import migram pro menu Mais */
  .hdr-actions { gap: 6px; flex-shrink: 0; }
  .user-config { padding: 6px 12px; font-size: 12px; min-height: 36px; }

  /* Nav desktop — some, dá lugar à bottom bar */
  nav.nav-desktop { display: none; }

  /* Nav mobile — barra inferior fixa */
  nav.nav-mobile {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
    z-index: 900;
    padding: 4px 2px calc(4px + env(safe-area-inset-bottom, 0px));
    gap: 0;
  }
  .nav-mobile-tab {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    border-radius: 8px;
    min-height: 52px;
    transition: color 0.15s, background 0.15s;
  }
  .nav-mobile-tab .nm-ico { font-size: 20px; line-height: 1; }
  .nav-mobile-tab .nm-lbl { font-size: 10.5px; letter-spacing: 0.1px; }
  .nav-mobile-tab.active { color: var(--primary); background: var(--primary-light); }
  .nav-mobile-tab:active { background: var(--gray-100); }

  /* Conteúdo — padding menor, ocupa toda a largura */
  .tab-content { padding: 12px 12px 20px; }

  /* Painel — botões hero empilham */
  .hero-actions { flex-direction: column; gap: 8px; margin-bottom: 12px; }
  .btn-hero { flex: 1 1 auto; padding: 14px 16px; min-height: 60px; }
  .btn-hero .h-ico { font-size: 24px; }

  /* Stats grid — 2 colunas em vez de auto-fit */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
  .stat-card { padding: 12px 14px; }
  .s-value { font-size: 22px; }

  /* Seções — padding menor */
  .section { margin-bottom: 12px; border-radius: 10px; }
  .sec-head { padding: 12px 14px; flex-wrap: wrap; gap: 6px; }
  .sec-head h2 { font-size: 12px; }
  .sec-body { padding: 12px 14px; }

  /* Cards de contrato/empresa */
  .ccard, .emp-card { border-radius: 10px; margin-bottom: 10px; }
  .ccard-head, .emp-head { padding: 12px 14px; }
  .ccard-title, .emp-name { font-size: 14px; }
  .ccard-sub, .emp-sub { font-size: 12px; }
  .meta-grid { padding: 12px 14px; grid-template-columns: 1fr 1fr; gap: 10px; }
  .m-val { font-size: 13px; }
  .emp-body { grid-template-columns: 1fr; padding: 12px 14px; }
  .ccard-actions, .emp-actions { padding: 10px 14px; gap: 6px; }
  .ccard-actions .btn, .emp-actions .btn { flex: 1 1 auto; justify-content: center; }
  .fin-row { grid-template-columns: 1fr 1fr; }
  .fin-cell { padding: 10px 12px; }
  .fin-cell:nth-child(2n) { border-right: none; }
  .fin-cell:nth-child(-n+2) { border-bottom: 1px solid var(--gray-100); }

  /* Protocol cards */
  .pcard { padding: 12px 14px; }
  .pcard-num { font-size: 14px; }
  .pcard-details { grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 10px; }

  /* No celular a fileira de 5 botões não cabe ao lado da informação: ela não
     encolhia, esmagava o número do protocolo e vazava para fora do card.
     Empilha — informação em cima, ações embaixo, ocupando a largura toda. */
  .pcard-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .pcard-actions { flex-wrap: wrap; width: 100%; }
  .pcard-actions .btn { flex: 1 1 auto; justify-content: center; }
  /* Botões só de ícone não devem esticar junto com os que têm rótulo. */
  .pcard-actions .btn[data-action="open-history-protocol"] { flex: 0 0 auto; }
  .pcard-del { margin-left: auto; }
  .pcard-emp { overflow-wrap: anywhere; }

  /* Filtros e botões */
  .filter-bar { gap: 5px; }
  .flt-btn {
    padding: 7px 13px;
    min-height: 36px;
    font-size: 12px;
  }
  .btn { padding: 10px 14px; font-size: 14px; min-height: 42px; }
  .btn-sm { padding: 8px 12px; font-size: 13px; min-height: 38px; }
  .btn-xs { padding: 6px 10px; font-size: 12px; min-height: 34px; }

  /* Formulários — inputs 44px pra toque confortável */
  select, input[type="text"], input[type="date"], textarea {
    padding: 11px 12px;
    font-size: 15px; /* >= 16px evita zoom no iOS; 15px é bom compromisso */
    border-radius: 8px;
    min-height: 44px;
  }
  input[type="text"], input[type="date"], select { font-size: 16px; } /* previne zoom iOS */
  textarea { min-height: 88px; font-size: 15px; }
  .form-group label { font-size: 11px; margin-bottom: 2px; }
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .form-grid .full { grid-column: 1; }

  /* Modais — fullscreen no mobile */
  .modal-overlay { padding: 0; align-items: stretch; justify-content: stretch; }
  .modal-overlay.open { display: flex; }
  .modal, .modal.modal-lg {
    max-width: 100%;
    width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }
  .modal-head {
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    flex-shrink: 0;
  }
  .modal-head h3 { font-size: 16px; }
  .modal-close { width: 36px; height: 36px; font-size: 18px; }
  .modal-body { padding: 14px 16px; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .modal-foot {
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
  }
  .modal-foot .btn { flex: 1; justify-content: center; }

  /* Tabelas — só as do painel viram scrolláveis; texto menor */
  table { font-size: 12px; }
  th { padding: 8px 10px; font-size: 10.5px; }
  td { padding: 8px 10px; }

  /* Bottom sheet "Mais" */
  .mobile-sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1500;
    align-items: flex-end;
    justify-content: center;
  }
  .mobile-sheet-overlay.open { display: flex; }
  .mobile-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
    animation: sheet-fade 0.18s ease-out;
  }
  .mobile-sheet {
    position: relative;
    background: white;
    width: 100%;
    max-width: 520px;
    border-radius: 16px 16px 0 0;
    padding: 8px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -6px 24px rgba(0,0,0,0.2);
    animation: sheet-up 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 88vh;
    overflow-y: auto;
  }
  .mobile-sheet-handle {
    width: 40px; height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: 6px auto 12px;
  }
  .mobile-sheet-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 4px 8px;
  }
  .mobile-sheet-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 12px 14px;
    background: white;
    border: 1px solid var(--gray-100);
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    color: var(--gray-900);
    margin-bottom: 6px;
    transition: background 0.15s;
    min-height: 60px;
  }
  .mobile-sheet-item:active { background: var(--gray-50); }
  .mobile-sheet-item .ms-ico { font-size: 22px; flex-shrink: 0; width: 28px; text-align: center; }
  .mobile-sheet-item b { font-size: 14px; font-weight: 700; }
  .mobile-sheet-item small { font-size: 11.5px; color: var(--gray-500); font-weight: 500; }
  .mobile-sheet-sep {
    height: 1px;
    background: var(--gray-100);
    margin: 8px 4px;
  }
  .mobile-sheet-cancel {
    display: block;
    width: 100%;
    padding: 14px;
    margin-top: 10px;
    background: var(--gray-100);
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-700);
    cursor: pointer;
    min-height: 48px;
  }
  .mobile-sheet-cancel:active { background: var(--gray-200); }
  @keyframes sheet-fade { from { background: rgba(0,0,0,0); } to { background: rgba(0,0,0,0.45); } }
  @keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

  /* Checklist controls */
  .cl-controls { margin-bottom: 14px; }
  .cl-controls .form-group { min-width: 100% !important; }
  .cl-header { padding: 12px 14px; }
  .cl-body { padding: 12px 14px; }
  .cl-item { padding: 10px 6px; min-height: 44px; }
  .cl-item input[type="checkbox"] { width: 20px; height: 20px; margin-top: 1px; }
  .cl-item .cl-text { font-size: 14px; }
  .cl-item-remove { opacity: 1; color: var(--gray-400); padding: 4px 8px; }

  /* Sec-head com botões — botões viram grid 2 colunas */
  .sec-head > div[style*="flex"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 6px !important;
    width: 100%;
  }
  .sec-head > div[style*="flex"] .btn {
    flex: 1;
    justify-content: center;
    padding: 9px 10px;
    font-size: 12px;
  }

  /* Filtros: nas abas Protocolos e Modelos vira select nativo em mobile.
     Na aba Empresas (3 filtros) mantém chips (cabem confortavelmente). */
  #tab-protocolos .filter-bar,
  #tab-modelos .filter-bar { display: none; }
  #tab-protocolos .filter-select,
  #tab-modelos .filter-select { display: block; flex: 1; min-width: 0; }

  /* Empresas: chips com scroll horizontal + fade à direita */
  #tab-empresas .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent);
            mask-image: linear-gradient(to right, black calc(100% - 24px), transparent);
  }
  #tab-empresas .filter-bar::-webkit-scrollbar { display: none; }
  #tab-empresas .flt-btn { flex-shrink: 0; scroll-snap-align: start; }
  #tab-empresas .filter-bar > span:first-child { display: none; }

  /* Modelos e IA */
  .modelo-card { padding: 12px 14px; }
  .modelo-title { font-size: 14px; }
  .modelo-actions { width: 100%; margin-top: 8px; }
  .modelo-actions .btn { flex: 1; justify-content: center; }
  .ai-section { padding: 14px; margin-bottom: 12px; }
  .ai-prov-list { grid-template-columns: 1fr; }
  .ai-prompt-txt { min-height: 180px; font-size: 13px; }
  .ai-run-preview { min-height: 200px; max-height: 300px; }

  /* Container "flex" com botões no topo de contratos/empresas/modelos/protocolos */
  #tab-contratos > div:first-child,
  #tab-empresas > div:first-child,
  #tab-modelos > div:first-child,
  #tab-protocolos > div:first-child {
    flex-direction: column;
    align-items: stretch !important;
  }
  #tab-contratos > div:first-child .btn,
  #tab-empresas > div:first-child .btn,
  #tab-modelos > div:first-child .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 14px;
    min-height: 44px;
  }

  /* Toast fica embaixo pra não colidir com header */
  #toast-container { top: auto; bottom: 80px; left: 12px; right: 12px; }
  .toast { min-width: auto; max-width: 100%; font-size: 13px; }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE PEQUENO — <=380px (iPhone SE)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
  header { padding: 10px 12px; }
  header h1 { font-size: 14px; }
  .tab-content { padding: 10px 10px 20px; }
  .stats-grid { grid-template-columns: 1fr; }
  .nav-mobile-tab .nm-lbl { font-size: 10px; }
  .btn-hero { padding: 12px 14px; min-height: 56px; }
  .btn-hero .h-title { font-size: 13px; }
  .btn-hero .h-sub { font-size: 10.5px; }
}

@media print {
  header .hdr-badge, header .hdr-btn, nav, .nav-mobile, .filter-bar, .btn, .ccard-actions, .sec-head .btn, .doc-espec-strip .btn { display: none !important; }
  .tab-content { display: block !important; padding: 0 !important; }
  body { background: white !important; padding-bottom: 0 !important; }
  .mobile-sheet-overlay { display: none !important; }
}

/* ─── Modo leitura: gestor vendo a fiscalização de outra pessoa ─── */
#viewing-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; padding: 9px 18px; background: var(--warning-light);
  color: #92400e; font-size: 13px; border-bottom: 1px solid #fcd34d;
}

/* Esconde os pontos de entrada de escrita. Isto é cosmética: quem impede a
   gravação de verdade é o guarda em saveLocal()/cloudPush() e o RLS.
   Casa pelo verbo da ação em vez de listar botão a botão — enumerar deixou
   emp-delete, cl-clear e os prompts de IA visíveis na primeira versão. */
body.modo-leitura [data-action^="hero-"],
body.modo-leitura [data-action^="edit-"],
body.modo-leitura [data-action*="-new"],
body.modo-leitura [data-action*="-edit"],
body.modo-leitura [data-action*="-delete"],
body.modo-leitura [data-action*="-del-"],
body.modo-leitura [data-action*="-add"],
body.modo-leitura [data-action*="-save"],
body.modo-leitura [data-action*="-clear"],
body.modo-leitura [data-action*="-restore"],
body.modo-leitura [data-action*="-reset"],
body.modo-leitura [data-action^="ai-run-"],
body.modo-leitura [data-action="desp-gerar"],
body.modo-leitura [data-action="cl-finalize"],
body.modo-leitura [data-action="cl-open-parecer"],
body.modo-leitura [data-action="emp-mod-open"],
body.modo-leitura [data-action="rel-open-config"],
body.modo-leitura [data-action="import-json-pick"],
body.modo-leitura [data-action="mobile-import"],
body.modo-leitura [data-action="open-user-config"],
body.modo-leitura [data-action="mobile-user-config"],
body.modo-leitura [data-action="doc-espec-open"],
body.modo-leitura [data-action="upd-open"],
body.modo-leitura [data-action="de-import-list"] { display: none !important; }

/* Considerações do relatório: leitura, não edição. Um dia o gestor escreve
   aqui — hoje digitar só perderia o texto no primeiro save() bloqueado. */
body.modo-leitura #rel-consid { background: var(--gray-100); cursor: not-allowed; }

/* Equipe */
.equipe-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--gray-200); border-radius: 9px; margin-bottom: 8px;
}
.equipe-card-main { flex: 1; min-width: 0; }
.equipe-card-nome { font-weight: 600; }
.equipe-card-sub { font-size: 12.5px; color: var(--gray-500); margin-top: 2px; }

/* Texto do despacho dentro do histórico */
.history-despacho { margin-top: 8px; }
.history-despacho summary {
  cursor: pointer; font-size: 11.5px; color: var(--primary); user-select: none;
}
.history-despacho pre {
  margin-top: 7px; padding: 10px 12px; background: var(--gray-100);
  border-radius: 7px; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, monospace; font-size: 11.5px; line-height: 1.5;
}

/* Relatório de Ações por Período */
.ra-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ra-chip {
  padding: 5px 11px; border-radius: 999px; background: var(--gray-100);
  font-size: 12px; color: var(--gray-600);
}
.ra-chip b { color: var(--primary); }
.ra-lista { max-height: 340px; overflow-y: auto; border: 1px solid var(--gray-200); border-radius: 9px; }
.ra-item { padding: 10px 13px; border-bottom: 1px solid var(--gray-200); }
.ra-item:last-child { border-bottom: 0; }
.ra-item-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.ra-item-acao { font-weight: 600; font-size: 12.5px; }
.ra-item-at { font-size: 11px; color: var(--gray-500); white-space: nowrap; }
.ra-item-origem { font-size: 11.5px; color: var(--primary); margin-top: 2px; }
.ra-item-det { font-size: 11.5px; color: var(--gray-600); margin-top: 3px; line-height: 1.45; }


}

/* ─── Espaço da Gestão ─── */
.gestao-alerta {
  background: var(--danger-light); border-left: 4px solid var(--danger);
  border-radius: 8px; padding: 11px 14px; margin-bottom: 14px; font-size: 13px; color: #7f1d1d;
}
.gestao-alerta .ga-item { font-size: 12px; margin-top: 5px; opacity: .9; }

.pend-card, .gc-card, .gd-card {
  display: flex; align-items: flex-start; gap: 12px;
  border: 1px solid var(--gray-200); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 9px; background: white;
}
.pend-vencida { border-color: var(--danger); background: var(--danger-light); }
.pend-ok { opacity: .7; }
.pend-main, .gc-main { flex: 1; min-width: 0; }
.pend-assunto, .gc-titulo { font-weight: 600; font-size: 13.5px; }
.pend-sub, .gc-sub { font-size: 12px; color: var(--gray-500); margin-top: 3px; }
.pend-prazo { font-size: 12px; margin-top: 5px; }
.pend-vencida .pend-prazo { color: var(--danger); font-weight: 600; }
.pend-tipo { background: var(--gray-100); border-radius: 999px; padding: 1px 8px; font-size: 10.5px; }
.pend-acoes { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.gc-obj { font-size: 12.5px; color: var(--gray-700); margin-top: 4px; line-height: 1.45; }
.gc-sit { font-size: 10.5px; padding: 2px 8px; border-radius: 999px; margin-left: 6px; font-weight: 500; }
.gc-sit-formalizacao { background: var(--warning-light); color: #92400e; }
.gc-sit-vigente { background: var(--success-light, #d1fae5); color: #065f46; }
.gc-sit-encerrado { background: var(--gray-100); color: var(--gray-600); }
.gd-data { font-size: 11.5px; color: var(--gray-500); font-weight: 400; margin-left: 6px; }

@media (max-width: 768px) {
  .pend-card, .gc-card, .gd-card { flex-direction: column; }
  .pend-acoes { width: 100%; justify-content: flex-end; }
}

/* ─── Painel do grupo (espelha o controle do Excel) ─── */
.pg-toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-bottom: 12px; font-size: 12.5px; color: var(--gray-600); }
.pg-toolbar select { margin-left: 6px; }
.pg-sync { margin-left: auto; font-size: 11.5px; color: var(--gray-500); }

.pg-totais { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.pg-totais > div { flex: 1 1 130px; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 9px; padding: 9px 12px; }
.pg-totais span { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--gray-500); }
.pg-totais b { font-size: 14px; }
.pg-totais .pg-saldo { background: var(--success-light); border-color: #a7f3d0; }
.pg-totais .pg-saldo b { color: #065f46; }

.pg-fiscal-bloco { margin-bottom: 22px; }
.pg-fiscal-nome { font-weight: 600; font-size: 13px; color: var(--primary); margin-bottom: 9px; }

.pg-card { border: 1px solid var(--gray-200); border-left: 4px solid var(--gray-300); border-radius: 10px; padding: 13px 15px; margin-bottom: 10px; background: white; }
.pg-card.pg-critico { border-left-color: var(--danger); }
.pg-card.pg-alerta  { border-left-color: #f59e0b; }
.pg-card.pg-ok      { border-left-color: var(--success); }

.pg-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.pg-num { font-weight: 700; font-size: 14px; }
.pg-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.pg-badge { font-size: 10.5px; padding: 2px 8px; border-radius: 999px; margin-left: 6px; font-weight: 500; }
.pg-badge-critico { background: var(--danger-light); color: #7f1d1d; }
.pg-badge-alerta  { background: var(--warning-light); color: #92400e; }
.pg-badge-ok      { background: var(--success-light); color: #065f46; }
.pg-badge-nd      { background: var(--gray-100); color: var(--gray-600); }
.pg-sync-col { text-align: right; font-size: 10.5px; color: var(--gray-500); line-height: 1.5; white-space: nowrap; }
.pg-sync-col b { color: var(--gray-700); font-size: 11px; }

.pg-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 9px; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--gray-100); font-size: 12.5px; }
.pg-meta span { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--gray-500); }
.pg-meta-fin { border-top: 0; padding-top: 0; }

.pg-emp { margin-top: 11px; }
.pg-emp summary { cursor: pointer; font-size: 11.5px; color: var(--primary); user-select: none; }
.pg-emp-tabela { overflow-x: auto; margin-top: 9px; }
.pg-emp-tabela table { width: 100%; border-collapse: collapse; font-size: 11.5px; min-width: 620px; }
.pg-emp-tabela th { text-align: left; padding: 6px 8px; background: var(--gray-50); color: var(--gray-500); font-size: 10.5px; text-transform: uppercase; letter-spacing: .3px; }
.pg-emp-tabela td { padding: 6px 8px; border-top: 1px solid var(--gray-100); }
.pg-emp-tabela .pg-obs { color: var(--gray-500); }

@media (max-width: 768px) {
  .pg-head { flex-direction: column; }
  .pg-sync-col { text-align: left; }
  .pg-sync { margin-left: 0; width: 100%; }
}

/* Livro de medições dentro do card do contrato (painel do grupo) */
.pg-med { margin-top: 8px; }
.pg-med summary { cursor: pointer; font-size: 11.5px; color: var(--primary); user-select: none; }
.pg-med .pg-emp-tabela table { min-width: 820px; }
.pg-med .badge { font-size: 10px; padding: 1px 7px; }

/* ─── Chat: Orientações e Discussões ─── */
.chat-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 0; height: 520px; border: 1px solid var(--gray-200); border-radius: 10px; overflow: hidden; }
.chat-lista { border-right: 1px solid var(--gray-200); overflow-y: auto; background: var(--gray-50); padding: 8px; }
.chat-vazio { color: var(--gray-500); font-size: 12.5px; padding: 14px; text-align: center; }

.chat-conv { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 9px 11px; cursor: pointer; margin-bottom: 3px; }
.chat-conv:hover { background: var(--gray-100); }
.chat-conv.ativa { background: white; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.chat-conv-topo { display: flex; align-items: center; gap: 6px; }
.chat-conv-nome { font-weight: 600; font-size: 12.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-conv-at { font-size: 10.5px; color: var(--gray-500); }
.chat-conv-previa { font-size: 11.5px; color: var(--gray-500); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-conv-sub { font-size: 10px; color: var(--gray-400); margin-top: 1px; text-transform: uppercase; letter-spacing: .3px; }
.chat-nao-lidas { background: var(--danger); color: white; font-size: 10.5px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }

.chat-janela { display: flex; flex-direction: column; min-width: 0; background: white; }
.chat-topo { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--gray-200); font-size: 13px; }
.chat-topo-sub { font-size: 11px; color: var(--gray-500); font-weight: 400; margin-left: 6px; }
.chat-voltar { display: none; background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--gray-600); }

.chat-mensagens { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.chat-dia { align-self: center; font-size: 10.5px; color: var(--gray-500); background: var(--gray-100); padding: 2px 10px; border-radius: 999px; margin: 6px 0; }
.chat-msg { display: flex; }
.chat-msg-eu { justify-content: flex-end; }
.chat-bolha { max-width: 76%; background: var(--gray-100); border-radius: 12px; padding: 8px 11px; }
.chat-msg-eu .chat-bolha { background: #dbeafe; }
.chat-autor { font-size: 11px; font-weight: 600; color: var(--primary); margin-bottom: 2px; }
.chat-texto { font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.chat-rodape { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 3px; font-size: 10px; color: var(--gray-500); }
.chat-del { background: none; border: 0; cursor: pointer; font-size: 10px; opacity: .5; }
.chat-del:hover { opacity: 1; }

.chat-compose { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--gray-200); }
.chat-compose textarea { flex: 1; resize: none; }
.chat-compose .btn { padding: 9px 15px; }

/* Contador de não lidas em abas e no menu */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px; padding: 0 5px; margin-left: 6px; border-radius: 999px; background: var(--danger); color: white; font-size: 10px; font-weight: 700; line-height: 1; }

@media (max-width: 768px) {
  .chat-wrap { grid-template-columns: 1fr; height: 68vh; position: relative; }
  .chat-lista { border-right: 0; }
  .chat-janela { position: absolute; inset: 0; transform: translateX(100%); transition: transform .18s ease; }
  .chat-janela.aberta { transform: translateX(0); }
  .chat-voltar { display: block; }
  .chat-bolha { max-width: 86%; }
}

/* ═══ DEMANDAS AO GESTOR ═══ */
.dem-card {
  background: white; border: 1px solid var(--gray-200); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px;
}
.dem-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.dem-assunto { font-size: 15px; font-weight: 700; color: var(--gray-900); line-height: 1.35; }
.dem-refs { font-size: 12px; color: var(--gray-600); margin-top: 5px; }
.dem-texto { font-size: 13.5px; color: var(--gray-700); line-height: 1.55; margin-top: 8px; white-space: pre-wrap; }
.dem-meta { font-size: 11.5px; color: var(--gray-500); margin-top: 8px; }
.dem-thread { margin-top: 12px; border-top: 1px dashed var(--gray-200); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.dem-and { font-size: 12.5px; color: var(--gray-700); line-height: 1.45; background: var(--gray-50); border-radius: 8px; padding: 7px 10px; }
.dem-and-tipo { font-weight: 700; margin-right: 6px; }
.dem-and-txt { color: var(--gray-800); }
.dem-and-meta { display: block; font-size: 10.5px; color: var(--gray-400); margin-top: 3px; }
.dem-acoes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.b-cat { background: var(--gray-100); color: var(--gray-700); }
.b-enviada { background: var(--gray-100); color: var(--gray-600); }
.b-ciente { background: #dbeafe; color: #1e40af; }
.b-andamento { background: #fef3c7; color: #92400e; }
.b-resolvida { background: var(--success-light); color: #065f46; }
.b-alta { background: #ffedd5; color: #9a3412; }
.b-urgente { background: var(--danger-light); color: var(--danger); }

/* ═══════════════════════════════════════════════════════════════
   MODO ESCURO — ativado por data-theme="dark" no <html>.
   Estratégia: inverte a escala de cinza (texto claro, fundo escuro)
   e remapeia as superfícies brancas. Badges/alertas seguem claros
   (pílula clara sobre fundo escuro) — legíveis e destacados.
   ═══════════════════════════════════════════════════════════════ */
:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: #60a5fa; --primary-light: #1e3a5f; --primary-dark: #3b82f6;
  --gray-50:#1b2436; --gray-100:#212c40; --gray-200:#324056;
  --gray-300:#415068; --gray-400:#6b7a92; --gray-500:#9aa7bd;
  --gray-600:#b9c4d6; --gray-700:#d6dded; --gray-900:#f2f5fb;
  --surface:#1b2436;
  --page-bg:#0f1526;
}
:root[data-theme="dark"] body { background: var(--page-bg); }
:root[data-theme="dark"] nav,
:root[data-theme="dark"] .section,
:root[data-theme="dark"] .stat-card,
:root[data-theme="dark"] .modal,
:root[data-theme="dark"] .ccard,
:root[data-theme="dark"] .emp-card,
:root[data-theme="dark"] .dem-card,
:root[data-theme="dark"] .modelo-card,
:root[data-theme="dark"] .ai-prompt-card,
:root[data-theme="dark"] .ai-section,
:root[data-theme="dark"] .pcard,
:root[data-theme="dark"] .pg-card,
:root[data-theme="dark"] .rel-preview,
:root[data-theme="dark"] .meta-grid,
:root[data-theme="dark"] .emp-section,
:root[data-theme="dark"] .cl-body,
:root[data-theme="dark"] .obs-strip,
:root[data-theme="dark"] .chat-janela,
:root[data-theme="dark"] .chat-lista,
:root[data-theme="dark"] .import-box,
:root[data-theme="dark"] .btn-secondary,
:root[data-theme="dark"] .flt-btn { background: var(--surface); color: var(--gray-700); }
:root[data-theme="dark"] .modal-head,
:root[data-theme="dark"] .sec-head { background: #151d2c; }
:root[data-theme="dark"] select,
:root[data-theme="dark"] input[type="text"],
:root[data-theme="dark"] input[type="email"],
:root[data-theme="dark"] input[type="password"],
:root[data-theme="dark"] input[type="number"],
:root[data-theme="dark"] input[type="date"],
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .filter-select { background: #0f1526; color: var(--gray-900); border-color: var(--gray-300); }
:root[data-theme="dark"] .rel-preview .rel-doc { color: var(--gray-900); }
:root[data-theme="dark"] .toast { background: #212c40; color: var(--gray-900); }
:root[data-theme="dark"] .login-gate { background: linear-gradient(150deg, #0f1526 0%, #1b2436 60%, #223052 100%); }
:root[data-theme="dark"] .flt-btn.active { background: var(--primary); color: #0f1526; border-color: var(--primary); }
:root[data-theme="dark"] .p-item-chip,
:root[data-theme="dark"] .ra-chip { background: #212c40; color: var(--gray-700); }

/* Configurações — switches e indicador de nuvem no header */
.cfg-switch { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--gray-700); cursor: pointer; user-select: none; }
.cfg-switch input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.hdr-cloud-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gray-400); display: inline-block; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(255,255,255,0.25); }
.hdr-cloud-dot.on { background: #34d399; }
.hdr-cloud-dot.error { background: #f87171; }
.hdr-cloud-dot.syncing { animation: dot-pulse 1s ease-in-out infinite; }
@keyframes dot-pulse { 0%,100%{opacity:1;} 50%{opacity:0.35;} }

/* Modo escuro — menu "Mais opções" (bottom sheet) */
:root[data-theme="dark"] .mobile-sheet { background: var(--surface); }
:root[data-theme="dark"] .mobile-sheet-item { background: #151d2c; color: var(--gray-900); border-color: var(--gray-200); }
:root[data-theme="dark"] .mobile-sheet-item:active { background: var(--gray-100); }
:root[data-theme="dark"] .mobile-sheet-cancel { background: var(--gray-100); color: var(--gray-700); }

/* ── Modo escuro: correções finas (varredura) ──
   Painéis internos claros e textos coloridos fixos que sumiam/estouravam. */
:root[data-theme="dark"] .emp-contracts-section { background: #151d2c; border-top-color: var(--gray-200); }
:root[data-theme="dark"] .import-box { background: #241b3a; border-color: var(--purple); }
:root[data-theme="dark"] .import-box p { color: #c4b5fd; }
:root[data-theme="dark"] .import-box h4 { color: #c4b5fd; }
:root[data-theme="dark"] .cl-header { background: #17263f; }
:root[data-theme="dark"] .cl-header p { color: #9db4de; }
:root[data-theme="dark"] .rel-totais { background: #2e2a12; border-left-color: #a16207; color: var(--gray-700); }
:root[data-theme="dark"] .rel-totais b { color: #fde68a; }
:root[data-theme="dark"] .obs-strip { background: #2e2712; color: #fcd34d; }
:root[data-theme="dark"] .ai-placeholders code { background: #0f1526; color: #93c5fd; }
:root[data-theme="dark"] .doc-espec-strip { background: #241b3a; }
:root[data-theme="dark"] .doc-espec-strip .de-info { color: #c4b5fd; }
:root[data-theme="dark"] .pcard-obs { background: #151d2c; color: var(--gray-700); }
:root[data-theme="dark"] .pg-totais .pg-saldo { background: #12321f; border-color: #14532d; }
:root[data-theme="dark"] .pg-totais .pg-saldo b { color: #86efac; }
:root[data-theme="dark"] .chat-bolha { background: var(--gray-200); }
:root[data-theme="dark"] .chat-msg-eu .chat-bolha { background: #1e3a5f; }
:root[data-theme="dark"] .cl-body { color: var(--gray-900); }
