/*
 * ╔══════════════════════════════════════════════════════════════════╗
 * ║              CARTÓRIO DIGITAL — SISTEMA DE GESTÃO               ║
 * ║                                                                  ║
 * ║  © 2026 Pedro Rodrigues Neto — Todos os direitos reservados.   ║
 * ║  CPF: 521.396.702-72                                             ║
 * ║                                                                  ║
 * ║  Proibida reprodução ou uso comercial sem autorização expressa. ║
 * ║  Lei nº 9.610/98 (Direitos Autorais) · Lei nº 9.279/96 (PI)    ║
 * ╚══════════════════════════════════════════════════════════════════╝
 */

:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --card: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f4f7fb;
  --text: #0f172a;
  --muted: #334155;
  --line: #b9c6d4;
  --border: #b9c6d4;
  --accent: #075985;
  --accent-2: #0f766e;
  --danger: #b42318;
  --warn: #a15c00;
  --soft: #e7f2f8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* app-shell acts as the grid container (replaces body grid) */
#app-shell {
  display: none;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #102331;
  color: #fff;
  padding: 20px 14px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,.16);
}
#sidebar-collapse-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,.25);
  color: #b8c7d3;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11px;
  padding: 4px 7px;
  flex-shrink: 0;
  line-height: 1;
}
#sidebar-collapse-btn:hover { background: rgba(255,255,255,.12); color: #fff; }

.brand span { color: #b8c7d3; font-size: 13px; }

nav { display: grid; gap: 6px; margin-top: 18px; }

nav button {
  width: 100%;
  border: 0;
  background: transparent;
  color: #dce7ef;
  text-align: left;
  padding: 11px 12px;
  border-radius: 6px;
  cursor: pointer;
}

nav button.active, nav button:hover { background: #1d4055; color: #fff; }

.main { padding: 22px; overflow: auto; }

.main::before {
  content: "";
  position: fixed;
  inset: 0 0 0 260px;
  background: url("/static/brasao-pcsp.jpg") center 58% / min(42vw, 480px) auto no-repeat;
  opacity: .06;
  pointer-events: none;
  z-index: -1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.mobile-menu-btn,
.mobile-nav-backdrop {
  display: none;
}

h1, h2 { margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 18px; margin-bottom: 12px; }
p { color: var(--muted); margin: 6px 0 0; }

.view { display: none; }
.view.active { display: block; }
.plantao-tab { display: none; }
.plantao-tab.active { display: block; }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi, .panel, .form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.kpi span { color: var(--muted); font-size: 13px; }
.kpi strong { display: block; font-size: 30px; margin-top: 6px; }

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: rgba(255,255,255,.92);
}

.dashboard-eyebrow {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.dashboard-hero h2 {
  margin-bottom: 4px;
  font-size: 22px;
}

.dashboard-quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-detail-grid {
  margin-top: 16px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-title-row h2 {
  margin-bottom: 2px;
}

.panel-title-row p {
  font-size: 13px;
}

.panel-title-row button {
  min-height: 34px;
  padding: 7px 10px;
  white-space: nowrap;
}

.dashboard-kpi-card {
  position: relative;
  overflow: hidden;
  min-height: 112px;
}

.dashboard-kpi-card::after {
  content: "";
  position: absolute;
  inset: auto 12px 12px auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(23,107,135,.08);
}

.dashboard-kpi-card strong {
  font-size: 34px;
}

.dashboard-kpi-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.3;
}

.kpi-danger {
  border-color: #fecaca;
  background: #fff7f7;
}

.kpi-danger strong,
.kpi-danger span {
  color: var(--danger);
}

.kpi-warn {
  border-color: #fed7aa;
  background: #fffbf5;
}

.kpi-warn strong,
.kpi-warn span {
  color: var(--warn);
}

.kpi-info {
  border-color: #bae6fd;
  background: #f0f9ff;
}

.kpi-ok {
  border-color: #bbf7d0;
  background: #f7fff9;
}

.dashboard-card-list {
  display: grid;
  gap: 10px;
}

.dashboard-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-dashboard-item {
  border-left: 4px solid var(--accent);
  background: linear-gradient(90deg, rgba(23,107,135,.06), #fff 42%);
}

.admin-dashboard-item button {
  min-width: 96px;
}

.dashboard-card-list.compact .dashboard-item {
  grid-template-columns: 1fr;
}

.dashboard-item-title {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.dashboard-item-title strong {
  color: #0f172a;
}

.dashboard-item p {
  margin: 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.35;
}

.dashboard-item-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #e2e8f0;
  color: #334155;
}

.dashboard-tag.danger { background: #fee2e2; color: #991b1b; }
.dashboard-tag.warn { background: #ffedd5; color: #9a3412; }
.dashboard-tag.info { background: #e0f2fe; color: #075985; }
.dashboard-tag.ok { background: #dcfce7; color: #166534; }

.dashboard-task-chip {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 12px;
}

.dashboard-task-chip.needs-review {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
}

.dashboard-task-chip span {
  display: block;
  color: inherit;
}

.dashboard-pendency-item {
  border-left: 4px solid var(--accent);
}

.dashboard-pendency-item .dashboard-item-meta .dashboard-tag {
  min-height: 22px;
}

.dashboard-empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  text-align: center;
}

.dashboard-health {
  margin-bottom: 16px;
}

.dashboard-health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.dashboard-health-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.dashboard-health-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 24px;
}

.dashboard-health-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-health-track {
  height: 7px;
  margin-top: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.dashboard-health-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.nested-tabs {
  margin-top: -4px;
}

.nested-tabs button {
  min-height: 34px;
  padding: 7px 10px;
}

.list-summary {
  margin: 0 0 10px;
  color: #334155;
  font-size: 14px;
}

.subtabs button {
  border-color: #cbd5e1;
  background: #fff;
  color: #334155;
  white-space: nowrap;
}

.subtabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  background: #fff;
}

textarea { min-height: 72px; resize: vertical; }

button, .button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.dashboard-table {
  min-width: 0;
  table-layout: fixed;
}

.dashboard-table th,
.dashboard-table td {
  line-height: 1.25;
  padding: 9px 10px;
  overflow-wrap: anywhere;
}

.dashboard-table .prazo-badge {
  min-width: 98px;
}

.priorities-table th:nth-child(1),
.priorities-table td:nth-child(1) {
  width: 92px;
}

.priorities-table th:nth-child(2),
.priorities-table td:nth-child(2) {
  width: 22%;
}

.priorities-table th:nth-child(3),
.priorities-table td:nth-child(3) {
  width: 24%;
}

.priorities-table th:nth-child(4),
.priorities-table td:nth-child(4) {
  width: 92px;
}

.priorities-table th:nth-child(5),
.priorities-table td:nth-child(5) {
  width: 118px;
}

th, td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Última coluna (ações / botões) nunca trunca */
td:last-child, th:last-child {
  max-width: none;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

/* Coluna de número de procedimento (curta, fixa) */
td:first-child {
  min-width: 70px;
}

/* Células truncadas são clicáveis */
td { cursor: default; }
td:not(:last-child):not(:has(button)):not(:has(input)) { cursor: pointer; }

/* Popover de texto completo ao clicar em célula truncada */
.td-popup {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .88rem;
  color: var(--text);
  box-shadow: 0 6px 24px rgba(0,0,0,.22);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  max-height: 260px;
  overflow-y: auto;
}

th {
  background: #eef3f7;
  color: #334155;
  position: sticky;
  top: 0;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  background: #dfe8f0;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions button {
  min-height: 34px;
  padding: 7px 10px;
}

.row-actions .secondary {
  background: #edf7f6;
  border-color: #9ccfca;
  color: #0f5f59;
}

.pending-list {
  display: grid;
  gap: 6px;
  max-width: 520px;
}

.pending-list-empty {
  color: var(--muted);
  font-style: italic;
}

.pending-empty {
  display: inline-block;
  white-space: normal;
}

.procedimentos-inqueritos-table,
.procedimentos-operacionais-table,
.procedimentos-bo-table {
  min-width: 1120px;
  table-layout: fixed;
}

.procedimentos-inqueritos-table th,
.procedimentos-inqueritos-table td,
.procedimentos-operacionais-table th,
.procedimentos-operacionais-table td,
.procedimentos-bo-table th,
.procedimentos-bo-table td {
  max-width: none;
}

/* A primeira coluna e a checkbox de selecao em lote. As demais larguras
   precisam considerar esse deslocamento para nao abrir vazios na tabela. */
.procedimentos-inqueritos-table th:nth-child(1),
.procedimentos-inqueritos-table td:nth-child(1),
.procedimentos-operacionais-table th:nth-child(1),
.procedimentos-operacionais-table td:nth-child(1) {
  text-align: center;
  width: 38px;
}

.procedimentos-inqueritos-table th:nth-child(2),
.procedimentos-inqueritos-table td:nth-child(2),
.procedimentos-operacionais-table th:nth-child(2),
.procedimentos-operacionais-table td:nth-child(2) {
  width: 118px;
}

.procedimentos-inqueritos-table th:nth-child(3),
.procedimentos-inqueritos-table td:nth-child(3),
.procedimentos-operacionais-table th:nth-child(3),
.procedimentos-operacionais-table td:nth-child(3) {
  width: 128px;
}

.procedimentos-inqueritos-table th:nth-child(4),
.procedimentos-inqueritos-table td:nth-child(4),
.procedimentos-operacionais-table th:nth-child(4),
.procedimentos-operacionais-table td:nth-child(4) {
  text-align: center;
  width: 64px;
}

.procedimentos-inqueritos-table th:nth-child(5),
.procedimentos-inqueritos-table td:nth-child(5),
.procedimentos-operacionais-table th:nth-child(5),
.procedimentos-operacionais-table td:nth-child(5) {
  width: 112px;
}

.procedimentos-inqueritos-table th:nth-child(6),
.procedimentos-inqueritos-table td:nth-child(6),
.procedimentos-operacionais-table th:nth-child(6),
.procedimentos-operacionais-table td:nth-child(6) {
  width: 220px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.procedimentos-inqueritos-table th:nth-child(7),
.procedimentos-inqueritos-table td:nth-child(7),
.procedimentos-operacionais-table th:nth-child(7),
.procedimentos-operacionais-table td:nth-child(7) {
  width: 108px;
}

.procedimentos-inqueritos-table th:nth-child(8),
.procedimentos-inqueritos-table td:nth-child(8),
.procedimentos-operacionais-table th:nth-child(8),
.procedimentos-operacionais-table td:nth-child(8),
.procedimentos-inqueritos-table th:nth-child(9),
.procedimentos-inqueritos-table td:nth-child(9),
.procedimentos-operacionais-table th:nth-child(9),
.procedimentos-operacionais-table td:nth-child(9) {
  width: 106px;
}

#procedimentos-table.procedimentos-inqueritos-table th:last-child,
#procedimentos-table.procedimentos-inqueritos-table td:last-child,
#procedimentos-table.procedimentos-operacionais-table th:last-child,
#procedimentos-table.procedimentos-operacionais-table td:last-child,
#procedimentos-table.procedimentos-bo-table th:last-child,
#procedimentos-table.procedimentos-bo-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  width: 118px;
  min-width: 118px;
  background: #ffffff;
  box-shadow: -8px 0 12px rgba(15, 23, 42, 0.08);
}

#procedimentos-table.procedimentos-inqueritos-table th:last-child,
#procedimentos-table.procedimentos-operacionais-table th:last-child,
#procedimentos-table.procedimentos-bo-table th:last-child {
  z-index: 3;
  background: #dbeafe;
}

.procedimentos-bo-table th:nth-child(1),
.procedimentos-bo-table td:nth-child(1) {
  text-align: center;
  width: 38px;
}

.procedimentos-bo-table th:nth-child(2),
.procedimentos-bo-table td:nth-child(2) {
  width: 116px;
}

.procedimentos-bo-table th:nth-child(3),
.procedimentos-bo-table td:nth-child(3) {
  text-align: center;
  width: 64px;
}

.procedimentos-bo-table th:nth-child(4),
.procedimentos-bo-table td:nth-child(4) {
  width: 112px;
}

.procedimentos-bo-table th:nth-child(5),
.procedimentos-bo-table td:nth-child(5) {
  width: 220px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.procedimentos-bo-table th:nth-child(6),
.procedimentos-bo-table td:nth-child(6),
.procedimentos-bo-table th:nth-child(7),
.procedimentos-bo-table td:nth-child(7) {
  width: 150px;
}

.procedimentos-bo-table th:nth-child(8),
.procedimentos-bo-table td:nth-child(8),
.procedimentos-bo-table th:nth-child(9),
.procedimentos-bo-table td:nth-child(9),
.procedimentos-bo-table th:nth-child(10),
.procedimentos-bo-table td:nth-child(10) {
  width: 106px;
}

#procedimentos-table .row-actions {
  min-width: 104px;
}

.bulk-toolbar {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
  padding: 10px 12px;
}

.bulk-toolbar strong {
  color: #12324a;
  margin-right: auto;
}

#procedimentos-table th:first-child,
#procedimentos-table td:first-child {
  text-align: center;
  width: 42px;
  min-width: 42px;
}

.proc-row-check,
#proc-select-all-visible {
  cursor: pointer;
  height: 18px;
  width: 18px;
}

.plantao-active-card {
  background: #f8fbfd;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  color: #334155;
  margin: 0 0 12px;
  padding: 10px 12px;
}

.piece-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.piece-group {
  display: grid;
  gap: 10px;
}

.piece-group h3 {
  color: #0f172a;
  font-size: 15px;
  margin: 8px 0 0;
}

.piece-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.piece-highlight {
  outline: 3px solid rgba(14, 116, 144, .35);
  box-shadow: 0 0 0 6px rgba(14, 116, 144, .12);
}

.piece-card textarea,
.raw-textarea,
.rich-editor {
  min-height: 180px;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.35;
}

.piece-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.document-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 14px;
  align-items: end;
  padding: 10px 0;
}

.document-meta-grid span {
  color: var(--text);
  font-size: 13px;
}

.piece-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #f8fafc;
  padding: 6px;
  margin-top: 8px;
}

.piece-toolbar button {
  min-width: 34px;
  padding: 5px 8px;
}

.piece-toolbar + textarea,
.piece-toolbar + .rich-editor {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.rich-editor {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 12px 14px;
  outline: none;
  resize: vertical;
  overflow: auto;
  white-space: normal;
}

.rich-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 111, 135, 0.12);
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.rich-editor p {
  margin: 0 0 10px;
}

.rich-editor ul,
.rich-editor ol {
  margin: 8px 0 8px 24px;
  padding: 0;
}

.model-upload {
  background: #f8fafc;
  border: 1px dashed var(--line);
  border-radius: 6px;
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
}

.model-upload label {
  color: #334155;
  font-size: 13px;
}

.model-upload input {
  margin-top: 4px;
}

.model-upload small {
  color: var(--muted);
}

.modelo-sugestoes {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  border-radius: 6px;
  padding: 10px;
  margin: 8px 0;
}

.modelo-sugestoes-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  color: #1e3a8a;
  font-size: 13px;
  margin-bottom: 8px;
}

.modelo-sugestoes-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.variable-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid #93c5fd;
  border-radius: 999px;
  background: #fff;
  color: #1e40af;
  font-size: 12px;
  padding: 4px 8px;
}

.mini-actions {
  margin-top: 8px;
}

.piece-card.piece-done { border-color: #bbf7d0; background: #f0fdf4; }
.piece-card.piece-empty { opacity: .55; }
.piece-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.piece-head h4 { margin: 0; font-size: 14px; flex: 1; }
.piece-num {
  background: var(--accent);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.badge-ok {
  background: #dcfce7;
  color: #15803d;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.section-head {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0 0 4px;
}

.pending-item {
  align-items: start;
  display: grid;
  gap: 7px;
  grid-template-columns: 30px minmax(0, 1fr);
  line-height: 1.25;
}

.pending-item small {
  color: var(--muted);
  display: block;
  grid-column: 2;
  margin-top: 3px;
}

.diligencia-check {
  background: #fff;
  border-color: #94a3b8;
  color: #176b87;
  font-size: 11px;
  font-weight: 700;
  min-height: 24px;
  padding: 0;
  width: 30px;
}

.diligencia-check:hover {
  background: #edf7f6;
  border-color: #176b87;
}

.report-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}

.search-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.search-actions {
  align-items: end;
}

tr:hover td { background: #fafcff; }

.badge {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 99px;
  font-size: 12px;
  background: #e8eef4;
  white-space: nowrap;
}

.verde { background: #dff6e5; color: #14532d; }
.amarelo { background: #fff2b8; color: #713f12; }
.laranja { background: #ffe0bd; color: #8a3a00; }
.vermelho { background: #ffd4d0; color: #8b1a10; }
.preto { background: #141414; color: #fff; }

.prazo-badge {
  border-radius: 6px;
  display: inline-block;
  font-weight: 700;
  min-width: 92px;
  padding: 5px 8px;
  text-align: center;
  white-space: nowrap;
}

.prazo-vencido {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.prazo-alerta {
  background: #fef3c7;
  border: 1px solid #facc15;
  color: #854d0e;
}

.prazo-ok {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}

.prazo-sem {
  background: #e5e7eb;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-weight: 600;
}

.prazo-aberto {
  background: #e0f2fe;
  border: 1px solid #7dd3fc;
  color: #075985;
  font-weight: 700;
}

.form { margin-top: 14px; display: grid; gap: 12px; }
.form.compact { margin-bottom: 14px; }
.form-help {
  background: #f8fbfd;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  color: #334155;
  display: grid;
  gap: 4px;
  line-height: 1.4;
  padding: 10px 12px;
}

.form-help strong { color: #102331; }
.form-help span { color: var(--muted); font-size: 13px; }
.form-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 12px;
}

.form-section legend {
  color: #102331;
  font-weight: 700;
  padding: 0 6px;
}

.pdf-import-box {
  align-items: end;
  background: #fbfdff;
  border: 1px dashed #b8c7d3;
  border-radius: 6px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(260px, 1fr) auto minmax(180px, 1fr);
  padding: 10px;
}

.pdf-import-box span {
  color: var(--muted);
  font-size: 13px;
}
.hidden { display: none !important; }

#procedimento-form[data-tipo="Boletim de Ocorrencia"] [data-proc-field="processual"] {
  display: none !important;
}

#procedimento-form[data-tipo="Inquerito Policial"] [data-proc-field="bo-only"],
#procedimento-form[data-tipo="Termo Circunstanciado"] [data-proc-field="bo-only"],
#procedimento-form[data-tipo="Ato Infracional"] [data-proc-field="bo-only"],
#procedimento-form[data-tipo="Carta Precatoria"] [data-proc-field="bo-only"],
#procedimento-form[data-tipo="Procedimento Administrativo"] [data-proc-field="bo-only"],
#procedimento-form[data-tipo="Outro"] [data-proc-field="bo-only"] {
  display: none !important;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}
label { display: grid; gap: 5px; font-size: 13px; color: #475569; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.prazo-manual {
  align-self: end;
  min-height: 38px;
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  width: min(420px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(15, 23, 42, .35); }
dialog form { display: grid; gap: 14px; padding: 18px; }
pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
}
.hint { margin-bottom: 10px; }

/* Plantao - filtros da listagem */
.plantao-filters {
  margin-bottom: 14px;
  display: grid;
  gap: 12px;
  padding: 14px 16px;
}

.plantao-filters-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
}

.plantao-filters-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* Plantao - badge de status na listagem */
.plantao-status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.plantao-status-triagem     { background: #e0f2fe; color: #075985; }
.plantao-status-importado   { background: #f0fdf4; color: #14532d; }
.plantao-status-elaboracao  { background: #fef9c3; color: #713f12; }
.plantao-status-aguardando  { background: #fff7ed; color: #9a3412; }
.plantao-status-conferencia { background: #fae8ff; color: #6b21a8; }
.plantao-status-concluido   { background: #dcfce7; color: #166534; }
.plantao-status-arquivado   { background: #f1f5f9; color: #475569; }
.plantao-status-flagrante   { background: #fee2e2; color: #991b1b; }

.plantao-home-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.plantao-home-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.plantao-home-head h2 {
  margin: 2px 0 4px;
}

.section-eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.empty-state {
  border: 1px dashed #9fb4c8;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fbfd;
  padding: 18px;
  text-align: center;
}

.plantao-home-actions,
.plantao-occ-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.plantao-dashboard-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.plantao-kpi {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.plantao-kpi span,
.plantao-kpi small {
  color: var(--muted);
}

.plantao-kpi strong {
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}

.plantao-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 8px;
}

.plantao-flow button {
  display: grid;
  gap: 3px;
  text-align: left;
  border-color: #b6c7d8;
  background: #f8fbfd;
}

.plantao-flow button.active,
.plantao-flow button:hover {
  border-color: var(--accent);
  background: #e9f5f8;
}

.plantao-flow span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.plantao-ocorrencias-cards {
  display: grid;
  gap: 10px;
}

.plantao-occ-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.plantao-occ-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 111, 135, .12);
}

.plantao-occ-main {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
  display: grid;
  gap: 4px;
  cursor: pointer;
}

.plantao-occ-main:hover {
  background: transparent;
}

.plantao-occ-bo {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.plantao-occ-main strong {
  font-size: 16px;
}

.plantao-occ-main span,
.plantao-occ-main small {
  color: var(--muted);
}

.plantao-occ-side {
  display: grid;
  gap: 8px;
  justify-items: end;
}

#plantao-tab-ocorrencias > .table-wrap {
  display: none;
}

.resenha-modelo-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
  margin: 0 0 12px;
  max-width: 820px;
}

.resenha-modelo {
  max-width: 820px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  color: #111827;
}

.resenha-modelo .res-periodo {
  margin-bottom: 18px;
}

.resenha-modelo .res-data {
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

.resenha-modelo table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.resenha-modelo th,
.resenha-modelo td {
  border: 1px solid #d6dee8;
  padding: 6px 8px;
  vertical-align: middle;
}

.resenha-modelo th {
  background: #eef4fb;
  text-align: center;
}

.resenha-modelo .res-num {
  width: 42px;
  text-align: right;
  color: #334155;
}

.resenha-modelo .res-total {
  width: 110px;
  text-align: center;
}

.resenha-modelo .res-total input {
  width: 72px;
  text-align: center;
  border: 1px solid #aebed0;
  border-radius: 4px;
  padding: 4px;
}

.resenha-modelo .res-section td {
  background: #f8fafc;
  font-weight: 700;
}

.resenha-modelo .res-assinaturas {
  display: grid;
  gap: 18px;
  margin-top: 34px;
  font-weight: 700;
}

.plantao-whatsapp-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
  gap: .55rem;
  align-items: center;
  margin: 1rem 0;
}

.whatsapp-inbox {
  display: grid;
  gap: .75rem;
}

.whatsapp-msg-card {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  padding: .85rem 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
}

@media (max-width: 980px) {
  .plantao-home-head,
  .plantao-occ-card {
    grid-template-columns: 1fr;
  }

  .plantao-home-head {
    display: grid;
  }

  .plantao-dashboard-cards,
  .plantao-flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .plantao-occ-card {
    align-items: stretch;
  }

  .plantao-occ-side {
    justify-items: start;
  }
}

@media (max-width: 640px) {
  .plantao-dashboard-cards,
  .plantao-flow {
    grid-template-columns: 1fr;
  }

  .plantao-home-actions button,
  .plantao-occ-actions button {
    flex: 1 1 130px;
  }
}

.whatsapp-msg-head,
.whatsapp-msg-foot {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  align-items: flex-start;
}

.whatsapp-msg-head strong { display: block; color: var(--text); }
.whatsapp-msg-head span,
.whatsapp-msg-foot small { color: var(--muted); font-size: .84rem; }
.whatsapp-msg-card p { white-space: pre-wrap; margin: .65rem 0; color: var(--text); }
.whatsapp-msg-meta { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.status-pill { border-radius: 999px; padding: .16rem .55rem; font-size: .78rem; font-weight: 700; background: #e2e8f0; color: #334155; }
.status-novo { background: #dbeafe; color: #1d4ed8; }
.status-em_analise { background: #fef3c7; color: #92400e; }
.status-convertido, .status-vinculado { background: #dcfce7; color: #166534; }
.status-arquivado { background: #f1f5f9; color: #475569; }

@media (max-width: 760px) {
  .plantao-whatsapp-toolbar { grid-template-columns: 1fr; }
  .whatsapp-msg-head,
  .whatsapp-msg-foot { flex-direction: column; }
  .whatsapp-msg-foot .row-actions { width: 100%; }
  .whatsapp-msg-foot .row-actions button { flex: 1; }
}

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .main::before { inset: 0; background-size: min(70vw, 360px) auto; }
  nav { grid-template-columns: repeat(2, 1fr); }
  .grid.two, .kpis, .form-grid { grid-template-columns: 1fr; }
  .report-form { grid-template-columns: 1fr; }
  .search-form { grid-template-columns: 1fr; }
  .pdf-import-box { grid-template-columns: 1fr; }
  .topbar, .toolbar { flex-direction: column; align-items: stretch; }
  .plantao-filters-grid { grid-template-columns: 1fr 1fr; }
  .parte-card { padding: 10px; }
  .parte-quick-actions { flex-wrap: wrap; }
}

@media (max-width: 760px) {
  body {
    background-attachment: scroll;
    overflow-x: hidden;
  }

  body.mobile-nav-open {
    overflow: hidden;
  }

  #app-shell {
    grid-template-columns: 1fr !important;
    min-height: 100dvh;
    width: 100%;
  }

  .sidebar {
    position: fixed !important;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    max-width: 320px;
    height: 100dvh;
    padding: 16px 12px;
    transform: translateX(-105%);
    transition: transform .2s ease;
    z-index: 1000;
    box-shadow: 18px 0 40px rgba(15, 23, 42, .24);
  }

  body.mobile-nav-open .sidebar {
    transform: translateX(0);
  }

  .mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .42);
    z-index: 999;
  }

  body.mobile-nav-open .mobile-nav-backdrop {
    display: block;
  }

  .brand {
    padding: 6px 8px 14px;
  }

  nav {
    grid-template-columns: 1fr !important;
    overflow-y: auto;
    margin-top: 12px;
    padding-right: 2px;
  }

  nav button {
    min-height: 42px;
  }

  .sidebar-user {
    margin-top: 12px;
  }

  .main {
    width: 100%;
    min-width: 0;
    padding: 12px;
    overflow-x: hidden;
  }

  .main::before {
    inset: 0;
    background-size: min(78vw, 340px) auto;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    margin: -12px -12px 12px;
    padding: 10px 12px;
    background: rgba(244, 246, 248, .96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
  }

  .topbar > div {
    min-width: 0;
  }

  .topbar #refresh-btn {
    grid-column: 1 / -1;
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    width: auto;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
  }

  h1 {
    font-size: 20px;
    line-height: 1.2;
  }

  h2 {
    font-size: 16px;
  }

  p {
    font-size: 12px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .dashboard-hero,
  .dashboard-main-grid,
  .dashboard-health-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-hero {
    padding: 12px;
  }

  .dashboard-quick-actions,
  .panel-title-row {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-quick-actions button,
  .panel-title-row button {
    width: 100%;
  }

  .dashboard-item {
    grid-template-columns: 1fr;
  }

  .kpi,
  .panel,
  .form {
    padding: 12px;
    border-radius: 8px;
  }

  .kpi strong {
    font-size: 22px;
  }

  .grid.two,
  .form-grid,
  .report-form,
  .search-form,
  .pdf-import-box,
  .plantao-filters-grid,
  .relat-filter-grid,
  .relat-chart-grid {
    grid-template-columns: 1fr !important;
  }

  .toolbar,
  .plantao-filters-actions,
  .parte-toolbar,
  .parte-filter-row,
  .parte-card-header,
  .parte-card-info,
  .parte-quick-actions,
  .view-topbar,
  .topbar-actions,
  .topbar-filters,
  .relat-topbar,
  .relat-actions,
  .relat-chart-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .subtabs {
    margin-left: -12px;
    margin-right: -12px;
    padding: 0 12px 6px;
    scroll-snap-type: x proximity;
  }

  .subtabs button {
    width: auto;
    min-width: max-content;
    scroll-snap-align: start;
  }

  .pol-subtab-header {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .pol-subtab-header button {
    min-width: max-content;
  }

  .table-wrap {
    margin-left: -4px;
    margin-right: -4px;
    max-width: calc(100vw - 16px);
    border-radius: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
  }

  table {
    width: max-content;
    min-width: 780px;
    table-layout: auto;
    font-size: 13px;
  }

  .dashboard-table {
    min-width: 820px !important;
    table-layout: auto;
  }

  .dashboard-table th,
  .dashboard-table td {
    min-width: 120px;
    overflow-wrap: normal;
    word-break: normal;
  }

  .dashboard-table th:nth-child(1),
  .dashboard-table td:nth-child(1) {
    min-width: 150px;
  }

  .dashboard-table th:nth-child(2),
  .dashboard-table td:nth-child(2),
  .dashboard-table th:nth-child(3),
  .dashboard-table td:nth-child(3) {
    min-width: 180px;
  }

  .dashboard-table th:nth-child(5),
  .dashboard-table td:nth-child(5) {
    min-width: 150px;
  }

  #procedimentos-table {
    min-width: 1120px;
    table-layout: auto;
  }

  #procedimentos-table th,
  #procedimentos-table td {
    min-width: 120px;
    overflow-wrap: normal;
    word-break: normal;
  }

  #procedimentos-table th:nth-child(1),
  #procedimentos-table td:nth-child(1) {
    min-width: 42px;
  }

  #procedimentos-table th:nth-child(5),
  #procedimentos-table td:nth-child(5) {
    min-width: 120px;
  }

  #procedimentos-table th:last-child,
  #procedimentos-table td:last-child {
    min-width: 150px;
  }

  #procedimentos-table.procedimentos-inqueritos-table,
  #procedimentos-table.procedimentos-operacionais-table,
  #procedimentos-table.procedimentos-bo-table {
    min-width: 1120px;
  }

  #procedimentos-table.procedimentos-inqueritos-table th:nth-child(6),
  #procedimentos-table.procedimentos-inqueritos-table td:nth-child(6),
  #procedimentos-table.procedimentos-operacionais-table th:nth-child(6),
  #procedimentos-table.procedimentos-operacionais-table td:nth-child(6) {
    min-width: 220px;
    white-space: normal;
    overflow: visible;
  }

  th,
  td {
    padding: 8px;
    vertical-align: top;
  }

  button,
  .primary,
  .secondary,
  .danger,
  .btn-logout {
    min-height: 42px;
  }

  .toolbar button,
  .plantao-filters-actions button,
  .topbar-actions button,
  .view-topbar button,
  .relat-actions button,
  .relat-chart-toolbar button,
  .btn-logout {
    width: 100%;
  }

  .login-box {
    width: min(92vw, 420px);
  }

  .modal-content,
  .modal-card {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    overflow: auto;
  }
}

/* ================================================================
   ETAPA 2 – Partes
   ================================================================ */

.parte-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.parte-filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.parte-filter-row input,
.parte-filter-row select {
  flex: 1;
  min-width: 140px;
}

.collapse-panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  margin-bottom: 16px;
  overflow: hidden;
}

.collapse-panel.hidden { display: none; }

.panel-header {
  padding: 10px 14px;
  font-weight: 600;
  background: var(--surface-alt, #f8fafc);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.parte-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--surface);
}

.parte-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.parte-card-header strong {
  flex: 1;
  font-size: 15px;
}

.parte-badges-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 4px;
}

.parte-card-info {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted, #6b7280);
  margin-bottom: 10px;
}

.parte-quick-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.qa-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  transition: background 0.15s;
}

.qa-btn:hover { background: var(--surface-alt, #f0f4f8); }

.qa-active {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.qa-btn.danger-btn {
  border-color: #fca5a5;
  color: #b91c1c;
}

.qa-btn.danger-btn:hover { background: #fee2e2; }

/* ================================================================
   ETAPA 2 – Policiais
   ================================================================ */

.pol-subtab-header {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 14px;
}

.pol-subtab-header button {
  padding: 6px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 13px;
  color: var(--muted, #6b7280);
}

.pol-subtab-header button.active {
  border-bottom-color: var(--accent, #3b82f6);
  color: var(--accent, #3b82f6);
  font-weight: 600;
}

.pol-subtab { display: none; }
.pol-subtab.active { display: block; }

.pol-vincular-panel {
  background: var(--surface-alt, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 14px;
}

.pol-autocomplete-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 380px;
}

.pol-sugestoes {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  z-index: 50;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

.pol-sugestoes.hidden { display: none; }

.pol-sug-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.pol-sug-item:last-child { border-bottom: none; }
.pol-sug-item:hover { background: var(--surface-alt, #f0f4f8); }
.pol-sug-item small { color: var(--muted, #6b7280); margin-left: 6px; }
.pol-sug-empty { color: var(--muted, #6b7280); cursor: default; font-style: italic; }

.pol-freq-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.pol-freq-toolbar input,
.pol-freq-toolbar select {
  flex: 1;
  min-width: 140px;
}

/* ================================================================
   ETAPA 2 – Objetos
   ================================================================ */

.obj-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.obj-toolbar select {
  flex: 1;
  min-width: 140px;
}

.obj-condicional { display: block; }
.obj-condicional.hidden { display: none; }

/* ================================================================
   Utilitarios ETAPA 2
   ================================================================ */

.form-section-summary {
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  user-select: none;
}

.danger-btn {
  background: transparent;
  color: #b91c1c;
  border-color: #fca5a5;
}

.danger-btn:hover { background: #fee2e2; }

/* ================================================================
   RELATORIOS – tela
   ================================================================ */

.relat-screen-panel { position: relative; }

.relat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.relat-topbar h2 { margin: 0; }

.relat-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--line);
  margin-bottom: 18px;
}

.relat-tabs button {
  padding: 7px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 13px;
  color: var(--muted);
  border-radius: 4px 4px 0 0;
}

.relat-tabs button:hover { background: var(--bg); }

.relat-tabs button.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  background: var(--bg);
}

.relat-pane { display: none; }
.relat-pane.active { display: block; }

.relat-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.relat-filters label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
}

.relat-filters input,
.relat-filters select { min-width: 140px; }

#relat-print-area { display: none; }

/* ================================================================
   RELATORIOS – impressao
   ================================================================ */

/* Botão de impressão presente em todas as views */
.print-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  gap: 4px;
}
.print-btn:hover { background: #f0f6ff; border-color: var(--accent); color: var(--accent); }

/* ================================================================
   NARRATIVA
   ================================================================ */
.narrativa-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.narrativa-sections { display: grid; gap: 14px; }
.narr-block h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.narr-block textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  background: #f8fafc;
}
.narr-block textarea:focus { border-color: var(--accent); outline: none; background: #fff; }

/* ================================================================
   PECAS
   ================================================================ */
.pecas-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.pecas-toolbar { display: flex; align-items: center; gap: 10px; }
.badge-info {
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
}
.badge-info-subtle {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
}

.senha-alert {
  display: flex;
  gap: 10px;
  align-items: center;
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
}

.senha-alert span {
  color: #1e3a8a;
  font-size: 13px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.inline-check input {
  width: auto;
}

.senha-masked {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-weight: 700;
  letter-spacing: 2px;
}

.import-help {
  margin: 10px 0 12px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 13px;
  line-height: 1.4;
}

.import-result {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.import-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.import-summary-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.import-summary-card strong {
  display: block;
  font-size: 24px;
  color: #0f172a;
}

.import-summary-card span {
  color: var(--muted);
  font-size: 12px;
}

.import-result pre {
  margin: 0;
  white-space: pre-wrap;
}
.hint-text {
  font-size: 12px;
  color: var(--muted);
  border-left: 3px solid var(--line);
  padding: 6px 10px;
  margin-bottom: 14px;
  background: #f8fafc;
  border-radius: 0 4px 4px 0;
}
.pecas-categories { display: grid; gap: 18px; }
.peca-category { }
.peca-cat-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 0 0 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

/* ================================================================
   CHECKLIST
   ================================================================ */
.checklist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.checklist-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
}
.progress-bar-container {
  flex: 1;
  background: var(--line);
  border-radius: 8px;
  height: 10px;
  overflow: hidden;
  min-width: 100px;
}
.progress-bar {
  height: 10px;
  background: var(--accent-2);
  border-radius: 8px;
  transition: width .4s ease;
}
#checklist-progress-text { font-size: 12px; color: var(--muted); white-space: nowrap; }
.checklist-group { margin-bottom: 16px; }
.checklist-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 6px 10px;
  background: #f0f4f8;
  border-radius: 6px 6px 0 0;
  border: 1px solid var(--line);
  border-bottom: none;
}
.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-top: none;
  background: #fff;
  transition: background .15s;
}
.checklist-item:last-child { border-radius: 0 0 6px 6px; }
.checklist-item:hover { background: #f8fafc; }
.checklist-item.concluido { background: #f0fdf4; }
.checklist-item.concluido .chk-titulo { color: var(--muted); text-decoration: line-through; }
.chk-status-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  transition: all .15s;
}
.chk-status-btn.done { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.chk-titulo { flex: 1; font-size: 13px; }
.chk-badges { display: flex; gap: 4px; }
.badge-obrig {
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
}
.badge-cond {
  background: #fef3c7;
  color: #92400e;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
}
.chk-descricao { font-size: 11px; color: var(--muted); margin-left: 32px; padding-bottom: 4px; }

/* ================================================================
   TAREFAS
   ================================================================ */
.tarefas-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.tarefas-filtros {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.tarefas-filtros select {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}
.tarefa-filter-modal {
  max-width: 560px;
}
.tarefa-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.tarefa-filter-grid label {
  display: grid;
  gap: 5px;
  font-weight: 700;
}
.tarefa-filter-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 16px;
}
#tarefas-filtros-resumo {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--muted);
  font-size: 12px;
}
#tarefas-filtros-resumo.tarefas-filtros-ativo {
  color: var(--primary);
  font-weight: 700;
}
@media (max-width: 680px) {
  .tarefa-filter-grid {
    grid-template-columns: 1fr;
  }
}
.tarefa-prioridade-urgente { background: #fee2e2; color: #b91c1c; }
.tarefa-prioridade-alta { background: #fff3cd; color: #92400e; }
.tarefa-prioridade-normal { background: #e0f2fe; color: #0369a1; }
.tarefa-prioridade-baixa { background: #f0fdf4; color: #14532d; }

/* ================================================================
   PENDENCIAS
   ================================================================ */
.pendencias-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.pendencias-filtros {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.pendencias-filtros select {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}
.pend-card {
  border-left: 4px solid var(--line);
  border-radius: 0 6px 6px 0;
  background: #fff;
  margin-bottom: 6px;
  padding: 10px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  transition: box-shadow .15s;
}
.pend-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.pend-card.critica { border-left-color: #b91c1c; }
.pend-card.alta { border-left-color: #d97706; }
.pend-card.media { border-left-color: #ca8a04; }
.pend-card.baixa { border-left-color: #2563eb; }
.pend-card.resolvida { border-left-color: #16a34a; opacity: .7; }
.pend-card.nao-aplica { border-left-color: #94a3b8; opacity: .6; }
.pend-card.pergunta { border-left-color: #7c3aed; }
.pend-gravidade {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.pend-card.critica .pend-gravidade { background: #fee2e2; color: #b91c1c; }
.pend-card.alta .pend-gravidade { background: #ffedd5; color: #c2410c; }
.pend-card.media .pend-gravidade { background: #fef9c3; color: #854d0e; }
.pend-card.baixa .pend-gravidade { background: #dbeafe; color: #1d4ed8; }
.pend-card.pergunta .pend-gravidade { background: #ede9fe; color: #6d28d9; }
.pend-body { flex: 1; }
.pend-titulo { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.pend-descricao { font-size: 12px; color: var(--muted); }
.pend-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pend-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  border: 1px solid transparent;
}
.pend-badge.categoria { background: #f0f4f8; color: #475569; border-color: var(--line); }
.pend-badge.status-pendente { background: #fef3c7; color: #92400e; }
.pend-badge.status-andamento { background: #dbeafe; color: #1d4ed8; }
.pend-badge.status-resolvida { background: #dcfce7; color: #15803d; }
.pend-badge.status-nao-aplica { background: #f1f5f9; color: #64748b; }
.pend-actions { display: flex; gap: 4px; flex-direction: column; }
.pend-action-btn {
  padding: 3px 8px;
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fafc;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.pend-action-btn:hover { background: var(--soft); border-color: var(--accent); color: var(--accent); }
.pend-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 16px 0 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

/* ================================================================
   CONFERENCIA FINAL
   ================================================================ */
.conferencia-panel { }
.conferencia-actions { margin-bottom: 20px; }
.big-btn {
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 8px;
}
.conf-banner {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 16px;
}
.conf-banner.pronto { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.conf-banner.pendencias { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.conf-banner.critico { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.conf-banner.incompleto { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.conferencia-counts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.conf-count-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  text-align: center;
}
.conf-count-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}
.conf-count-label { font-size: 11px; color: var(--muted); margin-top: 2px; }
.conferencia-alertas { margin-bottom: 16px; }
.conf-alerta {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 5px;
  font-size: 13px;
}
.conf-alerta.error { background: #fee2e2; color: #b91c1c; }
.conf-alerta.warn { background: #fff7ed; color: #c2410c; }
.conf-alerta.info { background: #e0f2fe; color: #0369a1; }
.conf-alerta.ok { background: #f0fdf4; color: #15803d; }
.conf-alerta-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.conferencia-resumo-acoes { display: flex; gap: 8px; }

/* ================================================================
   VIEW TOPBAR (Diligencias, Objetos)
   ================================================================ */
.view-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ================================================================
   BADGE variants used in tables
   ================================================================ */
.badge-warn {
  background: #fef3c7;
  color: #92400e;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
}
.badge-danger {
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
}
.badge-muted {
  background: #f1f5f9;
  color: #64748b;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
}

/* ================================================================
   KPI color variants
   ================================================================ */
.kpi.kpi-ok { border-left: 3px solid #16a34a; }
.kpi.kpi-warn { border-left: 3px solid #d97706; }
.kpi.kpi-danger { border-left: 3px solid #b91c1c; }
.kpi.kpi-muted { border-left: 3px solid #94a3b8; }
.kpi.kpi-ok strong { color: #15803d; }
.kpi.kpi-warn strong { color: #92400e; }
.kpi.kpi-danger strong { color: #b91c1c; }
.kpi.kpi-muted strong { color: #64748b; }
.kpi.kpi-info { border-left: 3px solid #2563eb; }
.kpi.kpi-info strong { color: #1d4ed8; }

/* text helper */
.muted { color: var(--muted); }

/* ================================================================
   Modal overlay (movimentar objetos, etc.)
   ================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 14px 38px rgba(15, 23, 42, .28);
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px;
  width: min(720px, calc(100vw - 32px));
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
}
.modal-close:hover { color: var(--danger); }

.sync-ipe-note,
.sync-ipe-warning,
.sync-ipe-result {
  border: 1px solid #b8d7e8;
  background: #f1f8fc;
  border-radius: 8px;
  color: #12324a;
  line-height: 1.45;
  margin-top: 12px;
  padding: 12px 14px;
}

.sync-ipe-warning {
  border-color: #f0c47d;
  background: #fff7e8;
  color: #4d3410;
  margin-top: 0;
}

.sync-ipe-modal {
  max-width: 780px;
  width: min(780px, calc(100vw - 32px));
}

.sync-ipe-steps {
  display: grid;
  gap: 9px;
  line-height: 1.45;
  margin: 16px 0;
  padding-left: 22px;
}

.sync-ipe-steps li {
  padding-left: 4px;
}

.sync-ipe-script-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 14px;
  overflow: hidden;
}

.sync-ipe-script-header {
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  padding: 10px 12px;
}

.sync-ipe-script-textarea {
  background: #0f172a;
  border: 0;
  color: #dbeafe;
  display: block;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  height: 190px;
  line-height: 1.4;
  padding: 12px;
  resize: vertical;
  width: 100%;
}

/* ================================================================
   Login screen
   ================================================================ */
.login-screen {
  position: fixed;
  inset: 0;
  background: #0d1f2d url("/static/brasao-pcsp.jpg") center center / min(40vw, 480px) auto no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 2.2rem 2.4rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,.45);
}

.login-logo {
  display: grid;
  gap: 2px;
  text-align: center;
  margin-bottom: 1.6rem;
}
.login-logo strong {
  font-size: 1.35rem;
  color: #102331;
  letter-spacing: .5px;
}
.login-logo span {
  font-size: .82rem;
  color: var(--muted);
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: var(--danger);
  border-radius: 6px;
  padding: .5rem .75rem;
  font-size: .85rem;
  margin-bottom: .8rem;
}

/* ================================================================
   Alto contraste e janelas opacas
   ================================================================ */
.main,
.view,
.panel,
.form,
.kpi,
.table-wrap,
.piece-card,
.collapse-panel,
.search-form,
.pdf-import-box,
.plantao-active-card,
.dashboard-item,
.dashboard-health-card,
.login-box {
  background-color: #ffffff;
  color: var(--text);
}

.main {
  background: var(--bg);
}

p,
.muted,
.hint-text,
small,
label small,
.form-help span,
.dashboard-item p,
.dashboard-item-meta {
  color: var(--muted) !important;
}

label,
legend,
th,
td,
input,
select,
textarea,
button,
.button {
  color: var(--text);
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid #9aaabd;
  color: #0f172a;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, .04);
}

input:focus,
select:focus,
textarea:focus {
  border-color: #075985;
  box-shadow: 0 0 0 3px rgba(7, 89, 133, .18);
  outline: none;
}

button,
.button {
  background: #ffffff;
  border-color: #94a3b8;
  color: #0f172a;
  font-weight: 700;
}

button:hover,
.button:hover {
  background: #f1f5f9;
  border-color: #64748b;
}

.primary,
button.primary,
#new-proc-btn,
#backup-btn,
#confirm-import,
#preview-import,
#nova-tarefa-btn,
#tarefas-nova-btn,
#nova-guia-btn,
#novo-objeto-btn,
#nova-diligencia-btn,
#nova-senha-btn,
#relat-excel-btn,
#relat-print-btn {
  background: #075985;
  border-color: #075985;
  color: #ffffff;
}

.primary:hover,
button.primary:hover,
#new-proc-btn:hover,
#backup-btn:hover,
#confirm-import:hover,
#preview-import:hover,
#nova-tarefa-btn:hover,
#tarefas-nova-btn:hover,
#nova-guia-btn:hover,
#novo-objeto-btn:hover,
#nova-diligencia-btn:hover,
#nova-senha-btn:hover,
#relat-excel-btn:hover,
#relat-print-btn:hover {
  background: #0c4a6e;
  border-color: #0c4a6e;
  color: #ffffff;
}

.secondary,
.row-actions .secondary {
  background: #e0f2fe;
  border-color: #0284c7;
  color: #075985;
}

.danger,
.danger-btn,
button[onclick*="Excluir"],
button[onclick*="remove"],
button[onclick*="delete"] {
  background: #fff1f2;
  border-color: #e11d48;
  color: #9f1239;
}

th {
  background: #dbeafe;
  color: #0f172a;
  font-weight: 800;
}

td {
  color: #0f172a;
  background: #ffffff;
}

tbody tr:nth-child(even) td {
  background: #f8fafc;
}

tbody tr:hover td {
  background: #eff6ff;
}

.badge,
.badge-ok,
.badge-warn,
.badge-danger,
.badge-muted,
.prazo-badge {
  font-weight: 800;
}

.modal-overlay,
.modal-backdrop,
#modal-tema,
#user-form-modal,
#tarefa-modal,
#prot-modal,
#movimentar-obj-modal,
#modal-cumprir-dilig,
#modal-encerrar-dilig,
#modal-retorno {
  background: rgba(15, 23, 42, .72) !important;
  backdrop-filter: none !important;
}

.modal-box,
.modal-content,
.modal-card,
.login-box,
[role="dialog"],
.dialog,
.popover,
.td-popup {
  background: #ffffff !important;
  border: 2px solid #334155 !important;
  color: #0f172a !important;
  box-shadow: 0 18px 55px rgba(15, 23, 42, .45) !important;
}

.modal-box h1,
.modal-box h2,
.modal-box h3,
.modal-content h1,
.modal-content h2,
.modal-content h3,
.modal-card h1,
.modal-card h2,
.modal-card h3 {
  color: #0f172a;
}

.modal-close {
  color: #334155;
  font-weight: 900;
}

.subtabs button {
  background: #ffffff;
  border-color: #9aaabd;
  color: #0f172a;
  font-weight: 700;
}

.subtabs button.active {
  background: #075985;
  border-color: #075985;
  color: #ffffff;
}

.sidebar {
  background: #071923;
}

nav button {
  color: #e5edf5;
}

nav button.active,
nav button:hover {
  background: #0e7490;
  color: #ffffff;
}

#login-form label {
  display: grid;
  gap: 4px;
  margin-bottom: .8rem;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
}
#login-form input {
  padding: .55rem .75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: .95rem;
  width: 100%;
}
#login-form input:focus { outline: 2px solid var(--accent); border-color: transparent; }
#login-btn { width: 100%; margin-top: .4rem; padding: .65rem; font-size: 1rem; }

/* ================================================================
   Sidebar user footer
   ================================================================ */
.sidebar-user {
  margin-top: auto;
  padding: 14px 10px 8px;
  border-top: 1px solid rgba(255,255,255,.16);
  display: grid;
  gap: 2px;
}
.sidebar-user span { font-size: .9rem; color: #e2eaf0; font-weight: 600; }
.sidebar-user small { font-size: .76rem; color: #8fa5b5; text-transform: capitalize; }
.btn-logout {
  margin-top: 8px;
  width: 100%;
  border: 1px solid rgba(255,255,255,.25);
  background: transparent;
  color: #b8c7d3;
  border-radius: 6px;
  padding: .35rem;
  cursor: pointer;
  font-size: .82rem;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.1); color: #fff; }

/* Make sidebar a flex column so user footer sticks to bottom */
.sidebar { display: flex !important; flex-direction: column; }
nav { flex: 1; overflow-y: auto; }

/* ── Protocolos ─────────────────────────────── */
/* ── Rodapé do sistema ───────────────────────── */
.app-footer {
  margin-top: 48px;
  padding: 14px 0 8px;
  border-top: 1px solid var(--line);
  font-size: .75rem;
  color: var(--muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.app-footer strong { color: var(--text); font-weight: 600; }
.app-footer-sep { opacity: .4; }

@media print { .app-footer { display: none !important; } }

#protocolo-print-area { display: none; }

/* ── Print 2 vias (Guia de Protocolo) ──────── */
@media print {
  /* Esconde tudo; o #relat-print-area (body > div) sobrescreve por especificidade de ID */
  body > * { display: none !important; }
  #protocolo-print-area {
    display: block !important;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10pt;
    color: #000;
    background: #fff;
    padding: 0;
    margin: 0;
  }
  .prot-via {
    border: 1.5pt solid #333;
    padding: 10mm 14mm;
    margin: 0;
    page-break-inside: avoid;
  }
  .prot-header { text-align: center; border-bottom: 1.5pt solid #333; padding-bottom: 5pt; margin-bottom: 8pt; }
  .prot-header .prot-org { font-size: 9pt; text-transform: uppercase; letter-spacing: .5pt; }
  .prot-header .prot-unit { font-size: 11pt; font-weight: bold; margin: 2pt 0; }
  .prot-header .prot-cartorio { font-size: 9pt; color: #444; }
  .prot-numero { font-size: 22pt; font-weight: bold; text-align: center; letter-spacing: 3pt; margin: 8pt 0 2pt; }
  .prot-numero-label { text-align: center; font-size: 8pt; text-transform: uppercase; letter-spacing: 1pt; color: #555; margin-bottom: 10pt; }
  .prot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6pt; margin-bottom: 6pt; }
  .prot-field { border-bottom: .5pt solid #bbb; padding-bottom: 3pt; }
  .prot-field.full { grid-column: 1 / -1; }
  .prot-field label { display: block; font-size: 7.5pt; text-transform: uppercase; letter-spacing: .3pt; color: #666; margin-bottom: 1pt; }
  .prot-field span { font-size: 10pt; }
  .prot-sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 24pt; margin-top: 14mm; }
  .prot-sig { text-align: center; }
  .prot-sig-line { border-top: .8pt solid #333; padding-top: 4pt; font-size: 8.5pt; }
  .prot-badge { text-align: right; margin-top: 6pt; border-top: .5pt dashed #aaa; padding-top: 4pt; font-size: 8.5pt; font-weight: bold; color: #555; }
  .prot-corte { text-align: center; padding: 3mm 0; font-size: 9pt; color: #888; }
}

@media print {
  #relat-print-area {
    display: block !important;
    font-family: "Times New Roman", Times, serif;
    font-size: 11pt;
    color: #000;
    padding: 10mm 14mm;
    margin: 0;
  }

  .relat-print-org {
    font-size: 11pt;
    text-align: center;
  }
  .relat-print-unit {
    font-size: 13pt;
    font-weight: bold;
    text-align: center;
    margin: 2pt 0;
  }
  .relat-print-cartorio {
    font-size: 11pt;
    text-align: center;
    margin-bottom: 8pt;
  }
  .relat-print-title {
    font-size: 15pt;
    font-weight: bold;
    text-align: center;
    margin: 8pt 0 4pt;
    text-transform: uppercase;
    letter-spacing: 0.5pt;
  }
  .relat-print-meta {
    font-size: 9pt;
    text-align: center;
    color: #444;
    margin-bottom: 12pt;
    border-bottom: 1pt solid #000;
    padding-bottom: 6pt;
  }

  .relat-print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
    margin-top: 4pt;
  }
  .relat-print-table th {
    background: #eee;
    border: 1pt solid #555;
    padding: 4pt 5pt;
    text-align: left;
    font-weight: bold;
  }
  .relat-print-table td {
    border: 1pt solid #bbb;
    padding: 3pt 5pt;
    vertical-align: top;
  }
  .relat-print-table tr:nth-child(even) td { background: #f7f7f7; }

  .relat-print-footer {
    margin-top: 14pt;
    font-size: 8pt;
    color: #666;
    text-align: right;
    border-top: 1pt solid #bbb;
    padding-top: 4pt;
  }

  .relat-print-table tr { page-break-inside: avoid; }
}

.relat-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .45rem .8rem;
  max-height: 260px;
  overflow: auto;
  padding-right: .25rem;
}

.relat-columns .checkline {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin: 0;
  font-size: .9rem;
}

.relat-columns input[type="checkbox"] {
  width: auto;
  min-width: 16px;
}

.relat-chart-panel {
  margin-top: 1rem;
}

.relat-chart-toolbar {
  display: flex;
  align-items: end;
  gap: .8rem;
  flex-wrap: wrap;
}

.relat-chart-toolbar h3 {
  margin-right: auto;
}

.relat-chart-toolbar label {
  min-width: 180px;
}

.relat-chart-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(220px, 1fr);
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}

.relat-pie {
  width: 100%;
  max-width: 280px;
  height: auto;
}

.relat-chart-legend,
.relat-bars {
  display: grid;
  gap: .45rem;
}

.relat-legend-row,
.relat-bar-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: .5rem;
  align-items: center;
}

.relat-legend-row strong,
.relat-bar-row strong {
  font-variant-numeric: tabular-nums;
}

.relat-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.relat-bar-row {
  grid-template-columns: minmax(130px, 220px) minmax(120px, 1fr) auto;
}

.relat-bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relat-bar-track {
  height: 14px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}

.relat-bar-fill {
  height: 100%;
  border-radius: inherit;
}

@media (max-width: 760px) {
  .relat-chart-grid {
    grid-template-columns: 1fr;
  }

  .relat-bar-row {
    grid-template-columns: minmax(90px, 1fr) minmax(90px, 1.2fr) auto;
  }
}

/* ================================================================
   Sidebar collapse (desktop)
   ================================================================ */
#app-shell.sidebar-collapsed {
  grid-template-columns: 64px 1fr;
}
#app-shell.sidebar-collapsed .sidebar {
  padding: 16px 8px;
}
#app-shell.sidebar-collapsed .brand-text,
#app-shell.sidebar-collapsed .nav-label,
#app-shell.sidebar-collapsed .sidebar-user span,
#app-shell.sidebar-collapsed .sidebar-user small,
#app-shell.sidebar-collapsed .btn-logout {
  display: none;
}
#app-shell.sidebar-collapsed nav button {
  padding: 10px;
  text-align: center;
  justify-content: center;
  display: flex;
}
#app-shell.sidebar-collapsed .nav-icon {
  font-size: 1.25rem;
}
#app-shell.sidebar-collapsed .brand {
  justify-items: center;
  padding-bottom: 14px;
}
#app-shell.sidebar-collapsed .main::before {
  inset: 0 0 0 64px;
}

/* ================================================================
   Camada final de legibilidade
   ================================================================ */
body,
.main {
  background: #eef3f8 !important;
}

.main::before {
  display: none !important;
}

.panel,
.form,
.kpi,
.table-wrap,
.piece-card,
.collapse-panel,
.search-form,
.pdf-import-box,
.dashboard-item,
.dashboard-health-card,
.plantao-active-card,
details.panel {
  background: #ffffff !important;
  border-color: #b9c6d4 !important;
  color: #0f172a !important;
}

.modal-overlay {
  background: rgba(15, 23, 42, .74) !important;
}

.modal-box {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 2px solid #334155 !important;
  box-shadow: 0 18px 55px rgba(15, 23, 42, .48) !important;
}

.modal-box .panel,
.modal-box fieldset,
.modal-box details,
.modal-box form {
  background: #ffffff !important;
  color: #0f172a !important;
}

.modal-box input,
.modal-box select,
.modal-box textarea,
.modal-box label,
.modal-box summary,
.modal-box li,
.modal-box p,
.modal-box small,
.modal-box span,
.modal-box strong {
  color: #0f172a !important;
}

.modal-box small,
.modal-box .muted {
  color: #475569 !important;
}

input,
select,
textarea {
  background: #ffffff !important;
  border: 1px solid #8ea0b4 !important;
  color: #0f172a !important;
}

button,
.button {
  border-color: #8ea0b4 !important;
  color: #0f172a !important;
}

.primary,
button.primary,
.modal-box button[type="submit"],
#usuario-modal button[onclick="salvarPermissoesUsuario()"],
#new-proc-btn,
#refresh-btn {
  background: #075985 !important;
  border-color: #075985 !important;
  color: #ffffff !important;
}

.primary:hover,
button.primary:hover,
.modal-box button[type="submit"]:hover,
#usuario-modal button[onclick="salvarPermissoesUsuario()"]:hover,
#new-proc-btn:hover,
#refresh-btn:hover {
  background: #0c4a6e !important;
  border-color: #0c4a6e !important;
  color: #ffffff !important;
}

button.danger,
.danger-btn,
button[onclick*="Excluir"],
button[onclick*="excluir"],
button[onclick*="removeProc"] {
  background: #fff1f2 !important;
  border-color: #be123c !important;
  color: #9f1239 !important;
}

.btn-logout {
  background: #0f2f3d !important;
  border-color: #3b6274 !important;
  color: #ffffff !important;
}

th {
  background: #dbeafe !important;
  color: #0f172a !important;
}

td {
  color: #0f172a !important;
}

tbody tr:nth-child(even) td {
  background: #f8fafc !important;
}

tbody tr:hover td {
  background: #e0f2fe !important;
}

#usuario-modal .modal-box,
#usuario-modal .user-permissions-modal {
  max-width: min(980px, calc(100vw - 32px)) !important;
  width: 980px;
}

.permissions-editor {
  margin-top: 1rem;
  border-top: 1px solid #cbd5e1;
  padding-top: 1rem;
}

.permissions-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: .75rem;
}

.permissions-header h4 {
  margin: 0;
  font-size: 1rem;
  color: #0f172a;
}

.permissions-header p {
  margin: .25rem 0 0;
  color: #475569;
  font-size: .85rem;
}

.permissions-actions,
.permissions-footer {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.permissions-note {
  margin: .6rem 0;
  padding: .65rem .8rem;
  border: 1px solid #93c5fd;
  background: #eff6ff;
  color: #0f3b63;
  border-radius: 6px;
  font-size: .86rem;
}

.permissions-summary {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: .65rem 0 .85rem;
}

.permissions-summary span {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  border-radius: 999px;
  padding: .28rem .6rem;
  font-size: .82rem;
  font-weight: 700;
}

.permissions-editor details {
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #ffffff;
  padding: .65rem .75rem;
}

.permissions-editor details + details {
  margin-top: .75rem;
}

.permissions-check-grid {
  padding: .65rem .1rem .1rem !important;
  display: grid !important;
  gap: .5rem !important;
}

.permissions-check-grid.cartorios {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.permissions-check-grid.areas {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)) !important;
}

.permissions-check-grid label {
  display: flex !important;
  align-items: flex-start !important;
  gap: .5rem !important;
  cursor: pointer;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: .55rem .65rem;
  min-height: 44px;
}

.permissions-check-grid input {
  width: auto !important;
  margin-top: .15rem;
  accent-color: #075985;
}

.permissions-check-grid strong {
  display: block;
  color: #0f172a;
  font-size: .88rem;
}

.permissions-check-grid small {
  display: block;
  color: #475569;
  font-size: .75rem;
  line-height: 1.25;
  margin-top: .12rem;
}

.permissions-footer {
  margin-top: .8rem;
}

/* ================================================================
   Personalizacao funcional: temas solidos e menu sempre legivel
   ================================================================ */
:root,
html[data-theme="claro"] {
  --ui-bg: #eef3f8;
  --ui-panel: #ffffff;
  --ui-panel-2: #f8fafc;
  --ui-text: #0f172a;
  --ui-muted: #475569;
  --ui-border: #9aaabd;
  --ui-head: #dbeafe;
  --ui-primary: #075985;
  --ui-primary-hover: #0c4a6e;
  --ui-sidebar: #071923;
  --ui-sidebar-active: #0e7490;
  --ui-danger-bg: #fff1f2;
  --ui-danger: #9f1239;
}

html[data-theme="azul"] {
  --ui-bg: #eaf3fb;
  --ui-panel: #ffffff;
  --ui-panel-2: #eff6ff;
  --ui-text: #082f49;
  --ui-muted: #31556f;
  --ui-border: #7aa4c7;
  --ui-head: #bfdbfe;
  --ui-primary: #075985;
  --ui-primary-hover: #034766;
  --ui-sidebar: #06283d;
  --ui-sidebar-active: #0369a1;
}

html[data-theme="escuro"] {
  --ui-bg: #101923;
  --ui-panel: #182536;
  --ui-panel-2: #223248;
  --ui-text: #f8fafc;
  --ui-muted: #d6e1ec;
  --ui-border: #5f7892;
  --ui-head: #27415d;
  --ui-primary: #38bdf8;
  --ui-primary-hover: #0ea5e9;
  --ui-sidebar: #07111c;
  --ui-sidebar-active: #075985;
  --ui-danger-bg: #3b111b;
  --ui-danger: #fecdd3;
}

html[data-theme="contraste"] {
  --ui-bg: #000000;
  --ui-panel: #ffffff;
  --ui-panel-2: #f2f2f2;
  --ui-text: #000000;
  --ui-muted: #1f2937;
  --ui-border: #000000;
  --ui-head: #ffeb3b;
  --ui-primary: #003cff;
  --ui-primary-hover: #0025a8;
  --ui-sidebar: #000000;
  --ui-sidebar-active: #003cff;
}

html[data-theme="rosa"] {
  --ui-bg: #fff1f7;
  --ui-panel: #ffffff;
  --ui-panel-2: #fff7fb;
  --ui-text: #3f1028;
  --ui-muted: #6b2949;
  --ui-border: #d98db1;
  --ui-head: #fbcfe8;
  --ui-primary: #be185d;
  --ui-primary-hover: #9d174d;
  --ui-sidebar: #3b1026;
  --ui-sidebar-active: #be185d;
}

html[data-fontsize="sm"] { font-size: 14px; }
html[data-fontsize="md"] { font-size: 16px; }
html[data-fontsize="lg"] { font-size: 18px; }
html[data-fontsize="xl"] { font-size: 20px; }

body,
.main {
  background: var(--ui-bg) !important;
  color: var(--ui-text) !important;
}

.panel,
.form,
.kpi,
.table-wrap,
.piece-card,
.collapse-panel,
.search-form,
.pdf-import-box,
.dashboard-item,
.dashboard-health-card,
.plantao-active-card,
details.panel,
.modal-box {
  background: var(--ui-panel) !important;
  border-color: var(--ui-border) !important;
  color: var(--ui-text) !important;
}

p,
.muted,
.hint-text,
small,
label small,
.form-help span,
.dashboard-item p,
.dashboard-item-meta {
  color: var(--ui-muted) !important;
}

label,
legend,
summary,
li,
th,
td,
.modal-box h1,
.modal-box h2,
.modal-box h3,
.modal-box p,
.modal-box span,
.modal-box strong {
  color: var(--ui-text) !important;
}

input,
select,
textarea {
  background: var(--ui-panel) !important;
  border-color: var(--ui-border) !important;
  color: var(--ui-text) !important;
}

button,
.button {
  background: var(--ui-panel) !important;
  border-color: var(--ui-border) !important;
  color: var(--ui-text) !important;
}

.primary,
button.primary,
.modal-box button[type="submit"],
#usuario-modal button[onclick="salvarPermissoesUsuario()"],
#new-proc-btn,
#refresh-btn,
.subtabs button.active {
  background: var(--ui-primary) !important;
  border-color: var(--ui-primary) !important;
  color: #ffffff !important;
}

.primary:hover,
button.primary:hover,
.modal-box button[type="submit"]:hover,
#usuario-modal button[onclick="salvarPermissoesUsuario()"]:hover,
#new-proc-btn:hover,
#refresh-btn:hover,
.subtabs button.active:hover {
  background: var(--ui-primary-hover) !important;
  border-color: var(--ui-primary-hover) !important;
  color: #ffffff !important;
}

button.danger,
.danger-btn,
button[onclick*="Excluir"],
button[onclick*="excluir"],
button[onclick*="removeProc"] {
  background: var(--ui-danger-bg) !important;
  border-color: var(--ui-danger) !important;
  color: var(--ui-danger) !important;
}

th {
  background: var(--ui-head) !important;
  color: var(--ui-text) !important;
}

td,
tbody tr:nth-child(even) td {
  background: var(--ui-panel) !important;
  color: var(--ui-text) !important;
}

tbody tr:hover td {
  background: var(--ui-panel-2) !important;
}

.modal-overlay {
  background: rgba(15, 23, 42, .76) !important;
}

.sidebar {
  background: var(--ui-sidebar) !important;
  color: #ffffff !important;
}

.sidebar .nav-label,
.sidebar .nav-icon,
.sidebar-personalizar .nav-label,
.brand-text,
.brand-text strong {
  display: inline !important;
  color: #f8fafc !important;
  opacity: 1 !important;
  visibility: visible !important;
}

nav button,
.sidebar-personalizar button {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  background: transparent !important;
  color: #f8fafc !important;
  border: 1px solid transparent !important;
  justify-content: flex-start !important;
}

nav button.active,
nav button:hover,
.sidebar-personalizar button:hover {
  background: var(--ui-sidebar-active) !important;
  border-color: rgba(255,255,255,.18) !important;
  color: #ffffff !important;
}

#app-shell.sidebar-collapsed {
  grid-template-columns: 260px 1fr !important;
}

#app-shell.sidebar-collapsed .sidebar {
  padding: 20px 14px !important;
}

#app-shell.sidebar-collapsed .nav-label,
#app-shell.sidebar-collapsed .brand-text,
#app-shell.sidebar-collapsed .sidebar-user span,
#app-shell.sidebar-collapsed .sidebar-user small,
#app-shell.sidebar-collapsed .btn-logout {
  display: inline !important;
}

#app-shell.sidebar-collapsed nav button {
  padding: 11px 12px !important;
  text-align: left !important;
  justify-content: flex-start !important;
}

.tema-btn,
.fonte-btn {
  min-height: 44px;
  background: var(--ui-panel-2) !important;
}

.tema-btn.active,
.fonte-btn.active {
  background: var(--ui-primary) !important;
  border-color: var(--ui-primary) !important;
  color: #ffffff !important;
}

.tema-btn.active small,
.fonte-btn.active small,
.tema-btn.active span,
.fonte-btn.active span {
  color: #ffffff !important;
}

/* Sidebar compacta */
.sidebar {
  padding: 12px 10px !important;
}

.brand {
  padding: 6px 8px 10px !important;
  margin-bottom: 6px !important;
}

nav {
  gap: 2px !important;
  margin-top: 8px !important;
}

nav button,
.sidebar-personalizar button {
  min-height: 32px !important;
  padding: 6px 9px !important;
  border-radius: 5px !important;
  font-size: 13px !important;
  line-height: 1.15 !important;
  gap: 8px !important;
}

.sidebar .nav-icon {
  width: 18px !important;
  min-width: 18px !important;
  font-size: 14px !important;
  text-align: center !important;
}

.sidebar .nav-label {
  font-size: 13px !important;
  line-height: 1.15 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

#app-shell.sidebar-collapsed .sidebar {
  padding: 12px 10px !important;
}

#app-shell.sidebar-collapsed nav button {
  padding: 6px 9px !important;
}

.sidebar-personalizar {
  margin-top: 6px !important;
  padding-top: 6px !important;
}

.sidebar-user {
  padding: 8px 8px 6px !important;
  gap: 1px !important;
}

.sidebar-user span {
  font-size: 13px !important;
  line-height: 1.2 !important;
}

.sidebar-user small {
  font-size: 12px !important;
  line-height: 1.15 !important;
}

.sidebar .btn-logout {
  min-height: 30px !important;
  padding: 4px 8px !important;
  font-size: 12px !important;
  margin-top: 6px !important;
}

/* Layout desktop sem exigir zoom */
@media (min-width: 761px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  #app-shell {
    grid-template-columns: clamp(184px, 15vw, 220px) minmax(0, 1fr) !important;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  #app-shell.sidebar-collapsed {
    grid-template-columns: 58px minmax(0, 1fr) !important;
  }

  #app-shell.sidebar-collapsed .sidebar {
    padding: 10px 6px !important;
  }

  #app-shell.sidebar-collapsed .nav-label,
  #app-shell.sidebar-collapsed .brand-text,
  #app-shell.sidebar-collapsed .sidebar-user span,
  #app-shell.sidebar-collapsed .sidebar-user small,
  #app-shell.sidebar-collapsed .btn-logout {
    display: none !important;
  }

  #app-shell.sidebar-collapsed nav button,
  #app-shell.sidebar-collapsed .sidebar-personalizar button {
    justify-content: center !important;
    padding: 7px 6px !important;
    gap: 0 !important;
  }

  #app-shell.sidebar-collapsed .sidebar .nav-icon {
    width: 22px !important;
    min-width: 22px !important;
    font-size: 15px !important;
  }

  #app-shell.sidebar-collapsed .brand {
    justify-content: center !important;
    padding: 6px 0 8px !important;
  }

  .sidebar {
    position: sticky !important;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    min-width: 0;
    overflow: hidden;
  }

  .sidebar nav {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
  }

  .main {
    min-width: 0 !important;
    max-width: 100%;
    overflow-x: hidden !important;
    padding: 18px !important;
  }

  .view,
  .panel,
  .form,
  .collapse-panel,
  details.panel {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .form-grid,
  .grid,
  .kpis,
  .dashboard-main-grid,
  .dashboard-detail-grid {
    min-width: 0 !important;
  }

  .form-grid > *,
  .grid > *,
  label,
  input,
  select,
  textarea {
    min-width: 0 !important;
  }

  .table-wrap {
    max-width: 100% !important;
    overflow-x: auto !important;
  }

  .subtabs,
  .toolbar,
  .actions {
    max-width: 100%;
  }
}

@media (min-width: 761px) and (max-width: 1180px) {
  .form-grid,
  .plantao-filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .dashboard-main-grid,
  .grid.two {
    grid-template-columns: 1fr !important;
  }
}

.modelos-toolbar {
  margin: 10px 0 12px;
  gap: 8px;
  flex-wrap: wrap;
}

.modelos-toolbar input {
  flex: 2;
  min-width: 260px;
}

.modelos-toolbar select {
  flex: 1;
  min-width: 190px;
}

.doc-part-editor,
.rich-editor {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
  background: #ffffff !important;
  color: #111827 !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .10);
}

.doc-part-editor {
  width: 100%;
  font-family: "Times New Roman", Times, serif;
  font-size: 13px;
  line-height: 1.35;
  resize: vertical;
}

.doc-header-editor {
  text-align: center;
  font-weight: 700;
}

.doc-footer-editor {
  text-align: center;
  color: #475569 !important;
}

#modelo-rich-editor,
[id^="proc-peca-editor-"] {
  min-height: 620px !important;
  padding: 56px 64px !important;
  font-family: "Times New Roman", Times, serif !important;
  font-size: 12pt !important;
  line-height: 1.45 !important;
  border-radius: 2px !important;
}

#modelo-rich-editor:focus,
[id^="proc-peca-editor-"]:focus,
.doc-part-editor:focus {
  outline: 2px solid rgba(14, 116, 144, .30);
  border-color: #0e7490 !important;
}

.piece-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  border-bottom: 0 !important;
  border-radius: 6px 6px 0 0 !important;
  box-shadow: 0 6px 16px rgba(15, 23, 42, .08);
}

.piece-toolbar + .rich-editor {
  border-top-left-radius: 0 !important;
  border-top-right-radius: 0 !important;
}

.official-doc-header {
  display: grid;
  grid-template-columns: 116px 1fr;
  align-items: center;
  gap: 26px;
  text-align: left;
  margin: 0 0 22px;
  padding: 8px 0 18px;
  font-family: "Times New Roman", Times, serif;
  font-weight: 700;
  line-height: 1.22;
}

.official-doc-brasao {
  display: block;
  width: 86px;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}

.official-doc-header-text {
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 28px;
  border-left: 2px solid #7c8794;
  text-align: left;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11pt;
  font-weight: 500;
  line-height: 1.18;
  color: #4b5563;
  white-space: pre-line;
}

.imported-word-document p,
.imported-plain-document {
  margin: 0 0 6pt;
}

.docx-tab {
  display: inline-block;
  width: 48px;
}

.docx-import-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}

.docx-import-table td,
.docx-import-table th {
  border: 1px solid #94a3b8;
  padding: 4px 6px;
  vertical-align: top;
}

.workload-panel {
  margin-top: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbff;
  padding: 0.7rem;
}

.workload-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.workload-head strong {
  display: block;
  color: var(--text);
  font-weight: 700;
}

.workload-head span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
}

.workload-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: none;
  overflow: visible;
}

.workload-card {
  text-align: left;
  border: 1px solid #bfd2e7;
  background: #fff;
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(90px, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  min-height: 52px;
}

.workload-card:hover,
.workload-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 95, 138, 0.14);
}

.workload-person {
  min-width: 0;
}

.workload-name {
  display: block;
  color: var(--text);
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.workload-stats {
  display: grid;
  grid-template-columns: repeat(2, 74px);
  gap: 0.35rem;
  width: auto;
}

.workload-metric {
  min-width: 0;
  border: 1px solid #d8e6f3;
  background: #f8fafc;
  border-radius: 7px;
  padding: 0.35rem 0.45rem;
  text-align: center;
}

.workload-metric strong {
  display: block;
  color: var(--primary);
  font-size: 1.15rem;
  line-height: 1.05;
  white-space: nowrap;
}

.workload-metric small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.05;
  margin-top: 0.12rem;
  white-space: nowrap;
}

.workload-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.workload-badge {
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  background: #e5e7eb;
  color: #374151;
}

.workload-badge.ok {
  background: #dcfce7;
  color: #166534;
}

.workload-badge.warn {
  background: #fef3c7;
  color: #92400e;
}

.workload-badge.danger {
  background: #fee2e2;
  color: #991b1b;
}

.tarefa-modal-box {
  width: min(760px, calc(100vw - 28px));
}

@media (max-width: 760px) {
  .workload-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .workload-card {
    grid-template-columns: 1fr;
  }

  .workload-stats { grid-template-columns: repeat(2, 72px); }
}

.proc-position-card {
  border-left: 4px solid var(--accent);
  background: #eef7ff;
  color: #0f2740;
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  min-width: 220px;
}

.proc-position-card strong {
  display: block;
  font-size: 0.88rem;
  line-height: 1.2;
}

.proc-position-card span {
  display: block;
  color: #334155;
  font-size: 0.78rem;
  line-height: 1.25;
  margin-top: 0.15rem;
}

.proc-position-card.compact {
  margin: 0.35rem 0;
  background: rgba(14, 116, 144, 0.18);
  border-left-color: #67e8f9;
  color: #e8edf2;
}

.proc-position-card.compact span {
  color: rgba(232, 237, 242, 0.78);
}

@media print {
  .official-doc-header {
    grid-template-columns: 30mm 1fr;
    gap: 10mm;
    margin-bottom: 14mm;
    padding: 0 0 8mm;
  }

  .official-doc-brasao {
    width: 24mm;
  }

  .official-doc-header-text {
    min-height: 26mm;
    padding-left: 9mm;
    font-size: 10.5pt;
  }
}

/* Impressao: as areas imprimiveis ficam dentro do app-shell */
@media print {
  body.printing-relatorio > *,
  body.printing-protocolo > * {
    display: none !important;
  }

  body.printing-relatorio #app-shell,
  body.printing-protocolo #app-shell {
    display: block !important;
    min-height: 0 !important;
    background: #fff !important;
  }

  body.printing-relatorio #app-shell > *,
  body.printing-protocolo #app-shell > * {
    display: none !important;
  }

  body.printing-relatorio #relat-print-area {
    display: block !important;
  }

  body.printing-relatorio #protocolo-print-area {
    display: none !important;
  }

  body.printing-protocolo #protocolo-print-area {
    display: block !important;
  }

  body.printing-protocolo #relat-print-area {
    display: none !important;
  }
}
/* Agenda: disponibilidade de oitivas para estagiarias */
.agenda-disponibilidade-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.agenda-mapa-panel {
  padding: 12px;
}

.agenda-mapa-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0;
  font-size: 12px;
  color: var(--muted);
}

.agenda-mapa-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.agenda-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  border: 1px solid var(--line);
}

.agenda-mapa-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(96px, 1fr));
  gap: 7px;
}

.agenda-mapa-head {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-align: center;
}

.agenda-mapa-empty {
  min-height: 78px;
}

.agenda-mapa-dia {
  min-height: 78px;
  padding: 8px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  display: grid;
  gap: 2px;
  align-content: start;
}

.agenda-mapa-dia strong {
  font-size: 18px;
}

.agenda-mapa-dia span {
  font-weight: 800;
  font-size: 12px;
}

.agenda-mapa-dia small,
.agenda-mapa-dia em {
  font-size: 11px;
  color: var(--muted);
  font-style: normal;
}

.agenda-mapa-dia.livre,
.agenda-dot.livre {
  background: #e8f7ee;
  border-color: #62b47d;
}

.agenda-mapa-dia.parcial,
.agenda-dot.parcial {
  background: #fff8dd;
  border-color: #d4a51f;
}

.agenda-mapa-dia.cheio,
.agenda-dot.cheio {
  background: #feecec;
  border-color: #e56b6f;
}

.agenda-mapa-dia.plantao,
.agenda-dot.plantao {
  background: #e9eef8;
  border-color: #6f88b8;
}

.agenda-mapa-dia.bloqueado,
.agenda-dot.bloqueado {
  background: #f4e9fb;
  border-color: #a875c6;
}

.agenda-mapa-dia.sem_horario,
.agenda-dot.sem_horario {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.agenda-bloqueio-form-wrap {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.agenda-bloqueio-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  align-items: end;
}

.agenda-bloqueios-lista {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.agenda-mapa-detalhe {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.agenda-mapa-detalhe-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.agenda-mapa-detalhe-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr) minmax(180px, 1fr);
  gap: 10px;
}

.agenda-mapa-detalhe-grid h4 {
  margin: 0 0 6px;
}

.agenda-checklist-oitiva {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  background: var(--surface-soft, #f8fafc);
}

.agenda-checklist-oitiva legend {
  font-weight: 800;
  padding: 0 6px;
}

.agenda-checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 12px;
  margin-bottom: 10px;
}

.agenda-checklist-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.agenda-whatsapp-modal {
  max-width: 760px;
  width: min(760px, calc(100vw - 24px));
}

.agenda-whatsapp-modal textarea[name="texto"] {
  font-family: Arial, sans-serif;
  line-height: 1.45;
  min-height: 260px;
}

.month-picker-btn {
  min-width: 132px;
  justify-content: center;
  font-weight: 700;
}

.agenda-month-modal {
  max-width: 420px;
  width: min(420px, calc(100vw - 24px));
}

.agenda-month-nav {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.agenda-month-nav strong {
  text-align: center;
  font-size: 1.25rem;
  color: var(--text);
}

.agenda-month-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.agenda-month-grid button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.agenda-month-grid button:hover,
.agenda-month-grid button.is-selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.agenda-mini-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.agenda-mini-slots button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #edf5ff;
  color: var(--text);
  padding: 6px 9px;
  font-weight: 800;
}

.agenda-bloqueios-lista h4 {
  margin: 0 0 4px;
}

.agenda-bloqueio-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.agenda-sugestoes-box {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.agenda-sugestoes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.agenda-sugestao-btn {
  display: grid;
  gap: 2px;
  min-width: 138px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  padding: 8px 10px;
}

.agenda-sugestao-btn strong {
  font-size: 18px;
}

.agenda-sugestao-btn em {
  font-style: normal;
  font-size: 11px;
  color: var(--ok, #166534);
}

.agenda-sugestao-btn.is-best {
  border-color: #2f80ed;
  background: #edf5ff;
}

.agenda-dia-resumo {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
}

.agenda-dia-item {
  display: grid;
  grid-template-columns: 54px minmax(100px, 150px) 1fr;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.agenda-dia-item span {
  font-weight: 800;
}

.agenda-dia-item em {
  color: var(--muted);
  font-style: normal;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agenda-dia-vazio {
  margin-top: 8px;
}

.agenda-disponibilidade-builder {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.agenda-disponibilidade-panel {
  padding: 10px 12px;
}

.agenda-disponibilidade-content {
  margin-top: 12px;
}

.agenda-disponibilidade-toolbar {
  margin-bottom: 10px;
}

.agenda-dias-grid,
.agenda-builder-grid {
  display: grid;
  gap: 8px;
}

.agenda-dias-grid {
  grid-template-columns: repeat(7, minmax(64px, 1fr));
}

.agenda-dias-grid label,
.agenda-builder-plantao {
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-muted, #f7fafc);
}

.agenda-builder-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  align-items: end;
}

.agenda-builder-grid label {
  display: grid;
  gap: 4px;
  font-weight: 700;
  color: var(--text);
}

.agenda-disponibilidade-row {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(110px, 140px) 104px auto 104px minmax(130px, 170px) minmax(130px, 160px) minmax(180px, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.agenda-disp-periodo {
  display: grid;
  gap: 4px;
}

.agenda-disp-periodo strong {
  font-size: 12px;
  color: var(--muted);
}

.agenda-disponibilidade-row input,
.agenda-disponibilidade-row select {
  width: 100%;
  min-width: 0;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.inline-check input[type="number"] {
  width: 64px;
}

@media (max-width: 900px) {
  .agenda-dias-grid {
    grid-template-columns: repeat(3, minmax(74px, 1fr));
  }

  .agenda-builder-grid {
    grid-template-columns: 1fr 1fr;
  }

  .agenda-mapa-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .agenda-mapa-head,
  .agenda-mapa-empty {
    display: none;
  }

  .agenda-bloqueio-item {
    align-items: stretch;
    flex-direction: column;
  }

  .agenda-mapa-detalhe-head {
    align-items: stretch;
    flex-direction: column;
  }

  .agenda-mapa-detalhe-grid {
    grid-template-columns: 1fr;
  }

  .agenda-disponibilidade-row {
    grid-template-columns: 1fr 1fr;
  }
}
