/* ==========================================================================
   GisMap Portal — folha de componentes
   --------------------------------------------------------------------------
   FONTE ÚNICA DE TOKENS: css/gismap-govtech.css (Design System v4, light-first
   com tema claro/escuro via html[data-theme]). Este arquivo NÃO redefine mais
   os tokens de cor/raio/sombra/fonte — antes havia um :root v2 (dark-first) que
   duplicava e conflitava com o v4 (color-scheme, fonte, header-h divergentes),
   causando inconsistência visual. Aqui apenas consumimos as variáveis (var(--x)).
   ========================================================================== */
:root {
  font-family: var(--font);
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}

/* Voltar ao topo */
.scroll-top-btn {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: max(1.15rem, calc(0.75rem + env(safe-area-inset-bottom, 0px)));
  z-index: 80;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    background 0.15s ease;
}
.scroll-top-btn:hover,
.scroll-top-btn:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateY(-2px);
  outline: none;
}
.scroll-top-btn:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.scroll-top-btn.hidden {
  display: none !important;
}
@media (max-width: 800px) {
  .scroll-top-btn {
    right: max(0.75rem, env(safe-area-inset-right, 0px));
    bottom: max(0.85rem, calc(0.65rem + env(safe-area-inset-bottom, 0px)));
    width: 2.85rem;
    height: 2.85rem;
  }
}

/* Ficha de campo: cadastro primeiro, navegação previsível e sem blocos concorrentes. */
.modal-panel-detail {
  width: min(1180px, 98vw);
  max-width: min(1180px, 98vw);
}
.detail-tablist {
  position: sticky;
  top: 4.8rem;
  z-index: 2;
  display: flex;
  gap: 0.25rem;
  padding: 0.35rem;
  margin: 0 0 0.65rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  scrollbar-width: thin;
}
.detail-tab {
  flex: 0 0 auto;
  min-height: 2.35rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  white-space: nowrap;
}
.detail-tab:hover {
  color: var(--text);
  background: var(--surface-2);
}
.detail-tab.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.detail-tabpanel {
  min-width: 0;
}
.detail-tabpanel.hidden {
  display: none !important;
}
.detail-emit-bar {
  margin-bottom: 0.65rem;
  padding: 0.55rem 0.65rem;
}
.detail-emit-hint {
  display: none;
}
#detail-panel-cadastro .detail-fields-head {
  margin-top: 0;
}
#detail-panel-fluxo > :first-child,
#detail-panel-analise > :first-child,
#detail-panel-media > :first-child {
  margin-top: 0;
}
@media (max-width: 720px) {
  .modal-panel-detail {
    width: 100%;
    max-width: 100%;
  }
  .detail-tablist {
    top: 4.2rem;
    margin-left: -0.25rem;
    margin-right: -0.25rem;
  }
  .detail-tab {
    min-height: 2.65rem;
  }
}

/* Gráficos: loading + animação de barras */
.chart-loading {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.35rem 0 0.15rem;
  min-height: 5.5rem;
}
.chart-loading .ui-spinner {
  margin-bottom: 0.15rem;
}
.bar-row-enter {
  animation: bar-row-in 0.28s ease both;
}
@keyframes bar-row-in {
  from {
    opacity: 0;
    transform: translateX(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.ficha-row,
.data-table tbody tr {
  animation: row-fade-in 0.22s ease both;
}
@keyframes row-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.table-loading-row {
  animation: none !important;
}

/* Barra de progresso global (topo) */
.global-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 9999;
  pointer-events: none;
  overflow: hidden;
  background: transparent;
}
.global-progress.hidden {
  display: none !important;
}
.global-progress.is-active .global-progress-bar {
  display: block;
}
.global-progress-bar {
  display: none;
  height: 100%;
  width: 35%;
  border-radius: 0 2px 2px 0;
  background: linear-gradient(
    90deg,
    transparent,
    var(--accent),
    #93c5fd,
    var(--accent),
    transparent
  );
  animation: global-progress-slide 1.1s ease-in-out infinite;
}
@keyframes global-progress-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .global-progress-bar {
    width: 100%;
    animation: none !important;
    opacity: 0.85;
  }
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
}
body {
  margin: 0;
  background:
    radial-gradient(
      900px 480px at 8% -8%,
      rgba(37, 99, 235, 0.22) 0%,
      transparent 55%
    ),
    radial-gradient(
      700px 400px at 100% 0%,
      rgba(16, 185, 129, 0.08) 0%,
      transparent 45%
    ),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* —— Top bar —— */
/* Z-index scale: base 0-10 | sticky headers 20-50 | dropdowns 100-200 | modals 1000 | toasts 1100 */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  padding-left: max(1.5rem, env(safe-area-inset-left, 0px));
  padding-right: max(1.5rem, env(safe-area-inset-right, 0px));
  padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
  min-height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: rgba(10, 15, 22, 0.82);
  backdrop-filter: blur(14px) saturate(1.2);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, #60a5fa 0%, #2563eb 55%, #0f766e 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 8px 24px rgba(96, 165, 250, 0.35);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.brand-mark-inner {
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  letter-spacing: -0.02em;
}
.brand-mark {
  position: relative;
  overflow: hidden;
}
.brand-mark.has-logo {
  background: var(--surface-2);
  box-shadow:
    0 0 0 1px var(--border),
    0 4px 12px rgba(0, 0, 0, 0.15);
}
.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: inherit;
  background: #fff;
}
.logo-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.logo-field input[type='file'] {
  max-width: 100%;
  font-size: 0.82rem;
}
.logo-preview {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.45rem;
  min-height: 2rem;
}
.logo-preview-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
.quick-actions-card {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
}
.quick-actions-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.quick-btn {
  margin: 0;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.1s;
}
.quick-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.quick-btn:active {
  transform: scale(0.98);
}
.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.65rem;
  display: block;
  color: var(--muted);
}
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}
.logo {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.sub {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}
.top-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.user-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  max-width: min(220px, 36vw);
  min-width: 0;
}
.user-badge.hidden {
  display: none !important;
}
.user-badge-main {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.2;
}
.user-badge-role {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.btn-logout {
  border-color: rgba(248, 113, 113, 0.4) !important;
  color: var(--danger) !important;
  font-weight: 600;
  flex-shrink: 0;
}
.btn-logout:hover {
  background: var(--danger-soft) !important;
}

main {
  flex: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
}
.card {
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}
.card h2 {
  margin: 0 0 0.85rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.muted {
  color: var(--muted);
}
.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 1rem;
}
.error {
  color: #fecaca;
  font-size: 0.9rem;
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  margin-top: 0.75rem;
}
.hidden {
  display: none !important;
}
label {
  display: block;
  margin: 0.75rem 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
}
input,
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}
input::placeholder {
  color: #5c6b82;
}
button {
  margin-top: 0.75rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.15rem;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition:
    background 150ms ease,
    color 150ms ease,
    border-color 150ms ease,
    transform 100ms ease,
    box-shadow 150ms ease;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset;
}
button:hover {
  background: var(--accent-hover);
}
button:active {
  transform: translateY(1px);
}
button.ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  box-shadow: none;
  transition:
    background 150ms ease,
    color 150ms ease,
    border-color 150ms ease;
}
button.ghost:hover {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.45);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-block {
  width: 100%;
  margin-top: 1rem;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.kpi {
  position: relative;
  overflow: hidden;
  margin-bottom: 0;
  padding: 1rem 1.1rem;
}
.kpi::after {
  content: '';
  position: absolute;
  inset: auto -20% -40% auto;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--ok-soft);
  pointer-events: none;
}
.kpi-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.kpi .num {
  font-size: 1.85rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.kpi-warn .num {
  color: var(--warn);
}
.kpi-danger .num {
  color: var(--danger);
}
.toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
th,
td {
  text-align: left;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
tr:last-child td {
  border-bottom: none;
}
tbody tr:hover td {
  background: rgba(59, 130, 246, 0.06);
}
.ficha-row {
  cursor: pointer;
}
.ficha-row:hover td {
  background: rgba(59, 130, 246, 0.09);
}
.ficha-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.btn-sm.btn-primary {
  margin-top: 0;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}
.pill-tipo {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 0.72rem;
}
.pill-pred {
  background: rgba(52, 211, 153, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.35);
}
.pill-terr {
  background: rgba(96, 165, 250, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.35);
}
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.75rem 0 0.25rem;
}
.filter-chips-label {
  margin-right: 0.25rem;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.4);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
}
.filter-chip:hover {
  background: rgba(59, 130, 246, 0.25);
}
.chip-x {
  opacity: 0.7;
  font-size: 1rem;
  line-height: 1;
}
.list-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.list-card-head h2 {
  margin: 0;
}
.list-count-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-weight: 600;
}
.modal-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.modal-head-actions button {
  margin-top: 0;
}
body.modal-open {
  overflow: hidden;
}
/* Modal: entrada suave do painel */
.modal:not(.hidden) .modal-panel {
  animation: modal-panel-in 0.22s ease both;
}
.modal:not(.hidden) .modal-backdrop {
  animation: modal-backdrop-in 0.2s ease both;
}
@keyframes modal-panel-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes modal-backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .modal:not(.hidden) .modal-panel,
  .modal:not(.hidden) .modal-backdrop {
    animation: none !important;
  }
}
.mono-id {
  font-size: 0.78rem;
}
.td-contrib {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table th {
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border-radius: 0 0 8px 0;
}
.skip-link:focus {
  left: 0;
}
.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}
.action-group button {
  margin-top: 0;
}
.row-inactive td {
  opacity: 0.72;
}
.pill-off {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.35);
}
.pill-role {
  font-size: 0.72rem;
  font-weight: 700;
}
.pill-role-admin {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
}
.pill-role-viewer {
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}
.pill-role-coordinator {
  background: rgba(251, 191, 36, 0.12);
  color: #fcd34d;
  border: 1px solid rgba(251, 191, 36, 0.35);
}
.color-field {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.35rem;
}
.color-field input[type='color'] {
  width: 48px;
  height: 42px;
  padding: 0.2rem;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.color-field input[type='text'],
.color-field #t-color {
  margin: 0;
  flex: 1;
}
.action-code {
  font-size: 0.75rem;
}
.list-head-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}
.sort-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 !important;
  font-weight: 600;
}
.sort-select,
.inline-search {
  margin: 0 !important;
  width: auto;
  min-width: 150px;
  max-width: 220px;
  padding: 0.4rem 0.55rem !important;
  font-size: 0.82rem;
}
.inline-search {
  min-width: 180px;
}
.th-sortable {
  cursor: pointer;
  user-select: none;
}
.th-sortable:hover {
  color: var(--text);
}
.th-sortable.sort-active {
  color: #93c5fd;
}
.th-sortable.sort-active::after {
  content: ' ↕';
  font-size: 0.7em;
  opacity: 0.8;
}
.th-sortable.sort-active.sort-asc::after {
  content: ' ↑';
}
.th-sortable.sort-active.sort-desc::after {
  content: ' ↓';
}
.status-pill-btn.is-active {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.55);
  border-color: rgba(59, 130, 246, 0.5);
}
.list-loading {
  padding: 0.5rem 0.25rem 0.75rem;
}
.list-loading .skeleton-row {
  margin: 0.4rem 0;
}
.empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin: 0.75rem 0 0.25rem;
}
.empty-state + .empty-actions,
td .empty-actions {
  margin-top: 0.65rem;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.2);
  position: sticky;
  top: 0;
}
td code,
code {
  font-family: var(--font-mono);
  font-size: 0.8em;
  background: var(--bg);
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}
footer,
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1.5rem 1rem 2rem;
  border-top: 1px solid transparent;
}
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  padding-bottom: max(2rem, calc(1.25rem + env(safe-area-inset-bottom, 0px)));
}
.site-footer p {
  margin: 0;
  line-height: 1.55;
}
.footer-meta-wrap.is-empty {
  display: none;
}
@media (max-width: 560px) {
  .site-footer {
    font-size: 0.75rem;
    padding: 1rem 0.75rem 1.35rem;
    padding-bottom: max(1.35rem, calc(1rem + env(safe-area-inset-bottom, 0px)));
  }
  .footer-kbds {
    display: none;
  }
  .footer-tag {
    display: block;
    margin-top: 0.2rem;
  }
  .footer-sep {
    display: none;
  }
}
.small {
  font-size: 0.8rem;
}
select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

/* —— Login shell —— */
.login-shell {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.5rem;
  align-items: stretch;
  max-width: 960px;
  margin: 1.5rem auto 2rem;
  min-height: min(560px, calc(100vh - 140px));
}
.login-hero {
  position: relative;
  border-radius: calc(var(--radius) + 4px);
  border: 1px solid var(--border);
  background:
    linear-gradient(160deg, rgba(37, 99, 235, 0.25) 0%, transparent 50%),
    linear-gradient(180deg, #152033 0%, #0c121c 100%);
  padding: 2rem 2rem 1.75rem;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.login-hero-glow {
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(59, 130, 246, 0.35),
    transparent 70%
  );
  top: -40px;
  right: -40px;
  pointer-events: none;
}
.login-hero-kicker {
  position: relative;
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #93c5fd;
}
.login-hero-title {
  position: relative;
  margin: 0 0 1.25rem;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
  max-width: 18ch;
}
.login-hero-list {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.login-hero-list li {
  font-size: 0.92rem;
  color: #c7d4e8;
  padding-left: 1.35rem;
  position: relative;
}
.login-hero-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.45rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}
.login-card {
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.75rem 1.6rem;
}
.login-card-head h1 {
  margin-bottom: 0.25rem;
}
.login-card-head .muted {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}
.login-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-top: 1.15rem;
}

.totp-box {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

/* —— Page header —— */
.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
}
.page-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #7dd3fc;
}
.page-title {
  margin: 0;
  font-size: clamp(1.35rem, 2.2vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.page-desc {
  margin: 0.35rem 0 0;
  max-width: 52ch;
}
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem 1rem;
  align-items: end;
}
.filters label {
  margin: 0;
}
.filter-actions {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding-bottom: 0.15rem;
}
.filter-actions button {
  margin-top: 0;
}
.btn-sm {
  margin-top: 0;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}
.pill {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  font-size: 0.75rem;
}
/* Modal (z-index 1000) — dropdowns 100-200, sticky headers 20-50 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
/* Confirmações podem ser abertas a partir de outro modal (ex.: Ficha). */
#confirm-modal {
  z-index: 1050;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}
.modal-panel {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: 90vh;
  overflow: auto;
  margin: 0;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.modal-head h2 {
  margin: 0;
  font-size: 1.15rem;
}
.section-label {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem 0.75rem;
}
.field-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
}
.field-item dt {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}
.field-item dd {
  margin: 0;
  font-size: 0.9rem;
  word-break: break-word;
}
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}
.media-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}
.media-label {
  font-size: 0.75rem;
  padding: 0.4rem 0.5rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.media-preview {
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}
.media-img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 4px;
}
.media-dl {
  color: var(--accent);
}
.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin: 0.75rem 0;
}
.status-row label {
  margin: 0;
  min-width: 160px;
}
.status-row button {
  margin-top: 0;
}
.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.nav-tab {
  margin-top: 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  box-shadow: none;
}
.nav-tab:hover {
  color: var(--text);
  border-color: var(--accent);
}
.nav-tab.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent);
  color: var(--text);
}
/* Fallback tipografia se CDN de fonts falhar */
@supports not (font-variation-settings: normal) {
  body {
    font-family: 'Segoe UI', system-ui, sans-serif;
  }
}
.tab-panel {
  margin-bottom: 1rem;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pill-warn {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.4);
}
.linkish {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.forgot-box {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.forgot-box label {
  margin-top: 0.5rem;
}
.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.bar-row {
  display: grid;
  grid-template-columns: 72px 1fr 40px;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.8rem;
}
.bar-track {
  background: var(--border);
  border-radius: 4px;
  height: 10px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  min-width: 2px;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.map-empty {
  height: 100%;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.map-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  align-items: stretch;
}
.map-layout.has-side {
  grid-template-columns: 1fr minmax(240px, 320px);
}
.map-layout.has-both-sides {
  grid-template-columns: 1fr minmax(200px, 260px) minmax(220px, 300px);
}
/* Container do Leaflet: legenda fica FORA do #map-box (L.map limpa o innerHTML) */
.map-stage {
  position: relative;
  min-width: 0;
  width: 100%;
}
.map-stage .map-box {
  width: 100%;
}
.map-stage .map-legend {
  position: absolute;
  left: 0.65rem;
  bottom: 0.65rem;
  z-index: 450;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  max-width: min(92%, 28rem);
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  background: rgba(15, 22, 35, 0.88);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
html[data-theme='light'] .map-stage .map-legend {
  background: rgba(255, 255, 255, 0.92);
}
.map-panel-card-pro {
  padding: 1rem 1.1rem 1.15rem;
}
.map-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.map-panel-title {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.map-panel-card-pro .map-intro {
  margin: 0;
  max-width: 52rem;
  line-height: 1.45;
}
/* Sidebar / abas mais profissionais */
.sidebar-nav .nav-tab {
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.page-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.85rem;
  margin-bottom: 0.85rem;
}
.page-title {
  letter-spacing: -0.02em;
}
.card {
  box-shadow: var(--shadow-sm);
}
.kpi-grid .card.kpi {
  transition:
    border-color 0.15s ease,
    transform 0.15s ease;
}
.kpi-grid .card.kpi:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
@media (max-width: 1100px) {
  .map-layout.has-both-sides {
    grid-template-columns: 1fr minmax(220px, 300px);
  }
  .map-layout.has-both-sides #map-fichas-list-panel {
    grid-column: 1 / -1;
    max-height: 220px;
  }
}
@media (max-width: 900px) {
  .map-layout.has-side,
  .map-layout.has-both-sides {
    grid-template-columns: 1fr;
  }
}
.map-feature-panel,
.map-fichas-list-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.75rem 0.85rem;
  max-height: min(56vh, 480px);
  overflow: auto;
  min-width: 0;
  z-index: 2;
}
.map-feature-panel.hidden,
.map-fichas-list-panel.hidden {
  display: none !important;
}
.map-fichas-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.map-fichas-list-panel .inline-search {
  width: 100%;
  margin-bottom: 0.5rem;
}
.map-fichas-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.map-ficha-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.5rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
}
.map-ficha-row:hover {
  border-color: var(--accent, #3b82f6);
}
.map-ficha-row:focus-visible {
  border-color: var(--accent, #3b82f6);
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 2px;
}
.map-ficha-row.is-fav {
  border-color: rgba(251, 191, 36, 0.55);
  background: rgba(251, 191, 36, 0.08);
}
.map-ficha-row.is-focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.12);
}
.map-ficha-row.is-cluster {
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(59, 130, 246, 0.1);
}
.map-ficha-row.is-selected {
  border-color: rgba(168, 85, 247, 0.6);
  background: rgba(168, 85, 247, 0.1);
}
.map-ficha-row.is-selected.is-cluster {
  box-shadow: inset 3px 0 0 #a855f7;
}
.map-fichas-list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.45rem;
}
.map-list-kbd-hint {
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
  line-height: 1.35;
}
.map-list-sel.is-on {
  color: #a855f7;
  border-color: rgba(168, 85, 247, 0.45);
}
.map-cluster-popup {
  font-size: 0.85rem;
  min-width: 180px;
}
.map-cluster-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.5rem 0;
  max-height: 200px;
  overflow: auto;
}
.map-cluster-list .btn-sm {
  text-align: left;
  justify-content: flex-start;
  white-space: normal;
}
.map-cluster-list .btn-sm.is-sel {
  border-color: rgba(168, 85, 247, 0.45);
  background: rgba(168, 85, 247, 0.1);
}
.map-cluster-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}
.cluster-more {
  margin: 0.25rem 0 0;
}
.cluster-status-sum {
  margin: 0.25rem 0 0;
}
/* Badge de cluster (L.divIcon) */
.leaflet-div-icon.map-cluster-icon {
  background: transparent;
  border: none;
}
.map-cluster-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #3b82f6, #2563eb);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
  border: 2.5px solid #fff;
  box-shadow:
    0 2px 8px rgba(15, 23, 42, 0.35),
    0 0 0 1px rgba(37, 99, 235, 0.35);
  text-align: center;
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease;
}
.map-cluster-badge:hover {
  transform: scale(1.08);
}
.map-cluster-badge.is-partial-sel {
  background: linear-gradient(145deg, #a78bfa, #7c3aed);
  box-shadow:
    0 2px 8px rgba(15, 23, 42, 0.35),
    0 0 0 1px rgba(124, 58, 237, 0.4);
}
.map-cluster-badge.is-all-sel {
  background: linear-gradient(145deg, #c084fc, #9333ea);
  box-shadow:
    0 2px 10px rgba(147, 51, 234, 0.45),
    0 0 0 2px rgba(168, 85, 247, 0.5);
}
.map-cluster-sel-pip {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.2rem;
  border-radius: 999px;
  background: #fbbf24;
  color: #1f2937;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1rem;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.td-actions {
  white-space: nowrap;
  min-width: 7.5rem;
}
.td-actions .btn-sm {
  margin: 0.1rem;
}
.td-actions-inner {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  justify-content: flex-end;
}
code.mono-id {
  cursor: pointer;
}
code.mono-id:hover {
  color: var(--accent);
  text-decoration: underline;
}
@media (max-width: 800px) {
  .td-actions {
    white-space: normal;
    min-width: 5.5rem;
  }
  .td-actions .btn-sm,
  .td-actions-inner .btn-sm {
    margin: 0;
    min-height: 2.15rem;
    flex: 1 1 auto;
  }
  .td-actions-inner {
    width: 100%;
  }
}
/* Lista de fichas: esconde colunas menos críticas em telas estreitas */
@media (max-width: 720px) {
  #fichas-table th:nth-child(10),
  #fichas-table td:nth-child(10) {
    /* Offline */
    display: none;
  }
}
@media (max-width: 560px) {
  #fichas-table th:nth-child(7),
  #fichas-table td:nth-child(7),
  #fichas-table th:nth-child(9),
  #fichas-table td:nth-child(9) {
    /* Bairro · Técnico */
    display: none;
  }
  #fichas-table th:nth-child(2),
  #fichas-table td:nth-child(2) {
    /* Recebida: só em telas um pouco maiores */
    font-size: 0.72rem;
  }
  .td-actions-inner .btn-row-copy-id {
    /* em telefone, ID já se copia pelo mono-id */
    display: none;
  }
}
.map-ficha-row-main {
  min-width: 0;
}
.map-ficha-row-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  word-break: break-all;
}
.map-ficha-row-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}
.map-ficha-row-actions {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: flex-end;
}
.map-feature-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.map-feature-insc {
  font-weight: 700;
  font-size: 1.05rem;
  font-family: var(--font-mono);
  margin: 0 0 0.65rem;
  word-break: break-all;
  color: var(--text);
}
.map-feature-dl {
  margin: 0;
}
/* base; regras finais (anti-sobreposição) mais abaixo no arquivo */
/* Painel lateral: empilhado em telas estreitas; 2 colunas só com espaço */
.map-feature-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  min-width: 0;
  width: 100%;
}
@media (min-width: 901px) {
  .map-feature-row {
    display: grid;
    grid-template-columns: minmax(7rem, 36%) minmax(8rem, 1fr);
    gap: 0.35rem 0.75rem;
    align-items: start;
  }
}
.map-feature-row dt,
.map-feature-row .map-feature-k {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  min-width: 0;
  word-break: normal;
  overflow-wrap: break-word;
  white-space: normal;
  line-height: 1.35;
}
.map-feature-row dd,
.map-feature-row .map-feature-v {
  margin: 0;
  word-break: normal;
  overflow-wrap: break-word;
  color: var(--text);
  font-weight: 600;
  min-width: 0;
  white-space: normal;
  line-height: 1.4;
}
.map-feature-row .map-feature-v.mono,
.map-feature-insc {
  font-family: var(--font-mono, ui-monospace, monospace);
  white-space: nowrap;
  overflow-x: auto;
  max-width: 100%;
}
.map-feature-agili-slot {
  margin-top: 0.5rem;
}
.map-feature-agili-slot:empty {
  display: none;
}
.map-layer-group {
  flex: 1 1 100%;
  margin: 0 0 0.45rem;
}
.map-layer-group-head {
  font-weight: 600;
  margin: 0 0 0.3rem;
  letter-spacing: 0.01em;
}
.map-layer-group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
}
.map-layer-swatch {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.15);
}
.map-layer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
  margin-top: 0.35rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border);
}
.map-layer-toggle.map-layer-geom-only {
  opacity: 0.88;
}
.map-feature-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
}
.map-box {
  position: relative;
  width: 100%;
  /* altura adaptativa: viewport dinâmico (mobile browser chrome) + limites */
  height: clamp(280px, 48dvh, 520px);
  min-height: 260px;
  background:
    linear-gradient(rgba(45, 58, 79, 0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 58, 79, 0.35) 1px, transparent 1px), #0b1220;
  background-size:
    40px 40px,
    40px 40px,
    auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 1;
  transition: height 0.2s ease;
}
/* Aba Mapa dedicada: mais altura útil (menos scroll no dashboard) */
#panel-map .map-box,
.map-box.map-box-tab {
  height: clamp(360px, 62dvh, 720px);
  min-height: 320px;
}
@supports not (height: 1dvh) {
  .map-box {
    height: clamp(280px, 48vh, 520px);
  }
  #panel-map .map-box,
  .map-box.map-box-tab {
    height: clamp(360px, 62vh, 720px);
  }
}
.map-box.leaflet-container,
.map-box .leaflet-container {
  width: 100%;
  height: 100%;
  font: inherit;
  background: #d4e0eb;
}
.map-box .map-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: inherit;
  padding: 1rem;
  box-sizing: border-box;
  color: var(--muted, #94a3b8);
  text-align: center;
}
.map-box .leaflet-control-attribution {
  font-size: 10px;
  max-width: 70%;
  background: rgba(255, 255, 255, 0.82);
  color: #334;
}
.map-basemap-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin: 0.5rem 0 0.75rem;
}
.map-tools-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem 0.75rem;
  margin: 0 0 0.75rem;
}
.map-layer-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  flex: 1 1 240px;
  margin: 0;
  max-height: min(30vh, 240px);
  overflow: auto;
  align-content: flex-start;
  padding: 0.15rem 0.1rem 0.25rem;
}
#btn-map-fit-fichas {
  flex: 0 0 auto;
  margin-top: 0.1rem;
}
.map-layer-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  user-select: none;
}
.map-layer-toggle:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.map-layer-toggle input {
  margin: 0;
  accent-color: var(--accent);
}
.map-layer-heavy {
  border-color: rgba(251, 191, 36, 0.45);
}
.map-layer-toggle.is-loading {
  border-color: var(--accent);
  color: var(--text);
  opacity: 0.85;
  pointer-events: none;
}
.map-layer-toggle.is-loading::after {
  content: '…';
  margin-left: 0.15rem;
  animation: map-pulse 0.9s ease-in-out infinite;
}
.map-layer-toggle.is-active {
  border-color: rgba(52, 211, 153, 0.55);
  background: rgba(52, 211, 153, 0.1);
  color: var(--text);
}
.map-layer-toggle.is-error {
  border-color: rgba(248, 113, 113, 0.65);
  background: rgba(248, 113, 113, 0.08);
  color: #fecaca;
}
@keyframes map-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}
/* Legenda flutuante no mapa */
.map-legend {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  padding: 0.3rem 0.65rem;
  background: var(--surface-2, rgba(241, 245, 249, 0.92));
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-muted, #475569);
  line-height: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  z-index: 500;
  margin: 0;
  max-width: calc(100% - 1.2rem);
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}
/* Em telas estreitas, legenda centralizada no fundo do mapa */
@media (max-width: 560px) {
  .map-legend {
    right: 0.4rem;
    bottom: 0.4rem;
    left: 0.4rem;
    max-width: none;
    justify-content: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    padding: 0.28rem 0.55rem;
  }
}
.map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  white-space: nowrap;
  line-height: 1.1;
}
.map-legend-label {
  line-height: 1.1;
  font-weight: 500;
}
.map-legend-dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 1.5px solid var(--surface, #fff);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.18),
    0 1px 2px rgba(0, 0, 0, 0.08);
  vertical-align: middle;
  flex-shrink: 0;
}
.map-legend-dot.pred {
  background: #34d399;
}
.map-legend-dot.terr {
  background: #60a5fa;
}
.map-legend-dot.fav {
  background: #fbbf24;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.map-legend-dot.sel {
  background: #34d399;
  box-shadow:
    0 0 0 2px #a855f7,
    0 0 0 1px rgba(0, 0, 0, 0.2);
}
.map-legend-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: var(--accent, #3b82f6);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  border: 1.5px solid var(--surface, #fff);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.18),
    0 1px 2px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}
#map-meta {
  margin: 0.55rem 0 0;
  line-height: 1.45;
}
#map-meta.is-err {
  color: var(--danger);
}
#map-meta.is-ok {
  color: var(--muted);
}
.map-basemap-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.map-basemap-disabled input {
  cursor: not-allowed;
}
.map-intro {
  max-width: 62rem;
  line-height: 1.45;
}
.list-kbd-hint {
  margin: 0.35rem 0 0;
}
.list-kbd-hint .kbd {
  font-size: 0.72rem;
}
.filter-fav-toggle {
  display: inline-flex !important;
  align-items: center;
  gap: 0.4rem;
  margin: 0 !important;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.filter-fav-toggle input {
  width: auto !important;
  margin: 0 !important;
  accent-color: var(--warn);
}
.filter-fav-toggle:has(input:checked) {
  border-color: rgba(251, 191, 36, 0.55);
  color: var(--text);
  background: var(--warn-soft);
}
.detail-emit-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin: 0.35rem 0 0.85rem;
  padding: 0.65rem 0.85rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  position: sticky;
  top: 3.25rem;
  z-index: 2;
}
.detail-emit-hint {
  margin: 0;
  flex: 1 1 220px;
  line-height: 1.4;
}
.detail-emit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.detail-list-pos {
  align-self: center;
  font-variant-numeric: tabular-nums;
  min-width: 5.5rem;
  text-align: center;
  white-space: nowrap;
}

/* Detalhes/resumo: no desktop os extras ficam inline; no mobile viram “Mais…” */
.detail-more-details {
  display: contents;
}
.detail-more-details > .detail-more-summary {
  display: none;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.detail-more-details > .detail-more-summary::-webkit-details-marker {
  display: none;
}
.detail-more-details > .detail-more-body {
  display: contents;
}
.detail-more-details.hidden {
  display: none !important;
}
.map-tools-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  align-items: center;
  flex: 0 1 auto;
}
.map-tools-more-body {
  display: contents;
}
.toolbar-exports-more {
  display: contents;
}
.toolbar-exports-more > .toolbar-exports-summary {
  display: none;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.toolbar-exports-more > .toolbar-exports-summary::-webkit-details-marker {
  display: none;
}
.toolbar-exports-more > .toolbar-exports-body {
  display: contents;
}
/* Toast: base (fila controlada em JS) */
.toast {
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}
.toast.toast-show {
  transform: translateY(0);
}
.filter-hit {
  background: rgba(251, 191, 36, 0.35);
  color: inherit;
  padding: 0 0.12em;
  border-radius: 3px;
}
/* Ficha já aberta nesta sessão */
.ficha-row.row-viewed td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}
.ficha-row.row-viewed {
  opacity: 0.92;
}
.ficha-row.row-viewed:hover {
  opacity: 1;
}
.ficha-row.row-viewed .mono-id::after {
  content: ' · vista';
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 500;
  font-family: var(--font);
}
/* Favoritas (persistente no navegador) */
.ficha-row.row-fav td:first-child {
  box-shadow: inset 3px 0 0 var(--warn);
}
.ficha-row.row-fav.row-viewed td:first-child {
  box-shadow:
    inset 3px 0 0 var(--warn),
    inset 6px 0 0 var(--accent);
}
/* Ficha aberta no modal */
.ficha-row.row-open {
  background: var(--accent-soft) !important;
  outline: 1px solid rgba(59, 130, 246, 0.35);
}
.ficha-row.row-open td:last-child .btn-open {
  box-shadow: 0 0 0 1px var(--accent);
}
.td-check {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 3.2rem;
}
.btn-fav-row {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0.1rem 0.2rem;
  font-size: 0.95rem;
  line-height: 1;
  border-radius: 4px;
}
.btn-fav-row:hover {
  color: var(--warn);
  background: var(--warn-soft);
}
.btn-fav-row.is-fav {
  color: var(--warn);
}
#btn-detail-fav.is-fav {
  border-color: rgba(251, 191, 36, 0.55);
  color: var(--warn);
  background: var(--warn-soft);
}
#btn-favs-header {
  font-weight: 700;
  gap: 0.25rem;
  min-width: 2.75rem;
}
#btn-favs-header.has-favs {
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.45);
  background: var(--warn-soft);
}
#favs-header-count {
  font-variant-numeric: tabular-nums;
  font-size: 0.85em;
}
.kpi-clickable {
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    transform 0.12s ease;
}
.kpi-clickable:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.kpi-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.password-field {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.password-field input {
  flex: 1;
}
#login-error.login-info {
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(59, 130, 246, 0.35);
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
}
.bar-label {
  max-width: 7.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}
.row-sync-err {
  background: var(--danger-soft);
}
.tl-ficha-row {
  cursor: pointer;
}
.tl-ficha-row:hover {
  background: var(--accent-soft);
}
.pill-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
html[data-theme='light'] .filter-hit {
  background: rgba(245, 158, 11, 0.35);
}
.status-tl {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0 0 0 0.85rem;
  border-left: 2px solid var(--border);
}
.status-tl-title {
  margin-bottom: 0.25rem;
}
.status-tl-item {
  position: relative;
  padding: 0.35rem 0 0.55rem 0.85rem;
}
.status-tl-dot {
  position: absolute;
  left: -1.05rem;
  top: 0.55rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--muted);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.status-tl-item.is-latest .status-tl-dot {
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.status-tl-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.65rem;
  align-items: baseline;
  font-size: 0.84rem;
}
.status-tl-when {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.78rem;
  color: var(--muted);
}
.status-tl-meta {
  margin-top: 0.15rem;
}
.panel-intro {
  padding: 0.85rem 1.1rem;
  margin-bottom: 0.85rem;
  border-style: dashed;
}
.form-lead {
  margin: 0 0 0.85rem;
  max-width: 52rem;
}
.field-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85em;
}
.form-divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}
.chart-hint {
  margin: -0.35rem 0 0.65rem;
}
.list-kbd-details {
  margin-top: 0.5rem;
}
.list-kbd-details summary {
  cursor: pointer;
  user-select: none;
}
.list-kbd-details summary:hover {
  color: var(--text);
}
.filter-group-label {
  display: inline-flex;
  align-items: center;
  margin-right: 0.15rem;
}
.bulk-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.45rem;
  padding: 0.25rem 0.45rem;
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.25);
}
.bulk-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  width: 100%;
  margin: 0;
}
.twofa-steps {
  margin: 0.35rem 0 0.75rem 1.1rem;
  padding: 0;
}
.twofa-steps li {
  margin: 0.2rem 0;
}
.totp-login-hint {
  margin: 0 0 0.5rem;
}
.confirm-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.confirm-actions .btn-primary,
.confirm-actions .ghost,
.confirm-actions button {
  min-height: 2.35rem;
}
.confirm-esc-hint {
  margin: 0.55rem 0 0;
  text-align: right;
  font-size: 0.75rem;
}
.top-label-short {
  display: none;
}
@media (max-width: 800px) {
  .confirm-esc-hint {
    text-align: center;
  }
}
.dash-auto-refresh-hint {
  margin-top: 0.75rem;
}
.filter-chips-clear-all {
  margin-left: 0.25rem;
  align-self: center;
}
.timeline-card {
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 0.75rem;
}
.timeline-card-head {
  align-items: flex-start;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  padding-bottom: 0.5rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}
.timeline-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.timeline-section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.35rem 0 0.75rem;
}
.timeline-section-nav .timeline-jump {
  min-height: 2.1rem;
}
.timeline-section {
  scroll-margin-top: 4.5rem;
  margin-bottom: 1rem;
}
.timeline-section:last-child {
  margin-bottom: 0.25rem;
}
#timeline-meta.is-err {
  color: var(--danger);
}
#timeline-meta.is-ok {
  color: var(--ok);
}
.tl-ficha-row {
  cursor: pointer;
}
.tl-ficha-row:hover,
.tl-ficha-row:focus-visible {
  background: var(--accent-soft);
  outline: none;
}
.superadmin-bar {
  border-color: rgba(251, 191, 36, 0.35);
  background: linear-gradient(
    180deg,
    rgba(251, 191, 36, 0.06) 0%,
    var(--surface) 40%
  );
}
.superadmin-bar .list-card-head {
  margin-bottom: 0.65rem;
}
#btn-density[aria-pressed='true'] {
  border-color: rgba(59, 130, 246, 0.55);
  background: var(--accent-soft);
}
#btn-theme[aria-pressed='true'] {
  border-color: rgba(251, 191, 36, 0.45);
  background: var(--warn-soft);
}
.confirm-danger .confirm-panel,
.modal.confirm-danger .confirm-panel {
  border-color: rgba(248, 113, 113, 0.45);
}
.btn-confirm-danger,
button.btn-confirm-danger {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%) !important;
  color: #fff !important;
  border: 1px solid transparent !important;
  font-weight: 600;
}
.btn-confirm-danger:hover:not(:disabled) {
  filter: brightness(1.06);
}
.detail-loading {
  padding: 0.35rem 0 0.75rem;
}
.detail-loading .skeleton-row {
  margin: 0.45rem 0;
}
.status-tl-empty {
  margin: 0.35rem 0 0;
}
.detail-meta code {
  font-size: 0.82em;
}
.detail-meta .pill {
  vertical-align: middle;
}
/* Sticky thead em listas densas */
.table-wrap {
  position: relative;
}
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  box-shadow: 0 1px 0 var(--border);
}
.offline-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
}
.offline-banner .offline-retry {
  flex-shrink: 0;
}
.help-panel {
  max-width: min(640px, 94vw);
  margin: 6vh auto;
  position: relative;
  z-index: 2;
  max-height: min(80vh, 720px);
  overflow: auto;
}
.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem 1.25rem;
  margin: 0.5rem 0 0.75rem;
}
.help-list {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
}
.help-list li {
  margin: 0.25rem 0;
}
.help-foot {
  margin: 0.5rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}
.cmdk-item {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
}
.cmdk-item-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.cmdk-kind {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  margin-top: 0.15rem;
}
.cmdk-kind-tab {
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.12);
}
.cmdk-kind-action {
  color: #86efac;
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.1);
}
.cmdk-kind-ficha {
  color: #fcd34d;
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.1);
}
.cmdk-empty .cmdk-item-empty {
  cursor: default;
  opacity: 0.85;
}
html[data-theme='light'] .data-table thead th {
  background: #eef2f7;
}
.toolbar-exports.hidden,
.toolbar-hint.hidden {
  display: none !important;
}
#users-readonly-hint,
#team-readonly-hint,
#sync-reprocess-hint {
  border-style: dashed;
}
.quick-btn.hidden {
  display: none !important;
}
.btn-toggle-pw[aria-pressed='true'],
#btn-toggle-login-pass[aria-pressed='true'] {
  border-color: rgba(59, 130, 246, 0.45);
  background: var(--accent-soft);
}
.user-badge-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  margin: 0;
  padding: 0.2rem 0.45rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: right;
}
.user-badge-btn:hover,
.user-badge-btn:focus-visible {
  border-color: var(--border-strong);
  background: var(--surface-2);
  outline: none;
}
.chart-empty {
  margin: 0.75rem 0;
  text-align: center;
}
.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.profile-card .profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem 1.25rem;
  margin: 0.75rem 0 1rem;
}
.profile-name {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0.15rem 0;
}
.profile-kicker {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
  margin: 0;
}
.cap-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  background: var(--accent-soft);
  color: var(--text);
  border: 1px solid rgba(59, 130, 246, 0.25);
  margin: 0.15rem 0.2rem 0.15rem 0;
}
.toolbar-actions {
  flex-wrap: wrap;
  gap: 0.65rem;
}
.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.btn-primary,
button.btn-primary {
  background: linear-gradient(
    180deg,
    var(--accent) 0%,
    var(--accent-hover) 100%
  );
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}
.btn-primary:disabled {
  opacity: 0.65;
  cursor: wait;
}
button.ghost,
.ghost {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
button.ghost:hover,
.ghost:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}
.btn-danger-ghost {
  background: transparent !important;
  color: var(--danger, #ef4444) !important;
  border-color: var(--danger, #ef4444) !important;
}
.btn-danger-ghost:hover {
  background: var(--danger, #ef4444) !important;
  color: #fff !important;
}
.card h2 {
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 0.75rem;
}
.kpi .num {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.quick-btn {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.quick-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.advanced-acl {
  margin: 0.5rem 0 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  width: 100%;
}
.advanced-acl summary {
  cursor: pointer;
  margin-bottom: 0.5rem;
}
.nav-tab {
  text-align: left;
}
.map-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--ok);
  border: 2px solid #fff;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}
.map-dot.terr {
  background: #60a5fa;
}
.map-dot:hover {
  transform: scale(1.3);
}

/* Superadmin + parecer */
.superadmin-bar {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
}
.superadmin-bar summary {
  cursor: pointer;
  margin-top: 0.5rem;
}
.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.status-row .parecer-label {
  flex: 1 1 100%;
}
.status-row textarea {
  width: 100%;
  min-height: 4rem;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  font: inherit;
}

/* Enterprise DS: status badges, live, team */
.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: none;
}
.status-received {
  background: #1e3a5f;
  color: #93c5fd;
}
.status-in_review {
  background: #713f12;
  color: #fcd34d;
}
.status-validated {
  background: #064e3b;
  color: #6ee7b7;
}
.status-rejected {
  background: #7f1d1d;
  color: #fca5a5;
}
.status-archived {
  background: #374151;
  color: #d1d5db;
}
.status-history {
  margin: 0.75rem 0 0.25rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface, var(--card));
  max-height: 180px;
  overflow: auto;
  line-height: 1.45;
}
.empty-state {
  padding: 1.25rem 1rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
  margin: 0.25rem 0;
}
.empty-title {
  margin: 0 0 0.35rem;
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}
.empty-hint {
  margin: 0;
  line-height: 1.4;
}
/* Skeleton leve para carregamento de tabelas */
.skeleton-row {
  height: 0.85rem;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--border) 25%,
    #2a3548 50%,
    var(--border) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  margin: 0.35rem 0;
}
@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
.list-loading-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}
.list-loading-label {
  margin: 0 !important;
}
.ui-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ui-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes ui-spin {
  to {
    transform: rotate(360deg);
  }
}
.kpi-skeleton {
  display: inline-block;
  width: 2.4rem;
  height: 1.35rem;
  border-radius: 6px;
  vertical-align: middle;
  background: linear-gradient(
    90deg,
    var(--border) 25%,
    #2a3548 50%,
    var(--border) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.1s ease-in-out infinite;
}
.kpi-grid-loading .kpi {
  pointer-events: none;
  opacity: 0.92;
}
.tab-panel.panel-enter {
  animation: panel-enter 0.28s ease;
}
@keyframes panel-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.table-wrap {
  transition: opacity 0.18s ease;
}
table[aria-busy='true'] {
  opacity: 0.88;
}
.card {
  transition:
    box-shadow 0.18s ease,
    border-color 0.18s ease;
}
.nav-tab {
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}
.toast {
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}
@media (prefers-reduced-motion: reduce) {
  .ui-spinner,
  .kpi-skeleton,
  .skeleton-row {
    animation: none !important;
  }
  .tab-panel.panel-enter,
  .bar-row-enter,
  .ficha-row,
  .data-table tbody tr {
    animation: none !important;
  }
  .bar-fill {
    transition: none !important;
  }
}

/* Mobile: ignore “sidebar colapsada” (menu é horizontal) */
@media (max-width: 800px) {
  .dash-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }
  .dash-shell.sidebar-collapsed .sidebar-head-label {
    display: block;
  }
  .dash-shell.sidebar-collapsed .sidebar-nav .nav-tab {
    width: auto;
    justify-content: center;
    padding: 0.5rem 0.65rem;
    font-size: 0.8rem;
  }
  .dash-shell.sidebar-collapsed .sidebar-nav .nav-tab::before {
    margin: 0;
  }
}
.status-history ul {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}
.status-history li {
  margin: 0.2rem 0;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.5rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.checkbox-row input {
  width: auto;
  margin: 0;
}
.tenant-inactive-opt {
  color: var(--danger);
}
.pill-ok {
  background: #064e3b;
  color: #6ee7b7;
}
.pill-danger {
  background: #7f1d1d;
  color: #fca5a5;
}
.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}
.status-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.25rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
}
.status-pill-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.status-pill-btn strong {
  font-variant-numeric: tabular-nums;
}
.charts-row-3 {
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 1100px) {
  .charts-row-3 {
    grid-template-columns: 1fr;
  }
}
/* Densidade compacta — listas densas para operadores */
html[data-density='compact'] th,
html[data-density='compact'] td {
  padding: 0.35rem 0.4rem;
  font-size: 0.8rem;
}
html[data-density='compact'] .btn-sm {
  padding: 0.2rem 0.4rem;
  font-size: 0.7rem;
}
html[data-density='compact'] .card {
  padding: 0.75rem 0.85rem;
}
html[data-density='compact'] .kpi .num {
  font-size: 1.35rem;
}
html[data-density='compact'] .ficha-row {
  line-height: 1.25;
}
.live-indicator {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.4rem;
  margin: 0 0 0.75rem;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  max-width: 100%;
}
.live-indicator #live-text {
  font-weight: 600;
}
@media (max-width: 420px) {
  .live-indicator {
    width: 100%;
    font-size: 0.78rem;
  }
  .last-refresh {
    margin-left: 0;
    width: 100%;
    font-size: 0.72rem;
  }
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}
.live-on .live-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
}
.live-off .live-dot {
  background: #fbbf24;
}
.confirm-panel {
  max-width: 420px;
  margin: 10vh auto;
  position: relative;
  z-index: 2;
}
.btn-sm {
  font-size: 0.75rem;
  padding: 0.3rem 0.5rem;
  margin: 0.15rem;
}

/* Shell sidebar — produto municipal */
.dash-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0 1.25rem;
  max-width: 100%;
  margin: 0 auto;
  min-height: calc(100vh - 140px);
  align-items: start;
}
.dash-shell.sidebar-collapsed {
  grid-template-columns: 64px 1fr;
}
.sidebar {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  padding: 0.85rem 0.65rem 1rem;
  position: sticky;
  top: calc(var(--header-h) + 12px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 32px);
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
  padding: 0 0.35rem;
}
.sidebar-head-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidebar-foot {
  margin: 1rem 0.35rem 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  line-height: 1.35;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex-wrap: nowrap;
  border: none;
  margin: 0;
  padding: 0;
}
.sidebar-nav .nav-tab {
  width: 100%;
  text-align: left;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0.62rem 0.75rem;
  margin: 0;
  font-weight: 600;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.sidebar-nav .nav-tab::before {
  content: attr(data-icon);
  font-size: 0.85rem;
  opacity: 0.85;
  width: 1.1rem;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-nav .nav-tab.active {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.35);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.08);
}
.sidebar-nav .nav-tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-color: var(--border);
}
.sidebar-toggle {
  width: auto;
  margin: 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
}
.dash-main {
  padding: 0 0 1.5rem;
  min-width: 0;
}
.dash-shell.sidebar-collapsed .sidebar-head-label,
.dash-shell.sidebar-collapsed .sidebar-foot {
  display: none;
}
.dash-shell.sidebar-collapsed .sidebar-nav .nav-tab {
  font-size: 0;
  padding: 0.7rem 0.4rem;
  justify-content: center;
  gap: 0;
}
.dash-shell.sidebar-collapsed .sidebar-nav .nav-tab::before {
  font-size: 1rem;
  width: auto;
}
.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.checkbox-row input {
  width: auto;
  margin: 0;
}
/* —— Toolbar / botões / toast (UI profissional) —— */
.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.35rem;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.toolbar-actions button {
  margin-top: 0;
  font-size: 0.84rem;
  padding: 0.5rem 0.9rem;
}
.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.toolbar-end {
  margin-left: auto;
}
.toolbar-hint {
  margin: 0 0 0.85rem 0.15rem;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
/* Toast (z-index 1100) — above modals (1000) */
.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 1100;
  max-width: min(380px, 92vw);
  padding: 0.7rem 0.75rem 0.7rem 1rem;
  border-radius: 10px;
  background: var(--surface-2, #1e293b);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.toast-msg {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.35;
}
.toast-dismiss {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.75;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0.1rem 0.35rem;
  cursor: pointer;
  border-radius: 6px;
}
.toast-dismiss:hover,
.toast-dismiss:focus-visible {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}
.toast-show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.toast-ok {
  border-color: rgba(52, 211, 153, 0.5);
}
.toast-err {
  border-color: rgba(248, 113, 113, 0.55);
  color: #fecaca;
}

/* Banner de atualização do service worker */
.sw-update-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
  padding: 0.55rem 0.85rem;
  background: rgba(37, 99, 235, 0.18);
  border-bottom: 1px solid rgba(59, 130, 246, 0.45);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 70;
}
.sw-update-banner.hidden {
  display: none !important;
}
.btn-busy-spinner {
  width: 0.95rem;
  height: 0.95rem;
  display: inline-block;
  vertical-align: -0.15em;
  margin-right: 0.2rem;
}
#events-body tr {
  content-visibility: auto;
  contain-intrinsic-size: auto 44px;
}

/* Perfil: ações e permissões em telas estreitas */
.profile-login-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}
.profile-caps-wrap .list-card-head {
  gap: 0.5rem;
}
.profile-caps {
  overflow-y: visible;
  padding-right: 0.15rem;
}
.cap-chip {
  display: inline-flex;
  margin: 0.15rem 0.2rem 0.15rem 0;
}
/* Tabela: sombra sutil ao rolar horizontal */
.table-wrap {
  position: relative;
  background:
    linear-gradient(90deg, var(--surface) 30%, transparent) left center /
      1.25rem 100% no-repeat local,
    linear-gradient(270deg, var(--surface) 30%, transparent) right center /
      1.25rem 100% no-repeat local;
}
html[data-theme='light'] .table-wrap {
  background:
    linear-gradient(90deg, #fff 30%, transparent) left center / 1.25rem 100%
      no-repeat local,
    linear-gradient(270deg, #fff 30%, transparent) right center / 1.25rem 100%
      no-repeat local;
}
/* Foco em linha da lista de fichas */
#fichas-body tr.ficha-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--accent-soft);
}
/* KPI clicável: feedback de teclado */
.kpi[tabindex]:focus-visible,
.kpi.kpi-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (max-width: 560px) {
  .profile-login-actions .btn-sm {
    flex: 1 1 auto;
    min-height: 2.25rem;
    white-space: normal;
    line-height: 1.25;
    padding-inline: 0.6rem;
  }
}

/* Intro de abas */
.panel-intro.fichas-intro {
  margin-bottom: 0.85rem;
}
.toolbar-hint {
  line-height: 1.45;
}

/* Filtros locais equipe / técnicos */
.users-client-filters,
.team-client-filters {
  margin: 0.35rem 0 0.55rem;
  gap: 0.55rem 0.85rem;
}
.users-client-filters .checkbox-row,
.team-client-filters .checkbox-row {
  min-height: 2rem;
  align-items: center;
}
#users-body tr.hidden,
#team-body tr.hidden {
  display: none !important;
}
.list-head-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
@media (max-width: 640px) {
  .list-head-right {
    width: 100%;
  }
  .list-head-right .inline-search {
    width: 100%;
    max-width: none;
  }
  .list-head-right .btn-sm {
    flex: 1 1 auto;
    min-height: 2.25rem;
  }
}

/* Detalhe ficha — seções predial/territorial */
.field-section {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
}
.field-section-title {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.55rem 0.85rem;
}
.field-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  min-width: 0;
}
.field-item dt {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0 0 0.2rem;
}
.field-item dd {
  margin: 0;
  font-size: 0.9rem;
  word-break: break-word;
}
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}
.media-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.media-img {
  max-width: 100%;
  max-height: 240px;
  width: 100%;
  object-fit: contain;
  display: block;
  background: #0b1220;
}
.media-preview {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}
.modal-panel {
  max-width: min(920px, 96vw);
  max-height: 90vh;
  overflow: auto;
}
.kpi {
  transition:
    border-color 0.15s,
    transform 0.15s;
}
.kpi:hover {
  border-color: rgba(59, 130, 246, 0.45);
  transform: translateY(-1px);
}
.kpi .num {
  font-variant-numeric: tabular-nums;
}

/* KPI denser on large screens */
@media (min-width: 1100px) {
  .grid {
    grid-template-columns: repeat(7, 1fr);
  }
}

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0.75rem 0 1rem;
}
.modal-panel-detail {
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}
.detail-meta {
  margin: 0 0 0.85rem;
  line-height: 1.55;
}
.detail-fields-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
}
.detail-fields-head .section-label {
  margin: 0;
}
.detail-empty-toggle {
  margin: 0 !important;
  font-size: 0.82rem;
  color: var(--muted);
}
.detail-fields-wrap {
  display: block !important;
}
.ficha-fill-summary {
  margin: 0.35rem 0 0.85rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: var(--accent-soft);
  border: 1px solid rgba(59, 130, 246, 0.25);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  align-items: center;
}
.ficha-fill-summary .fill-pct {
  font-size: 0.78em;
  font-weight: 700;
  color: var(--accent, #3b82f6);
  margin-left: 0.2rem;
}
.ficha-fill-summary .fill-gps-ok {
  color: var(--ok, #16a34a);
  font-weight: 600;
}
.ficha-fill-summary .fill-gps-miss {
  color: var(--muted);
  font-style: italic;
}
#map-fichas-list .empty-state {
  margin: 0.5rem 0;
  padding: 0.75rem;
}
#map-fichas-list .empty-actions {
  margin-top: 0.35rem;
  margin-bottom: 0.5rem;
}
tr.filter-empty-row .empty-actions {
  margin-top: 0.35rem;
}
code.device-uuid {
  cursor: pointer;
}
code.device-uuid:hover {
  text-decoration: underline;
  color: var(--accent, #3b82f6);
}
button[aria-busy='true'] {
  opacity: 0.72;
  cursor: wait;
}
.login-last-hint {
  margin: -0.35rem 0 0.65rem;
  line-height: 1.4;
}
.profile-login-actions {
  margin-top: 0.35rem;
}
.profile-caps-count {
  font-weight: 500;
  opacity: 0.8;
}
.profile-2fa-line {
  margin-top: 0.35rem;
}
.twofa-status-line {
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: var(--bg-elevated, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}
.twofa-status-line.is-ok {
  border-color: rgba(34, 197, 94, 0.35);
}
.twofa-status-line.is-warn {
  border-color: rgba(245, 158, 11, 0.4);
}
.dash-refresh-age {
  display: inline;
  white-space: nowrap;
}
.panel-intro .section-label {
  letter-spacing: 0.01em;
}
.form-lead {
  line-height: 1.45;
}
#toolbar-hint strong {
  font-weight: 600;
}
.tl-event-ficha {
  cursor: pointer;
}
.tl-event-ficha:hover {
  background: var(--row-hover, rgba(59, 130, 246, 0.06));
}
.user-badge-btn {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.45rem;
  max-width: min(280px, 42vw);
  text-align: left;
}
.user-badge-tenant {
  font-size: 0.72rem;
  width: 100%;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmdk-kind-search {
  background: rgba(168, 85, 247, 0.18);
  color: #c4b5fd;
}
html[data-theme='light'] .cmdk-kind-search {
  background: rgba(124, 58, 237, 0.12);
  color: #6d28d9;
}
.cmdk-item-empty {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 0.85rem;
  opacity: 0.85;
}
.live-indicator.live-on .live-dot {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}
.confirm-danger #confirm-ok.btn-confirm-danger {
  border-color: rgba(239, 68, 68, 0.55);
}
.team-self-tag {
  display: inline-block;
  margin-left: 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--accent-soft, rgba(59, 130, 246, 0.15));
  color: var(--accent, #3b82f6);
  vertical-align: middle;
}
.field-section-count {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0;
  text-transform: none;
}
.field-item-empty {
  opacity: 0.55;
}
.field-item-empty dd {
  font-style: italic;
  color: var(--muted);
}
.field-section-sys {
  border-color: rgba(59, 130, 246, 0.35);
}
.empty-state {
  background: var(--bg-elevated) !important;
}

@media (max-width: 960px) {
  .login-shell {
    grid-template-columns: 1fr;
    max-width: 440px;
  }
  .login-hero {
    min-height: 200px;
    padding: 1.5rem;
  }
  .login-hero-title {
    max-width: none;
    font-size: 1.3rem;
  }
}

@media (max-width: 800px) {
  .dash-shell {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
  /* Drawer off-canvas (substitui sticky horizontal) */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(88vw, 300px);
    max-height: 100dvh;
    z-index: 95;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.85rem 0.65rem 1.25rem;
    border-radius: 0;
    border-right: 1px solid var(--border);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.35);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    will-change: transform;
  }
  .dash-shell.nav-drawer-active .sidebar {
    transform: translateX(0);
  }
  .sidebar-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.2rem;
    overflow: visible;
    scroll-snap-type: none;
  }
  .sidebar-nav .nav-tab {
    width: 100%;
    flex: none;
    white-space: normal;
    font-size: 0.9rem;
    padding: 0.7rem 0.8rem;
  }
  .sidebar-foot {
    display: block;
  }
  .sidebar-toggle {
    display: none !important;
  }
  .sidebar-drawer-close {
    display: inline-flex !important;
  }
  .nav-drawer-open {
    display: inline-flex !important;
  }
  body.nav-drawer-lock {
    overflow: hidden;
  }
  main {
    padding: 0.75rem 0.85rem 1.5rem;
  }
  .toolbar-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-end {
    margin-left: 0;
  }
  .toolbar-group {
    width: 100%;
  }
  .toolbar-group button {
    flex: 1 1 auto;
  }
  .toolbar-hint {
    font-size: 0.75rem;
  }
  .grid,
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .kpi .num {
    font-size: 1.35rem;
  }
  .map-box {
    height: clamp(220px, 42dvh, 380px);
    min-height: 220px;
  }
  @supports not (height: 1dvh) {
    .map-box {
      height: clamp(220px, 42vh, 380px);
    }
  }
  .map-basemap-row,
  .map-tools-row {
    gap: 0.4rem 0.65rem;
  }
  .map-tools-row .btn-sm,
  .map-tools-btns .btn-sm {
    flex: 1 1 auto;
    min-height: 2.25rem;
  }
  .map-tools-btns {
    width: 100%;
  }
  /* Mapa phone: bottom sheet app-like sob o mapa */
  .map-layout.has-side,
  .map-layout.has-both-sides {
    grid-template-columns: 1fr;
  }
  /* Quando ambos os painéis estão abertos, limitar altura para não estourar viewport */
  .map-layout.has-both-sides .map-fichas-list-panel,
  .map-layout.has-both-sides .map-feature-panel {
    max-height: min(28vh, 240px);
  }
  .map-fichas-list-panel,
  .map-feature-panel {
    max-height: min(42vh, 320px);
    border-radius: 16px 16px 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.28);
    position: relative;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  .map-fichas-list-panel::before,
  .map-feature-panel::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.55);
    margin: 0.45rem auto 0.35rem;
    flex-shrink: 0;
  }
  .map-box {
    order: -1;
  }
  /* Compactar “Mais…” no modal e toolbar em ≤800px */
  .detail-more-details {
    display: block;
    flex: 1 1 100%;
    width: 100%;
    margin: 0;
  }
  .detail-more-details > .detail-more-summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    width: 100%;
    box-sizing: border-box;
  }
  .detail-more-details > .detail-more-body {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
    width: 100%;
  }
  .detail-more-details > .detail-more-body .btn-sm {
    flex: 1 1 auto;
    min-height: 2.25rem;
  }
  .detail-more-details[open] > .detail-more-summary {
    border-color: rgba(59, 130, 246, 0.45);
    background: rgba(59, 130, 246, 0.08);
  }
  .map-tools-more.detail-more-details {
    flex: 1 1 100%;
  }
  .map-tools-more-body {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    width: 100%;
  }
  .toolbar-exports-more {
    display: block;
    flex: 1 1 100%;
    width: 100%;
  }
  .toolbar-exports-more > .toolbar-exports-summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.35rem;
    width: 100%;
    box-sizing: border-box;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.84rem;
    padding: 0.5rem 0.9rem;
  }
  .toolbar-exports-more > .toolbar-exports-body {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.35rem;
    width: 100%;
  }
  .toolbar-exports-more > .toolbar-exports-body button {
    flex: 1 1 calc(50% - 0.2rem);
    min-height: 2.35rem;
  }
  .toolbar-exports {
    width: 100%;
  }
  .toolbar-exports > #btn-export,
  .toolbar-exports > #btn-export-xls {
    flex: 1 1 calc(50% - 0.2rem);
    min-height: 2.35rem;
  }
  .modal-actions-primary,
  .modal-actions-secondary {
    width: 100%;
  }
  #btn-detail-close {
    width: 100%;
    min-height: 2.35rem;
  }
  .page-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .live-indicator {
    width: 100%;
    justify-content: flex-start;
  }
  .modal-panel {
    margin: 2vh auto;
    max-height: 96vh;
    border-radius: 12px 12px 0 0;
  }
  .fields-grid {
    grid-template-columns: 1fr;
  }
  .status-row {
    flex-direction: column;
    align-items: stretch;
  }
  .status-row label {
    min-width: 0;
    width: 100%;
  }
  .toast {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    max-width: none;
  }
  .table-wrap {
    margin: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  th,
  td {
    font-size: 0.8rem;
    padding: 0.45rem 0.3rem;
  }
  .page-header {
    margin-bottom: 0.75rem;
  }
  /* Bulk / detalhe / charts em telas estreitas */
  .bulk-bar {
    position: static;
    padding: 0.55rem 0.65rem;
    gap: 0.45rem;
  }
  .bulk-bar-top {
    width: 100%;
  }
  .bulk-primary-actions {
    width: 100%;
  }
  .bulk-group {
    width: 100%;
  }
  .bulk-copy-group {
    width: 100%;
  }
  .bulk-copy-group .btn-sm,
  .bulk-copy-group button {
    flex: 1 1 auto;
    min-height: 2.25rem;
  }
  .bulk-parecer {
    max-width: none;
    width: 100%;
    flex: 1 1 100%;
  }
  /* Bulk: grupos colapsáveis no mobile */
  .bulk-label-desk {
    display: none !important;
  }
  .bulk-label-mobi {
    display: flex !important;
  }
  .bulk-more-details.detail-more-details {
    display: block;
    width: 100%;
    flex: 1 1 100%;
    margin: 0;
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 8px;
    padding: 0.35rem 0.45rem;
    background: rgba(15, 23, 42, 0.12);
  }
  .bulk-more-details > .detail-more-summary {
    display: flex !important;
    align-items: center;
    width: 100%;
    min-height: 2.15rem;
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text);
    margin: 0;
    user-select: none;
  }
  .bulk-more-details > .detail-more-summary::-webkit-details-marker {
    display: none;
  }
  .bulk-more-details > .detail-more-body {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
    width: 100%;
  }
  .bulk-more-details[open] {
    border-color: rgba(59, 130, 246, 0.45);
  }
  .bulk-status-group {
    width: 100%;
  }
  /* Status em lote colapsável no mobile (economiza altura da sticky bar) */
  .bulk-status-wrap.detail-more-details {
    display: block;
    width: 100%;
    flex: 1 1 100%;
    margin: 0;
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 8px;
    padding: 0.4rem 0.5rem;
    background: rgba(15, 23, 42, 0.12);
  }
  .bulk-status-wrap > .bulk-status-summary {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 2.25rem;
    box-sizing: border-box;
    font-weight: 600;
    font-size: 0.82rem;
  }
  .bulk-status-wrap > .bulk-status-body {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: stretch;
    margin-top: 0.45rem;
    width: 100%;
  }
  .bulk-status-wrap .bulk-status-desk-label {
    display: none;
  }
  .bulk-status-wrap .bulk-status-label {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  .bulk-status-wrap .bulk-status-label select {
    width: 100%;
    min-width: 0;
    min-height: 2.35rem;
  }
  .bulk-status-wrap .bulk-parecer {
    width: 100%;
    min-height: 2.35rem;
  }
  .bulk-status-wrap #btn-bulk-apply {
    width: 100%;
    min-height: 2.4rem;
  }
  .bulk-status-wrap[open] {
    border-color: rgba(59, 130, 246, 0.55);
  }
  /* Um único acordeão “Mais seleção e exportação” no mobile */
  .bulk-secondary-wrap.detail-more-details {
    display: block;
    width: 100%;
    flex: 1 1 100%;
    margin: 0;
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    padding: 0.4rem 0.5rem;
    background: rgba(15, 23, 42, 0.1);
  }
  .bulk-secondary-wrap > .bulk-secondary-summary {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 2.25rem;
    box-sizing: border-box;
    font-weight: 600;
    font-size: 0.82rem;
  }
  .bulk-secondary-wrap > .bulk-secondary-body {
    display: flex !important;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.45rem;
    width: 100%;
  }
  .bulk-secondary-wrap[open] {
    border-color: rgba(59, 130, 246, 0.5);
  }
  /* Dentro do wrap mobile, sub-grupos ficam sempre abertos (sem double accordion) */
  .bulk-secondary-wrap .bulk-more-details.detail-more-details {
    display: contents;
    border: none;
    padding: 0;
    background: transparent;
  }
  .bulk-secondary-wrap .bulk-label-desk {
    display: block !important;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    margin: 0.15rem 0 0.2rem;
  }
  .bulk-secondary-wrap .bulk-label-mobi {
    display: none !important;
  }
  .bulk-secondary-wrap .bulk-more-details > .detail-more-body {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.35rem;
    width: 100%;
  }
  .filter-more-details.detail-more-details {
    display: block;
    width: 100%;
    flex: 1 1 100%;
    grid-column: 1 / -1;
  }
  .filter-more-details > .detail-more-summary {
    display: inline-flex;
    width: 100%;
    min-height: 2.35rem;
    justify-content: center;
  }
  .filter-more-details > .detail-more-body {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.35rem;
    width: 100%;
  }
  .filter-more-details > .detail-more-body button {
    flex: 1 1 auto;
    min-height: 2.35rem;
  }
  .filter-actions-primary {
    width: 100%;
    grid-column: 1 / -1;
  }
  .filter-actions-primary button {
    flex: 1 1 auto;
    min-height: 2.35rem;
  }
  #panel-fichas .list-head-right {
    width: 100%;
    flex-wrap: wrap;
  }
  #panel-fichas .list-head-right .sort-label {
    flex: 1 1 auto;
    min-width: 8rem;
  }
  #panel-fichas .list-head-right .btn-sm {
    flex: 1 1 auto;
    min-height: 2.25rem;
  }
  .timeline-card-head {
    flex-direction: column;
    align-items: stretch;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--surface);
    padding: 0.5rem 0 0.55rem;
    margin: 0 0 0.35rem;
    box-shadow: 0 6px 12px -8px rgba(0, 0, 0, 0.35);
  }
  .timeline-head-actions {
    width: 100%;
    justify-content: stretch;
  }
  .timeline-head-actions .btn-sm {
    flex: 1 1 auto;
    min-height: 2.25rem;
  }
  .timeline-section-nav {
    width: 100%;
    position: sticky;
    top: 5.25rem;
    z-index: 4;
    background: var(--surface);
    padding: 0.35rem 0 0.45rem;
    margin: 0 0 0.65rem;
    border-bottom: 1px solid var(--border);
  }
  .timeline-section-nav .timeline-jump {
    flex: 1 1 auto;
    min-height: 2.25rem;
  }
  .timeline-section {
    scroll-margin-top: 8.5rem;
  }
  .confirm-panel {
    margin: 8vh auto 2vh;
    max-width: min(420px, 94vw);
    width: 100%;
  }
  .confirm-actions {
    flex-direction: column-reverse;
    align-items: stretch;
    width: 100%;
  }
  .confirm-actions button {
    width: 100%;
    min-height: 2.45rem;
  }
  .field-pw-panel {
    margin: 4vh auto 2vh;
    max-width: min(440px, 96vw);
  }
  .action-group .btn-sm {
    flex: 1 1 auto;
    min-height: 2.15rem;
  }
  .modal-panel-detail .modal-head {
    flex-direction: column;
    align-items: stretch;
  }
  .modal-head-actions {
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .modal-actions-group {
    flex-wrap: wrap;
    width: 100%;
  }
  .detail-emit-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .detail-emit-actions .btn-sm {
    flex: 1 1 auto;
    min-height: 2.25rem;
  }
  .charts-row,
  .charts-row-3 {
    grid-template-columns: 1fr !important;
  }
  .quick-actions {
    gap: 0.35rem;
  }
  .quick-btn {
    flex: 1 1 auto;
    min-height: 2.35rem;
    font-size: 0.82rem;
  }
  .filters label {
    min-width: 0;
  }
  .inline-search {
    width: 100%;
    max-width: none;
  }
  .list-head-right {
    flex-wrap: wrap;
    width: 100%;
    gap: 0.4rem;
  }
  .pagination {
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: center;
  }
  .page-jump-input {
    width: 3.5rem;
  }
  .action-group {
    flex-wrap: wrap;
  }
  .action-group .btn-sm {
    flex: 1 1 auto;
    min-height: 2.15rem;
  }
  /* Equipe do painel: papel/convite colapsável no mobile */
  .action-more.detail-more-details {
    display: block;
    flex: 1 1 100%;
    width: 100%;
    margin: 0;
  }
  .action-more > .detail-more-summary {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 2.15rem;
    box-sizing: border-box;
    cursor: pointer;
    list-style: none;
  }
  .action-more > .detail-more-summary::-webkit-details-marker {
    display: none;
  }
  .action-more > .detail-more-body,
  .action-more > .action-group-nested {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
    width: 100%;
  }
  .action-more[open] > .detail-more-summary {
    border-color: rgba(59, 130, 246, 0.45);
    background: rgba(59, 130, 246, 0.08);
  }
  .filter-chips {
    gap: 0.35rem;
  }
  .filter-chip {
    max-width: 100%;
  }
  .filter-chip span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: min(70vw, 16rem);
  }
  .superadmin-bar .filters {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .user-badge {
    font-size: 0.75rem;
    max-width: 48vw;
  }
  .user-badge-tenant {
    display: none;
  }
  .logo {
    font-size: 1.05rem;
  }
  .sub {
    display: none;
  }
  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .login-shell {
    margin-top: 0.5rem;
  }
  .login-card {
    padding: 1rem 0.9rem;
  }
  .login-card h1 {
    font-size: 1.25rem;
  }
  .kbd-hint {
    display: none;
  }
  .top-action {
    padding: 0.35rem 0.5rem;
  }
  .toolbar-label {
    display: none;
  }
  .tb-label-full {
    display: none;
  }
  .tb-label-short {
    display: inline;
  }
  /* Short no header: !important evita conflito com regras genéricas */
  .top-action .top-label-full,
  .top-label-full {
    display: none !important;
  }
  .top-action .top-label-short,
  .top-label-short {
    display: inline !important;
  }
  #btn-refresh,
  #btn-toolbar-search,
  #btn-toolbar-help,
  #btn-copy-portal-url,
  #btn-theme,
  #btn-density,
  #btn-logout {
    min-width: 2.4rem;
    min-height: 2.35rem;
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }
  #btn-copy-portal-url .tb-label-full {
    display: none;
  }
  #btn-copy-portal-url .tb-label-short {
    display: inline;
  }
  .top-right {
    gap: 0.25rem;
  }
  #btn-favs-header {
    min-height: 2.35rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  .user-badge {
    max-width: 36vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .page-title {
    font-size: 1.25rem;
  }
  .page-desc {
    font-size: 0.8rem;
  }
  /* no desktop estreito o label de status em lote some; os do bulk mobile usam summary */
  .bulk-status-group > .bulk-group-label {
    display: none;
  }
  .bulk-label-full {
    display: none;
  }
  .bulk-label-short {
    display: inline;
  }
  .bulk-count {
    width: 100%;
    min-width: 0;
    font-size: 0.85rem;
  }
  .bulk-primary-actions .btn-sm {
    flex: 1 1 calc(50% - 0.25rem);
    min-height: 2.35rem;
  }
  .bulk-status-summary .bulk-label-full {
    display: none;
  }
  .bulk-status-summary .bulk-label-short {
    display: inline;
  }
  #btn-bulk-apply .bulk-label-full {
    display: none;
  }
  #btn-bulk-apply .bulk-label-short {
    display: inline;
  }
  /* Tabelas: colunas menos críticas em telefone */
  #team-table th.col-2fa,
  #team-table td:nth-child(5),
  #devices-table th.col-app-ver,
  #devices-table td:nth-child(3),
  #audit-table th.col-ip,
  #audit-table td:nth-child(5),
  #sync-table th.col-http,
  #sync-table td:nth-child(3),
  #users-table th:nth-child(3),
  #users-table td:nth-child(3) {
    display: none;
  }
  .map-fichas-list-panel,
  .map-feature-panel {
    max-height: min(34vh, 260px);
  }
  .map-layout-narrow-feature #map-box {
    min-height: 200px;
  }
  .account-section-nav .account-jump {
    flex: 1 1 calc(50% - 0.25rem);
    text-align: center;
  }
  .detail-emit-hint {
    display: none;
  }
  .modal-panel-detail .modal-actions-group {
    width: 100%;
  }
  .modal-panel-detail .modal-actions-group .btn-sm {
    flex: 1 1 auto;
  }
  #btn-toolbar-help {
    /* em telas muito estreitas o atalho ? no teclado ainda existe */
    min-width: 0;
  }
  .page-kicker {
    font-size: 0.68rem;
  }
  .dash-auto-refresh-hint {
    font-size: 0.75rem;
    line-height: 1.35;
  }
  .filter-group-label {
    display: none;
  }
  .list-card-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }
  .list-card-head .muted.small {
    font-size: 0.75rem;
  }
  .toolbar-hint {
    display: none;
  }
  #btn-print-ficha,
  #btn-export-ficha-pdf-file {
    flex: 1 1 100%;
  }
  .modal-panel-detail {
    margin: 0;
    max-height: 100dvh;
    border-radius: 0;
  }
  @supports not (height: 1dvh) {
    .modal-panel-detail {
      max-height: 100vh;
    }
  }
}

/* Foco visível em chips de filtro (touch/teclado) */
.filter-chip:focus-visible,
.account-jump:focus-visible,
.quick-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tb-label-short {
  display: none;
}
.toolbar-label {
  align-self: center;
  margin-right: 0.15rem;
  white-space: nowrap;
}
.profile-card .profile-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.4fr;
  gap: 1rem 1.25rem;
  margin: 0.75rem 0 0.5rem;
}
@media (max-width: 800px) {
  .profile-card .profile-grid {
    grid-template-columns: 1fr;
  }
}
.profile-kicker {
  margin: 0 0 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
  font-weight: 700;
}
.profile-name {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.profile-role {
  margin: 0;
}
.profile-caps {
  justify-content: flex-start !important;
  overflow: visible;
}
.print-note {
  font-size: 0.85rem;
  margin: 0.5rem 0 1rem;
  padding: 0.5rem 0.65rem;
  border-left: 3px solid var(--accent);
  background: rgba(0, 0, 0, 0.04);
}
.print-media-list {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
}
.print-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
}
.print-photo {
  margin: 0;
  border: 1px solid #ccc;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.print-photo img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: #f8fafc;
}
.print-photo figcaption {
  font-size: 0.75rem;
  padding: 0.25rem 0.4rem;
  color: #333;
  border-top: 1px solid #eee;
}
.detail-agili-box {
  margin: 0.35rem 0 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  line-height: 1.4;
}
/* Edição: esconde inputs fora do modo editar (evita campos duplicados) */
.ficha-edit-input,
.ficha-edit-wrap {
  display: none !important;
}
.ficha-edit-mode .field-display {
  display: none !important;
}
.ficha-edit-mode .ficha-edit-input {
  display: block !important;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.35rem 0.45rem !important;
  font-size: 0.85rem;
}
.ficha-edit-mode .ficha-edit-wrap {
  display: flex !important;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.ficha-edit-mode .field-item {
  border-color: rgba(59, 130, 246, 0.35);
}
.field-required {
  margin-left: 0.2rem;
  color: var(--danger, #dc2626);
  font-weight: 800;
}
.ficha-edit-mode .ficha-edit-input[aria-invalid='true'] {
  border-color: var(--danger, #dc2626) !important;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.18) !important;
}
.field-display {
  display: block;
  line-height: 1.35;
}
.status-card.status-row,
#detail-status-row.status-card {
  display: grid;
  grid-template-columns: minmax(140px, 180px) 1fr auto;
  gap: 0.65rem 0.85rem;
  align-items: end;
}
@media (max-width: 720px) {
  #detail-status-row.status-card {
    grid-template-columns: 1fr;
  }
}
#detail-status-row .parecer-label {
  grid-column: span 1;
}
#detail-status-row #detail-parecer-atual,
#detail-status-row #status-msg {
  grid-column: 1 / -1;
}
.modal-panel-detail .modal-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-panel-detail {
  max-width: min(980px, 98vw);
}
.ficha-fill-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  align-items: center;
}
.map-layer-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
}
.map-layer-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  cursor: pointer;
  color: var(--muted);
  user-select: none;
}
.map-layer-toggle input {
  width: auto;
  margin: 0;
}
.map-layer-heavy {
  color: var(--warn);
}
@media print {
  .print-note {
    border: none;
    padding: 0;
    background: none;
  }
  .print-photo img {
    max-height: 280px;
  }
}

.kpi-total-card {
  position: relative;
}
.kpi-new-badge {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  margin: 0;
  padding: 0.15rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid rgba(52, 211, 153, 0.45);
  background: var(--ok-soft);
  color: var(--ok);
  cursor: pointer;
}
.kpi-new-badge:hover {
  filter: brightness(1.08);
}
.detail-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.35rem 0 0.75rem;
}

/* Offline banner */
.offline-banner {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #7f1d1d;
  color: #fecaca;
  text-align: center;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-bottom: 1px solid #991b1b;
}
.last-refresh {
  margin-left: 0.35rem;
  opacity: 0.85;
  font-size: 0.78rem;
}

/* —— Top actions / theme —— */
.top-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.top-action {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.kbd-hint {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  opacity: 0.75;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
  background: var(--bg);
}
.kbd {
  font-family: var(--font-mono);
  font-size: 0.72em;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05rem 0.28rem;
  background: var(--surface);
}
.user-badge-caps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.profile-caps .cap-chip,
.user-badge-caps .cap-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.25);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
html[data-theme='light'] .profile-caps .cap-chip {
  color: #1d4ed8;
}
.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
/* Papel e convite: no desktop fica inline; no mobile vira acordeão */
.action-more.detail-more-details {
  display: contents;
}
.action-more > .detail-more-summary {
  display: none;
}
.action-more > .detail-more-body {
  display: contents;
}
.action-group-nested {
  display: contents;
}
.team-self-hint {
  white-space: nowrap;
}
.action-group .btn-sm {
  white-space: nowrap;
}
.modal-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  align-items: center;
  justify-content: flex-end;
  max-width: min(720px, 100%);
}
.modal-actions-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding: 0.2rem 0.35rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.detail-fields-wrap .field-section {
  margin: 0 0 1rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.detail-fields-wrap .field-section-title {
  margin: 0 0 0.65rem;
  font-size: 0.92rem;
}
.detail-fields-wrap .fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.55rem 0.85rem;
}
/* estilos base; regras finais em “Pop-up Leaflet + painel de lote” abaixo */
.gis-popup {
  font-size: 12px;
  line-height: 1.35;
  max-width: 100%;
}
.leaflet-popup-content-wrapper {
  border-radius: 12px;
}

/* —— Bulk selection —— */
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  padding: 0.65rem 0.85rem;
  margin: 0 0 0.75rem;
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  position: sticky;
  /* abaixo do top bar se o scroll for da página */
  top: 0.35rem;
  z-index: 5;
  max-width: 100%;
  box-sizing: border-box;
}
.bulk-bar-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  width: 100%;
}
.bulk-primary-actions {
  flex: 1 1 auto;
}
.bulk-count {
  font-weight: 700;
  font-size: 0.88rem;
  min-width: 7rem;
}
.bulk-copy-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
/* Desktop: bulk secundário colapsável (“Mais seleção e exportação”) */
.bulk-label-mobi {
  display: none;
}
.bulk-label-short {
  display: none;
}
.bulk-more-details.detail-more-details {
  display: block;
  margin: 0.25rem 0;
}
.bulk-more-details > .detail-more-summary {
  display: inline-flex;
  align-items: center;
  list-style: none;
  cursor: pointer;
  min-height: 2rem;
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.78rem;
  font-weight: 600;
}
.bulk-more-details > .detail-more-summary::-webkit-details-marker {
  display: none;
}
.bulk-more-details:not([open]) > .detail-more-body {
  display: none;
}
.bulk-more-details[open] > .detail-more-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}
/* Wrapper: um único acordeão no desktop (barra menos longa) */
.bulk-secondary-wrap.detail-more-details {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
}
.bulk-secondary-wrap > .bulk-secondary-summary {
  display: inline-flex;
  align-items: center;
  list-style: none;
  cursor: pointer;
  min-height: 2.1rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.82rem;
  font-weight: 600;
}
.bulk-secondary-wrap > .bulk-secondary-summary::-webkit-details-marker {
  display: none;
}
.bulk-secondary-wrap:not([open]) > .bulk-secondary-body {
  display: none;
}
.bulk-secondary-wrap[open] > .bulk-secondary-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  margin-top: 0.45rem;
  align-items: flex-start;
}
.bulk-secondary-wrap .bulk-label-desk {
  display: none;
}
.bulk-status-wrap.detail-more-details {
  display: block;
  margin-top: 0.35rem;
}
.bulk-status-wrap > .bulk-status-summary {
  display: inline-flex;
  align-items: center;
  list-style: none;
  cursor: pointer;
  min-height: 2.1rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.82rem;
  font-weight: 600;
}
.bulk-status-wrap > .bulk-status-summary::-webkit-details-marker {
  display: none;
}
.bulk-status-wrap:not([open]) > .bulk-status-body {
  display: none;
}
.bulk-status-wrap[open] > .bulk-status-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.45rem;
  align-items: flex-end;
}
.bulk-status-wrap .bulk-status-desk-label {
  display: none;
}
.bulk-status-wrap.hidden {
  display: none !important;
}
.filter-more-details.detail-more-details {
  display: contents;
}
.filter-actions-primary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}
.bulk-status-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
}
.bulk-status-group.hidden {
  display: none !important;
}
.bulk-status-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 !important;
}
.bulk-status-label select {
  width: auto;
  min-width: 140px;
  margin: 0 !important;
  padding: 0.35rem 0.5rem !important;
  font-size: 0.82rem;
}
.bulk-parecer {
  flex: 1 1 160px;
  min-width: 140px;
  max-width: 280px;
  margin: 0 !important;
  padding: 0.4rem 0.55rem !important;
  font-size: 0.82rem;
}
.th-check {
  width: 2.2rem;
  text-align: center;
}
.th-check input,
.td-check input {
  width: auto;
  margin: 0;
  cursor: pointer;
}
.td-check {
  text-align: center;
  vertical-align: middle;
}
.ficha-row.row-selected {
  background: var(--accent-soft);
}

/* —— Command palette (Ctrl+K) —— */
.cmdk-modal .cmdk-panel {
  max-width: 520px;
  margin: 12vh auto 0;
  padding: 1rem 1.1rem 0.85rem;
  position: relative;
  z-index: 2;
}
.cmdk-hint-short {
  display: none;
}
@media (max-width: 800px) {
  .cmdk-modal .cmdk-panel {
    max-width: min(520px, 96vw);
    margin: 4vh auto 0;
    padding: 0.85rem 0.9rem 0.75rem;
    border-radius: 12px;
  }
  #cmdk-input {
    font-size: 1.05rem;
    min-height: 2.65rem;
    padding: 0.75rem 0.9rem;
  }
  .cmdk-results {
    max-height: min(55vh, 380px);
  }
  .cmdk-item {
    min-height: 2.75rem;
    padding: 0.55rem 0.7rem;
  }
  .cmdk-hint-full {
    display: none;
  }
  .cmdk-hint-short {
    display: inline;
  }
  .help-panel {
    margin: 3vh auto;
    max-height: min(92vh, 720px);
    max-width: min(640px, 96vw);
  }
  .offline-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    padding: 0.55rem 0.75rem;
    gap: 0.45rem;
  }
  .offline-banner .offline-retry {
    width: 100%;
    min-height: 2.4rem;
  }
  .offline-banner-text {
    font-size: 0.85rem;
    line-height: 1.35;
  }
}
.cmdk-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.45rem;
  display: block;
}
#cmdk-input {
  width: 100%;
  margin: 0 0 0.65rem;
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
}
#cmdk-input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.cmdk-results {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.cmdk-results li {
  margin: 0;
  border-bottom: 1px solid var(--border);
}
.cmdk-results li:last-child {
  border-bottom: none;
}
.cmdk-item {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  border-radius: 0;
}
.cmdk-item:hover,
.cmdk-item.cmdk-active {
  background: var(--accent-soft);
}
.cmdk-item-title {
  font-weight: 600;
  font-size: 0.92rem;
}
.cmdk-item-meta {
  font-size: 0.75rem;
  color: var(--muted);
}
.cmdk-hint {
  margin: 0.55rem 0 0;
  text-align: center;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* —— Tema claro (secretaria / impressão diurna) —— */
html[data-theme='light'] {
  color-scheme: light;
  --bg: #f4f6fa;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --border: #d5dde8;
  --border-strong: #b8c4d6;
  --text: #0f172a;
  --muted: #5b6b82;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.12);
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 4px 16px rgba(15, 23, 42, 0.06);
}
html[data-theme='light'] body {
  background:
    radial-gradient(
      900px 480px at 8% -8%,
      rgba(37, 99, 235, 0.08) 0%,
      transparent 55%
    ),
    var(--bg);
}
html[data-theme='light'] .top {
  background: rgba(255, 255, 255, 0.9);
}
html[data-theme='light'] .status-received {
  background: #dbeafe;
  color: #1e40af;
}
html[data-theme='light'] .status-in_review {
  background: #fef3c7;
  color: #92400e;
}
html[data-theme='light'] .status-validated {
  background: #d1fae5;
  color: #065f46;
}
html[data-theme='light'] .status-rejected {
  background: #fee2e2;
  color: #991b1b;
}
html[data-theme='light'] .status-archived {
  background: #e5e7eb;
  color: #374151;
}
html[data-theme='light'] .cap-chip {
  color: #1d4ed8;
}
html[data-theme='light'] .th-sortable.sort-active {
  color: #1d4ed8;
}
html[data-theme='light'] .login-hero {
  background:
    linear-gradient(160deg, rgba(37, 99, 235, 0.12) 0%, transparent 50%),
    linear-gradient(180deg, #e8eef8 0%, #f8fafc 100%);
}
html[data-theme='light'] .login-hero-title {
  color: var(--text);
}
html[data-theme='light'] .skeleton-row {
  background: linear-gradient(90deg, #e5eaf2 25%, #f1f5f9 50%, #e5eaf2 75%);
  background-size: 200% 100%;
}
html[data-theme='light'] th {
  background: #eef2f7;
}
html[data-theme='light'] .toast {
  background: var(--surface-2, #f0f3f8);
  border-color: var(--border, #d5dde8);
  color: var(--text, #0f172a);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
}

/* —— Lightbox mídia (galeria) —— */
.media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 3.5rem;
  backdrop-filter: blur(4px);
}
.media-lightbox-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: min(96vw, 1100px);
  gap: 0.45rem;
}
.media-lightbox-img {
  max-width: min(92vw, 1100px);
  max-height: min(82vh, 900px);
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  object-fit: contain;
  background: #111;
}
.media-lightbox-caption {
  margin: 0;
  color: #e2e8f0;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}
.media-lightbox-counter {
  margin: 0;
  color: #94a3b8 !important;
}
.media-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.1rem;
  min-width: 2.4rem;
  z-index: 2;
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.35) !important;
}
.media-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1.6rem;
  line-height: 1;
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.35) !important;
  background: rgba(15, 23, 42, 0.55) !important;
  border-radius: 999px;
  padding: 0;
}
.media-lightbox-nav:hover {
  background: rgba(37, 99, 235, 0.85) !important;
}
.media-lightbox-prev {
  left: 0.75rem;
}
.media-lightbox-next {
  right: 0.75rem;
}
.media-lightbox-nav.hidden {
  display: none !important;
}
.media-lightbox-actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.media-lightbox-dl {
  background: rgba(15, 23, 42, 0.75) !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
  color: #fff !important;
}
#status-msg.is-ok,
#field-pw-msg.is-ok,
#twofa-msg.is-ok,
#cp-msg.is-ok,
#team-create-msg.is-ok,
#user-create-msg.is-ok,
#tenant-msg.is-ok,
#forgot-msg.is-ok,
#reset-msg.is-ok,
#sa-create-msg.is-ok,
#sa-manage-msg.is-ok,
#sa-switch-msg.is-ok,
#tenant-select-msg.is-ok {
  color: var(--ok);
}
#status-msg.is-err,
#field-pw-msg.is-err,
#twofa-msg.is-err,
#cp-msg.is-err,
#team-create-msg.is-err,
#user-create-msg.is-err,
#tenant-msg.is-err,
#forgot-msg.is-err,
#reset-msg.is-err,
#sa-create-msg.is-err,
#sa-manage-msg.is-err,
#sa-switch-msg.is-err,
#tenant-select-msg.is-err {
  color: var(--danger);
}
.logo-preview-meta {
  font-size: 0.82rem;
  color: var(--muted);
}
.kpi-clickable {
  cursor: pointer;
  transition:
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    transform 0.12s ease;
}
.kpi-clickable:hover,
.kpi-clickable:focus-visible {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
  outline: none;
}
.kpi-hint {
  display: block;
  font-size: 0.72rem;
  margin-top: 0.15rem;
  opacity: 0.75;
  line-height: 1.2;
}
.kpi-is-zero .num {
  opacity: 0.55;
}
.kpi-is-alert {
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.45);
}
.kpi-is-warn-on {
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.4);
}
.kpi-clickable:active {
  transform: translateY(1px);
}
.row-sync-ok td {
  /* leve contraste em linhas OK */
}
tr.row-sync-err {
  background: rgba(248, 113, 113, 0.06);
}
.bulk-parecer:focus-visible {
  border-color: rgba(59, 130, 246, 0.55);
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.bulk-parecer-required {
  border-color: rgba(248, 113, 113, 0.55) !important;
  background: rgba(248, 113, 113, 0.06);
}
.detail-list-pos:not(.hidden) {
  font-variant-numeric: tabular-nums;
  min-width: 5.5rem;
  text-align: center;
}
.detail-edit-banner {
  margin: 0.5rem 0 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.12);
  font-size: 0.85rem;
  line-height: 1.4;
}
.detail-edit-banner.hidden {
  display: none !important;
}
.ficha-edit-mode .ficha-edit-input:not(:disabled) {
  border-color: rgba(59, 130, 246, 0.55);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2);
}
@media (max-width: 640px) {
  .media-lightbox {
    padding: 3rem 0.5rem 1.5rem;
  }
  .media-lightbox-nav {
    top: auto;
    bottom: 1rem;
    transform: none;
  }
  .media-lightbox-prev {
    left: 25%;
  }
  .media-lightbox-next {
    right: 25%;
  }
}

/* —— Print ficha —— */
.print-root {
  display: none;
}
@media print {
  @page {
    margin: 12mm;
  }
  body * {
    visibility: hidden !important;
  }
  .print-root,
  .print-root * {
    visibility: visible !important;
  }
  .print-root {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 0.5rem 0.75rem 1.5rem;
    color: #111 !important;
    background: #fff !important;
    font-size: 10.5pt;
    line-height: 1.35;
    font-family: 'Segoe UI', system-ui, sans-serif;
  }
  .print-header {
    margin-bottom: 0.75rem;
    border-bottom: 2px solid #1d4ed8;
    padding-bottom: 0.5rem;
  }
  .print-brand {
    margin: 0 0 0.2rem;
    font-size: 9pt;
    color: #1d4ed8;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .print-root h1 {
    font-size: 15pt;
    margin: 0 0 0.35rem;
    color: #0f172a;
  }
  .print-root h2 {
    font-size: 11pt;
    margin: 0 0 0.45rem;
    color: #1e3a8a;
    border-bottom: 1px solid #cbd5e1;
    padding-bottom: 0.2rem;
  }
  .print-section {
    break-inside: avoid;
    margin: 0.75rem 0 0.5rem;
  }
  .print-meta {
    color: #334155;
    margin: 0 0 0.4rem;
    font-size: 9.5pt;
  }
  .print-note {
    font-size: 8.5pt;
    color: #475569;
    margin: 0.25rem 0 0;
  }
  .print-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem 0.85rem;
  }
  .print-field {
    break-inside: avoid;
  }
  .print-field dt {
    font-weight: 700;
    font-size: 8.5pt;
    color: #475569;
  }
  .print-field dd {
    margin: 0 0 0.3rem;
    color: #0f172a;
  }
  .print-field.print-empty dd {
    color: #94a3b8;
  }
  .print-photos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }
  .print-photo {
    margin: 0;
    break-inside: avoid;
  }
  .print-photo img {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    border: 1px solid #cbd5e1;
  }
  .print-photo figcaption {
    font-size: 8pt;
    color: #64748b;
  }
  .print-footer {
    margin-top: 1.25rem;
    font-size: 8.5pt;
    color: #64748b;
    border-top: 1px solid #e2e8f0;
    padding-top: 0.45rem;
  }
}

/* Painéis de lista (equipe / aparelhos / sync) */
.devices-filters {
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  align-items: center;
}
.panel-intro {
  margin-bottom: 0.75rem;
}
#users-msg.is-err,
#team-msg.is-err,
#devices-meta.is-err,
#audit-meta.is-err,
#sync-meta.is-err,
#list-meta.is-err {
  color: var(--danger);
}
#users-msg.is-ok,
#team-msg.is-ok,
#list-meta.is-ok {
  color: var(--ok);
}
.sa-manage-actions {
  flex-wrap: wrap;
  gap: 0.45rem;
}
@media (max-width: 800px) {
  .devices-filters .btn-sm {
    flex: 1 1 auto;
    min-height: 2.25rem;
  }
  .devices-filters .checkbox-row {
    width: 100%;
  }
  #panel-users .list-head-right,
  #panel-team .list-head-right,
  #panel-sync .list-head-right {
    width: 100%;
    flex-wrap: wrap;
  }
  #panel-users .inline-search,
  #panel-team .inline-search,
  #panel-devices .inline-search,
  #panel-sync .inline-search {
    width: 100%;
    max-width: none;
  }
  #panel-users .list-head-right .btn-sm,
  #panel-team .list-head-right .btn-sm {
    flex: 1 1 auto;
    min-height: 2.25rem;
  }
  #user-create-form .filter-actions button,
  #team-create-form .filter-actions button,
  #filter-form .filter-actions button,
  #filter-form .filter-actions-primary button,
  #filter-form .filter-actions-secondary button {
    flex: 1 1 auto;
    min-height: 2.35rem;
  }
  #filter-form .filter-date-presets .btn-sm {
    flex: 1 1 auto;
    min-height: 2.15rem;
  }
  .sa-manage-actions button,
  .superadmin-bar .filter-actions button {
    flex: 1 1 auto;
    min-height: 2.4rem;
  }
  .map-tools-row .btn-sm,
  .map-feature-actions .btn-sm {
    flex: 1 1 auto;
    min-height: 2.25rem;
  }
  .map-fichas-list-panel,
  .map-feature-panel {
    max-height: min(40vh, 320px);
  }
  #tenant-select-card .filter-actions button {
    width: 100%;
    min-height: 2.4rem;
  }
}

/* Timeline do técnico */
.timeline-card.is-loading {
  opacity: 0.85;
  pointer-events: none;
}
.timeline-card-head {
  flex-wrap: wrap;
  gap: 0.5rem;
}
.superadmin-bar details {
  margin-top: 0.75rem;
}
.superadmin-bar summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.25rem 0;
}
.superadmin-bar summary:hover {
  color: var(--text);
}
.field-pw-actions {
  flex-wrap: wrap;
  gap: 0.4rem;
}
@media (max-width: 800px) {
  .superadmin-bar .filters {
    grid-template-columns: 1fr;
  }
  .field-pw-actions button {
    flex: 1 1 auto;
    min-height: 2.4rem;
  }
  .timeline-head-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* —— Conta (perfil, senha, 2FA, município) —— */
.account-intro .account-section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}
.account-section-nav .account-jump {
  min-height: 2.15rem;
}
.account-load-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.65rem 0 0;
}
.account-load-status.hidden {
  display: none !important;
}
.account-card {
  transition:
    box-shadow 0.25s ease,
    border-color 0.25s ease,
    opacity 0.2s ease;
}
.account-card.is-loading {
  opacity: 0.72;
  pointer-events: none;
  position: relative;
}
.account-card.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    100deg,
    transparent 30%,
    rgba(59, 130, 246, 0.06) 50%,
    transparent 70%
  );
  background-size: 200% 100%;
  animation: account-shimmer 1.1s ease-in-out infinite;
  pointer-events: none;
}
@keyframes account-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}
.account-card-focus {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.55);
  border-color: rgba(59, 130, 246, 0.45);
}
.account-form.filters {
  align-items: end;
}
.account-form-actions {
  width: 100%;
  margin-top: 0.25rem;
}
.pw-strength {
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 0.4rem 0 0.15rem;
  overflow: hidden;
}
.pw-strength-bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--muted);
  transition:
    width 0.25s ease,
    background 0.25s ease;
}
.pw-strength-bar.is-weak {
  background: var(--danger);
}
.pw-strength-bar.is-fair {
  background: var(--warn);
}
.pw-strength-bar.is-good {
  background: #60a5fa;
}
.pw-strength-bar.is-strong {
  background: var(--ok);
}
.pw-strength-label {
  display: block;
  min-height: 1.1em;
  margin-top: 0.15rem;
}
.twofa-actions {
  flex-wrap: wrap;
}
.mono-input {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
@media (max-width: 800px) {
  .account-form.filters {
    grid-template-columns: 1fr;
  }
  /* Preferências: grade 2 colunas (não empilhar tudo — 8 botões ficavam enormes) */
  .account-form-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.4rem;
  }
  .account-form-actions button {
    flex: 1 1 auto;
    width: auto;
    min-width: min(100%, 9.5rem);
    min-height: 2.4rem;
    white-space: normal;
    line-height: 1.25;
    padding-inline: 0.65rem;
    word-break: normal;
    overflow-wrap: anywhere;
  }
  .account-form-actions .btn-primary {
    flex: 1 1 100%;
  }
  .twofa-actions button {
    flex: 1 1 auto;
    min-height: 2.4rem;
  }
  .color-field {
    width: 100%;
  }
  .logo-field {
    flex-wrap: wrap;
    width: 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  .account-card.is-loading::after {
    animation: none !important;
  }
}

/* 2FA setup — QR + chave manual */
.twofa-setup-box {
  margin: 0.75rem 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.twofa-setup-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem 1.25rem;
  align-items: start;
}
@media (max-width: 560px) {
  .twofa-setup-grid {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .twofa-secret-wrap .filter-actions {
    justify-content: center;
  }
}
.twofa-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
.twofa-qr {
  display: block;
  width: 200px;
  height: 200px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 6px;
  box-sizing: border-box;
}
.twofa-secret {
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  word-break: break-all;
  margin: 0.35rem 0 0.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px dashed var(--border);
  color: var(--text);
}
.twofa-secret-wrap .filter-actions {
  margin-bottom: 0.35rem;
}

.twofa-recovery-box {
  margin-top: 0.75rem;
  padding: 0.875rem;
  border: 1px solid var(--warning-border, #b7791f);
  border-radius: var(--radius-sm);
  background: var(--warning-soft, rgba(245, 158, 11, 0.08));
}
.twofa-recovery-box h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}
.twofa-recovery-codes {
  margin: 0.75rem 0;
  padding: 0.75rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 600 0.9rem/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0;
  white-space: pre-wrap;
}
.field-pw-panel label {
  display: block;
  margin-bottom: 0.65rem;
}
.field-pw-panel .password-field {
  margin-top: 0.25rem;
}
.team-self-tag {
  font-size: 0.72rem;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.18);
  color: var(--text);
  margin-left: 0.35rem;
  vertical-align: middle;
}
tr.row-self {
  background: rgba(59, 130, 246, 0.06);
}
.bar-row-clickable {
  cursor: pointer;
  border-radius: 6px;
  padding: 0.15rem 0.2rem;
  margin: 0 -0.2rem;
  transition: background 0.12s ease;
}
.bar-row-clickable:hover,
.bar-row-clickable:focus-visible {
  background: rgba(59, 130, 246, 0.1);
  outline: none;
}
.bar-row-clickable:focus-visible {
  box-shadow: 0 0 0 2px var(--accent, #3b82f6);
}
/* Aparelhos — inatividade */
tr.row-device-warn {
  background: rgba(251, 191, 36, 0.08);
}
tr.row-device-stale {
  background: rgba(248, 113, 113, 0.08);
}
.device-stale-pill {
  margin-left: 0.35rem;
  font-size: 0.7rem;
  vertical-align: middle;
}
.devices-filters {
  margin: 0.35rem 0 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
}
.audit-row-ficha {
  cursor: pointer;
}
.audit-row-ficha:hover {
  background: rgba(59, 130, 246, 0.08);
}
.audit-open-hint {
  font-size: 0.7rem;
  margin-left: 0.25rem;
  opacity: 0.75;
}
.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0 0.35rem;
}
.page-jump-input {
  width: 3.2rem;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}
#fichas-pagination .ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.pagination-hint {
  margin: 0.35rem 0 0;
  text-align: center;
  font-size: 0.78rem;
}
@media (min-width: 801px) {
  .pagination-hint {
    text-align: left;
    margin-left: 0.15rem;
  }
}
@media (max-width: 420px) {
  .pagination-hint {
    font-size: 0.72rem;
    line-height: 1.35;
  }
  #fichas-pagination .ghost {
    min-height: 2.25rem;
    min-width: 2.25rem;
  }
}
.filter-date-presets {
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.recent-filters {
  margin-top: 0.35rem;
}
.saved-filter-controls {
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) auto minmax(10rem, 1fr) auto auto;
  gap: 0.45rem;
  align-items: center;
  width: 100%;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.saved-filter-controls input,
.saved-filter-controls select {
  min-width: 0;
  width: 100%;
}
.map-workspace-presets {
  display: grid;
  gap: 0.45rem;
}
.map-workspace-presets input,
.map-workspace-presets select {
  width: 100%;
  min-width: 0;
}
.detail-versions-panel {
  margin: 0.75rem 0 0.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface, var(--card));
}
.detail-versions-panel > summary {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  font-weight: 600;
}
.detail-versions-list {
  padding: 0 0.8rem 0.75rem;
}
.version-history-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.version-history-item {
  padding: 0.65rem 0;
  border-top: 1px solid var(--border);
  line-height: 1.5;
}
.version-history-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}
.version-history-head time {
  color: var(--muted);
}
.detail-error-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--danger, #b91c1c);
  border-radius: 8px;
}
.detail-error-box .error {
  margin: 0;
}
@media (max-width: 800px) {
  .saved-filter-controls {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .saved-filter-controls select {
    grid-column: 1 / -1;
  }
  .detail-error-box,
  .version-history-head {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Correções finais de responsividade do shell operacional. */
#fichas-table {
  min-width: 1080px;
  table-layout: auto;
}
#fichas-table th,
#fichas-table td {
  word-break: normal;
  overflow-wrap: normal;
}
#fichas-table .mono-id {
  white-space: normal;
  overflow-wrap: anywhere;
}
#fichas-table th:nth-child(2) {
  min-width: 7rem;
}
#fichas-table th:nth-child(3) {
  min-width: 10rem;
}
#fichas-table th:nth-child(4) {
  min-width: 7rem;
}
#fichas-table th:nth-child(5) {
  min-width: 11rem;
}
#fichas-table th:nth-child(6) {
  min-width: 12rem;
}
#fichas-table th:nth-child(7) {
  min-width: 9rem;
}
#fichas-table th:nth-child(8) {
  min-width: 8rem;
}
#fichas-table th:nth-child(9) {
  min-width: 9rem;
}
#fichas-table th:nth-child(10) {
  min-width: 5rem;
}
#fichas-table th:nth-child(11) {
  min-width: 7rem;
}
@media (max-width: 800px) {
  #fichas-table {
    min-width: 1120px;
  }
}
@media (max-width: 560px) {
  .top {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.4rem;
    padding: max(0.5rem, env(safe-area-inset-top, 0px)) 0.65rem 0.55rem;
  }
  .brand {
    gap: 0.55rem;
  }
  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 8px;
  }
  .brand-text .logo {
    max-width: calc(100vw - 5rem);
    font-size: 0.95rem;
  }
  .top-right {
    display: flex;
    width: 100%;
    flex-wrap: nowrap;
    justify-content: stretch;
    gap: 0.3rem;
  }
  .top-right .top-action,
  .top-right .btn-logout {
    flex: 0 0 2.45rem;
    width: 2.45rem;
    min-width: 2.45rem;
    padding-inline: 0.4rem;
  }
  #btn-cmdk,
  #btn-density {
    display: none !important;
  }
  .user-badge {
    flex: 1 1 auto;
    max-width: none;
    min-width: 0;
    padding: 0.3rem 0.55rem;
  }
  .user-badge-role,
  .user-badge-tenant {
    display: none;
  }
  .sw-update-banner {
    position: fixed;
    inset: auto 0.65rem max(0.65rem, env(safe-area-inset-bottom, 0px));
    z-index: 1200;
    justify-content: flex-start;
    border: 1px solid rgba(59, 130, 246, 0.5);
    border-radius: 8px;
    background: var(--surface, #fff);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.24);
  }
  .sw-update-banner > span {
    flex: 1 1 100%;
  }
  .sw-update-banner button {
    flex: 1 1 calc(50% - 0.3rem);
  }
}
.status-quick-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0.5rem 0 0.75rem;
}
.status-quick-label {
  margin-right: 0.15rem;
}
.btn-quick-status {
  border-color: var(--accent, #3b82f6);
  min-height: 2.15rem;
}
.status-save-short {
  display: none;
}
@media (max-width: 420px) {
  .status-save-full {
    display: none;
  }
  .status-save-short {
    display: inline;
  }
  #detail-status-row #btn-status-save {
    width: 100%;
    min-height: 2.4rem;
  }
  #detail-status-row .btn-quick-status {
    flex: 1 1 auto;
    min-height: 2.25rem;
  }
  #detail-status-row #detail-status,
  #detail-status-row #detail-parecer {
    width: 100%;
    min-height: 2.35rem;
  }
  #detail-status-row #detail-parecer {
    min-height: 4.5rem;
  }
}
.overview-recents-card {
  margin-bottom: 1rem;
}
.overview-recents-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.25rem;
}
@media (max-width: 720px) {
  .overview-recents-grid {
    grid-template-columns: 1fr;
  }
}
.overview-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 1.75rem;
  align-items: center;
}
.overview-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  max-width: 100%;
}
.overview-chip:hover,
.overview-chip:focus-visible {
  border-color: var(--accent, #3b82f6);
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.overview-chip-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
}
.overview-dash-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.85rem;
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: var(--radius);
  background: rgba(248, 113, 113, 0.08);
  color: var(--text);
}
.overview-dash-error.hidden {
  display: none !important;
}
.overview-dash-error #overview-dash-error-text {
  flex: 1 1 200px;
  margin: 0;
  color: var(--danger);
}
.chart-error {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  padding: 0.35rem 0;
}
.chart-error .btn-chart-retry {
  min-height: 2.15rem;
}
.page-btn-short {
  display: none;
}
@media (max-width: 560px) {
  .pagination .page-btn-full,
  .page-btn-full {
    display: none !important;
  }
  .pagination .page-btn-short,
  .page-btn-short {
    display: inline !important;
  }
  .page-jump-label {
    display: none;
  }
  #panel-devices .list-head-right,
  #panel-devices .list-card-head {
    width: 100%;
  }
  #panel-devices .inline-search,
  #audit-search {
    width: 100%;
    max-width: none;
  }
  #btn-audit-refresh {
    flex: 1 1 auto;
    min-height: 2.25rem;
  }
  .overview-dash-error {
    flex-direction: column;
    align-items: stretch;
  }
  .overview-dash-error .btn-sm {
    width: 100%;
    min-height: 2.35rem;
  }
}
@media (max-width: 800px) {
  #panel-devices .list-head-right {
    width: 100%;
    flex-wrap: wrap;
  }
  #panel-devices .inline-search {
    width: 100%;
    max-width: none;
  }
}

/* ——— Drawer, virtualização, modal compacto (desktop), PWA helpers ——— */
.nav-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(2px);
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
.nav-drawer-backdrop:not(.hidden) {
  display: block;
}
.dash-shell.nav-drawer-active .nav-drawer-backdrop {
  display: block;
}
.nav-drawer-open {
  display: none;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.25rem;
  flex-shrink: 0;
}
.sidebar-drawer-close {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  min-height: 2.25rem;
}
.page-header-main {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  min-width: 0;
}

/* Virtualização real (windowed) + content-visibility de apoio */
#fichas-body tr.ficha-row {
  content-visibility: auto;
  contain-intrinsic-size: auto 44px;
}
#fichas-body[data-virtualized='1'] tr.ficha-row {
  content-visibility: visible;
}
.table-wrap-virtual.is-virtualized {
  max-height: min(70vh, 640px);
  overflow: auto;
  overscroll-behavior: contain;
}
#fichas-body tr.virt-spacer td {
  background: transparent !important;
  pointer-events: none;
}
#audit-body tr,
#events-body tr {
  content-visibility: auto;
  contain-intrinsic-size: auto 44px;
}
.infinite-sentinel {
  height: 1px;
  width: 100%;
  pointer-events: none;
  visibility: hidden;
}
.offline-queue-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--warn, #c9a227);
  color: #111;
  font-size: 0.7rem;
  font-weight: 700;
}
.offline-banner.has-queue {
  border-color: var(--warn, #c9a227);
}

/* Modal ficha: “Mais…” colapsável também no desktop (menos botões visíveis) */
.modal-panel-detail .detail-more-details,
#detail-emit-bar .detail-more-details {
  display: inline-block;
  vertical-align: middle;
  position: relative;
}
.modal-panel-detail .detail-more-details > .detail-more-summary,
#detail-emit-bar .detail-more-details > .detail-more-summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  list-style: none;
  cursor: pointer;
  user-select: none;
  min-height: 2.1rem;
  margin: 0.15rem;
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.75rem;
}
.modal-panel-detail
  .detail-more-details
  > .detail-more-summary::-webkit-details-marker,
#detail-emit-bar
  .detail-more-details
  > .detail-more-summary::-webkit-details-marker {
  display: none;
}
.modal-panel-detail .detail-more-details > .detail-more-body,
#detail-emit-bar .detail-more-details > .detail-more-body {
  display: none;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-width: min(100%, 220px);
}
.modal-panel-detail .detail-more-details[open] > .detail-more-body,
#detail-emit-bar .detail-more-details[open] > .detail-more-body {
  display: flex;
}
.modal-panel-detail .detail-more-details[open] > .detail-more-summary,
#detail-emit-bar .detail-more-details[open] > .detail-more-summary {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.08);
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}

/* Fallback: se content-visibility não for suportado, tabela segue normal */
@supports not (content-visibility: auto) {
  #fichas-body tr.ficha-row,
  #audit-body tr {
    content-visibility: visible;
  }
}

/* —— Auditoria responsiva SPA (todas as abas) —— */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  overflow-x: hidden;
}
main {
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
}
/* Tabelas largas: scroll horizontal sem quebrar o layout */
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table {
  min-width: 0;
}
/* Lista de fichas: colunas longas não estouram o viewport */
#fichas-table {
  min-width: 640px;
}
#team-table {
  min-width: 560px;
}
#devices-table,
#audit-table,
#sync-table {
  min-width: 480px;
}
/* Header em tablet: quebra sem sobrepor */
@media (max-width: 960px) {
  .top {
    flex-wrap: wrap;
    gap: 0.55rem 0.75rem;
    padding: 0.65rem 1rem;
  }
  .top-right {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 100%;
  }
  .page-header-main {
    max-width: 100%;
  }
  .page-desc {
    max-width: none;
  }
  .filters {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  }
  .charts-row {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  }
}
@media (max-width: 800px) {
  .top {
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
  }
  .brand-text .sub {
    max-width: 28vw;
  }
  .live-indicator {
    font-size: 0.78rem;
    line-height: 1.35;
    flex-wrap: wrap;
  }
  .toolbar-hint {
    line-height: 1.4;
  }
  .devices-filters {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .devices-filters .btn-sm,
  .devices-filters .checkbox-row {
    min-height: 2.2rem;
  }
  #panel-sync .list-head-right,
  #panel-devices .list-head-right,
  #panel-users .list-head-right,
  #panel-team .list-head-right {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  #panel-sync .inline-search,
  #panel-devices .inline-search,
  #panel-users .inline-search,
  #panel-team .inline-search,
  #audit-search {
    width: 100%;
    max-width: none;
    min-width: 0;
  }
  #panel-sync .devices-filters .btn-sm,
  #panel-devices .devices-filters .btn-sm {
    flex: 1 1 calc(50% - 0.25rem);
    min-height: 2.3rem;
  }
  .account-section-nav {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .account-section-nav .account-jump {
    min-height: 2.2rem;
  }
  .profile-grid {
    grid-template-columns: 1fr !important;
  }
  .password-field {
    max-width: 100%;
  }
  .twofa-setup-grid {
    grid-template-columns: 1fr !important;
  }
  .modal {
    padding: 0;
    align-items: flex-end;
  }
  .modal-panel:not(.cmdk-panel):not(.help-panel):not(.confirm-panel) {
    width: 100%;
    max-width: 100%;
    max-height: min(94dvh, 96vh);
    border-radius: 14px 14px 0 0;
    margin: 0;
  }
  .cmdk-panel,
  .help-panel {
    margin: auto 0.75rem;
    max-height: min(86dvh, 88vh);
    width: min(100%, 520px);
  }
  .pagination {
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: center;
  }
  #fichas-pagination .ghost {
    min-height: 2.25rem;
  }
  .bar-row {
    grid-template-columns: 64px 1fr 36px;
    font-size: 0.75rem;
  }
  /* Card específico do painel do mapa — padding ajustado para layout imersivo */
  .map-panel-card {
    padding: 0.65rem 0.85rem;
    margin: 0 0 0.5rem;
  }
  .map-intro {
    font-size: 0.8rem;
    line-height: 1.4;
  }
  .superadmin-bar {
    padding: 0.75rem;
  }
  .superadmin-bar .list-card-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  /* Bulk sticky safe-area em telefone */
  .bulk-bar {
    padding-bottom: max(0.55rem, env(safe-area-inset-bottom, 0px));
  }
}
@media (max-width: 560px) {
  .filters {
    grid-template-columns: 1fr;
  }
  .filter-actions {
    flex-wrap: wrap;
    width: 100%;
  }
  .filter-actions button {
    flex: 1 1 auto;
  }
  .toolbar-exports {
    width: 100%;
  }
  .list-card-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }
  .list-card-head h2 {
    margin: 0;
  }
  .page-kicker {
    font-size: 0.68rem;
  }
  .dash-auto-refresh-hint {
    font-size: 0.75rem;
    line-height: 1.4;
  }
  /* Esconde marca textual longa no header */
  .brand-text .sub {
    display: none;
  }
  #btn-nav-drawer {
    min-height: 2.35rem;
    flex-shrink: 0;
  }
  .page-header-main {
    gap: 0.45rem;
  }
}
@media (max-width: 420px) {
  .kpi-hint {
    font-size: 0.7rem;
  }
  .quick-btn {
    font-size: 0.78rem;
    padding: 0.4rem 0.55rem;
  }
  .map-box {
    height: clamp(260px, 48dvh, 420px);
    min-height: 240px;
  }
  #sync-limit-hint,
  #audit-limit-hint {
    width: 100%;
    flex: 1 1 100%;
  }
  .modal-panel-detail .modal-head {
    flex-direction: column;
    align-items: stretch;
  }
  .modal-panel-detail .modal-head-actions {
    width: 100%;
  }
}
@media (min-width: 801px) and (max-width: 1100px) {
  .dash-shell {
    grid-template-columns: 200px 1fr;
    gap: 0 1rem;
  }
  .sidebar-nav .nav-tab {
    font-size: 0.84rem;
    padding: 0.55rem 0.65rem;
  }
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
/* Prefer reduced motion: already partially handled; ensure drawer/map */
@media (prefers-reduced-motion: reduce) {
  .map-fichas-list-panel,
  .map-feature-panel,
  .panel-enter {
    transition: none !important;
    animation: none !important;
  }
}

/* —— Pós-auditoria: toque, landscape, iOS zoom, labels —— */
/* Evita zoom automático no iOS ao focar inputs (fonte < 16px) */
@media (max-width: 800px) {
  input:not([type='checkbox']):not([type='radio']):not([type='color']):not(
      [type='range']
    ),
  select,
  textarea {
    font-size: 16px !important;
  }
  .btn-sm,
  button.ghost.btn-sm,
  .quick-btn,
  .account-jump,
  .nav-drawer-open,
  .filter-chip {
    min-height: 2.5rem;
  }
  .checkbox-row {
    min-height: 2.5rem;
    align-items: center;
  }
  /* labels de barra de gráfico não estouram */
  .bar-row > :first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
}
/* Telefone em paisagem: mapa e drawer usáveis */
@media (max-height: 480px) and (orientation: landscape) {
  .map-box {
    height: clamp(160px, 52dvh, 240px) !important;
    min-height: 160px !important;
  }
  .map-fichas-list-panel,
  .map-feature-panel {
    max-height: min(48dvh, 200px) !important;
  }
  .login-hero {
    min-height: 0 !important;
    padding: 0.75rem 1rem !important;
  }
  .login-hero-title {
    font-size: 1.1rem !important;
  }
  .login-hero-list {
    display: none;
  }
  .modal-panel-detail {
    max-height: 92dvh !important;
  }
  .sidebar {
    max-height: 100dvh;
  }
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  .page-desc {
    display: none;
  }
}
/* Offline / SW banners não cobrem o skip-link */
.offline-banner,
.sw-update-banner {
  padding-left: max(0.85rem, env(safe-area-inset-left, 0px));
  padding-right: max(0.85rem, env(safe-area-inset-right, 0px));
}
/* Foco visível consistente em controles */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 2px;
}
/* Ações de linha em tabelas: empilham no estreito sem sumir */
@media (max-width: 560px) {
  .td-actions-inner,
  .action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
  }
  .td-actions-inner .btn-sm,
  .action-group > .btn-sm {
    flex: 1 1 auto;
    min-width: 5.5rem;
  }
  /* Status pills do dashboard */
  .status-pills {
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .status-pill-btn {
    min-height: 2.25rem;
  }
}
/* Painel de conta: cards não ficam “colados” no topo com âncoras */
.account-card {
  scroll-margin-top: 5.5rem;
}
@media (max-width: 800px) {
  .account-card {
    scroll-margin-top: 4.5rem;
  }
  /* Evita botões do superadmin em linha única ilegível */
  .sa-switch-row {
    grid-template-columns: 1fr !important;
  }
}
/* Densidade compacta: não reduzir touch targets no mobile */
@media (max-width: 800px) {
  html[data-density='compact'] .btn-sm {
    min-height: 2.5rem;
    padding: 0.4rem 0.65rem;
  }
}

/* Gráficos e live indicator — polish */
.bar-row-clickable {
  cursor: pointer;
  border-radius: 6px;
  padding: 0.15rem 0.2rem;
}
.bar-row-clickable:hover {
  background: rgba(59, 130, 246, 0.08);
}
.bar-row-clickable:focus-visible {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 1px;
}
.bar-value {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.live-indicator[role='button'] {
  cursor: pointer;
  border-radius: 8px;
  padding: 0.2rem 0.4rem;
  margin: -0.2rem -0.4rem;
}
.live-indicator[role='button']:hover {
  background: rgba(59, 130, 246, 0.1);
}
.live-indicator[role='button']:focus-visible {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .bar-fill {
    transition: none !important;
  }
}
.chart-empty {
  padding: 0.5rem 0;
  min-height: 2.5rem;
}

/* Auditoria profunda — tabelas users + pills + login */
#users-table {
  min-width: 420px;
}
.status-pill-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  cursor: pointer;
  min-height: 2.15rem;
}
.status-pill-btn.is-active,
.status-pill-btn[aria-pressed='true'] {
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(59, 130, 246, 0.14);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.12);
}
.status-pill-btn:focus-visible {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 2px;
}
.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
}
/* Scroll horizontal com indicação sutil em mobile */
@media (max-width: 800px) {
  .table-wrap {
    background:
      linear-gradient(90deg, var(--surface) 30%, transparent) left center / 12px
        100% no-repeat local,
      linear-gradient(270deg, var(--surface) 30%, transparent) right center /
        12px 100% no-repeat local,
      var(--surface);
  }
  /* Evita double min-width forçando scroll desnecessário em users estreita */
  #users-table {
    min-width: 0;
  }
  #users-table .td-actions,
  #users-table th:last-child {
    min-width: 8.5rem;
  }
}
/* Login: campos full width e toque */
@media (max-width: 560px) {
  .login-card label {
    width: 100%;
  }
  .login-card .btn-block {
    min-height: 2.75rem;
  }
  .password-field {
    width: 100%;
  }
  .password-field input {
    flex: 1 1 auto;
    min-width: 0;
  }
}
/* Impede que bulk-bar cubra o scroll-top no mobile */
@media (max-width: 800px) {
  .scroll-top-btn {
    bottom: max(4.5rem, calc(3.75rem + env(safe-area-inset-bottom, 0px)));
    z-index: 85;
  }
  #bulk-bar:not(.hidden) ~ * .scroll-top-btn,
  body:has(#bulk-bar:not(.hidden)) .scroll-top-btn {
    bottom: max(5.5rem, calc(4.75rem + env(safe-area-inset-bottom, 0px)));
  }
}

/* �� Auditoria SPA 2026-07: equipes, listas, modal, �ncoras �� */
.list-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}
.list-head-primary-btns {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.form-create-actions {
  width: 100%;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.timeline-card {
  scroll-margin-top: 5rem;
}
.timeline-section {
  scroll-margin-top: 4.5rem;
}
.timeline-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.timeline-section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0 0.75rem;
}
/* Tabela: indica��o visual de scroll horizontal */
.table-wrap {
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}
.table-wrap::after {
  content: '';
  display: block;
  pointer-events: none;
}
/* form-lead longos: leg�veis em telefone */
.form-lead,
.panel-intro > p.muted {
  line-height: 1.45;
  max-width: 70ch;
}
@media (max-width: 800px) {
  .form-lead,
  .panel-intro > p.muted {
    max-width: none;
    font-size: 0.84rem;
  }
  .list-head-actions {
    width: 100%;
  }
  .list-head-actions .inline-search {
    width: 100%;
    max-width: none;
    order: -1;
  }
  .list-head-primary-btns {
    width: 100%;
  }
  .list-head-primary-btns .btn-sm {
    flex: 1 1 calc(50% - 0.25rem);
    min-height: 2.4rem;
  }
  .form-create-actions button {
    flex: 1 1 auto;
    min-height: 2.5rem;
  }
  .timeline-head-actions {
    width: 100%;
  }
  .timeline-head-actions .btn-sm {
    flex: 1 1 auto;
    min-height: 2.35rem;
  }
  .timeline-section-nav .btn-sm {
    flex: 1 1 calc(33% - 0.3rem);
    min-height: 2.35rem;
    text-align: center;
  }
  /* Preferências: reforço 2 colunas (evita override de rules mais antigas) */
  .account-form-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 0.4rem;
  }
  .account-form-actions button {
    flex: 1 1 calc(50% - 0.25rem) !important;
    width: auto !important;
    min-width: 0;
  }
  .account-form-actions .btn-primary {
    flex: 1 1 100% !important;
  }
  /* Modal ficha: grupos de a��es em coluna */
  .modal-panel-detail .modal-head-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }
  .modal-panel-detail .modal-actions-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
  }
  .detail-emit-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .detail-emit-actions > .btn-sm,
  .detail-emit-actions > details {
    flex: 1 1 auto;
  }
  /* Status card no detalhe */
  .status-card {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
  }
  .status-card label,
  .status-card .parecer-label {
    width: 100%;
    min-width: 0;
  }
  .status-card select,
  .status-card textarea {
    width: 100%;
  }
  #btn-status-save {
    width: 100%;
    min-height: 2.55rem;
  }
  /* Mapa: tools row */
  .map-tools-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    width: 100%;
  }
  .map-tools-btns > .btn-sm {
    flex: 1 1 calc(50% - 0.25rem);
    min-height: 2.4rem;
  }
  /* Superadmin forms */
  .superadmin-bar .filters {
    grid-template-columns: 1fr;
  }
  .superadmin-bar label {
    min-width: 0;
  }
}
@media (max-width: 560px) {
  .account-form-actions button {
    flex: 1 1 100%;
  }
  .list-head-primary-btns .btn-sm {
    flex: 1 1 100%;
  }
  .timeline-section-nav .btn-sm {
    flex: 1 1 calc(50% - 0.25rem);
  }
  /* Oculta form-lead muito verboso nas listas estreitas se tiver data-collapse � default: mant�m */
  .panel-intro > p.muted {
    font-size: 0.82rem;
  }
  /* Login: bot�es full width */
  .login-card button.btn-block,
  .forgot-box button.btn-block {
    min-height: 2.65rem;
  }
  .password-field {
    width: 100%;
  }
  .password-field input {
    min-width: 0;
    flex: 1 1 auto;
  }
}
/* Landscape estreito: esconde intros longas de painel (mant�m t�tulo) */
@media (max-height: 420px) and (orientation: landscape) {
  .panel-intro > p.muted,
  .form-lead {
    display: none;
  }
  .account-section-nav {
    display: none;
  }
}
/* Print: esconde chrome */
@media print {
  .top,
  .sidebar,
  .toolbar,
  .offline-banner,
  .sw-update-banner,
  .nav-drawer-open,
  #btn-nav-drawer,
  .bulk-bar,
  .detail-emit-bar,
  .modal-backdrop {
    display: none !important;
  }
  .dash-shell {
    display: block !important;
  }
  .tab-panel.hidden {
    display: none !important;
  }
}

/* —— Pop-up Leaflet + painel de lote (layout sem sobreposição) —— */
.leaflet-popup {
  text-align: left !important;
}
.leaflet-container .leaflet-popup-content-wrapper {
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  box-shadow:
    0 10px 34px rgba(15, 23, 42, 0.24),
    0 2px 8px rgba(15, 23, 42, 0.12);
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, rgba(15, 23, 42, 0.08));
  color: var(--text, #0f172a);
  max-width: 94vw;
}
.leaflet-container .leaflet-popup-content {
  margin: 0;
  padding: 0;
  /* Largura mínima evita coluna de valor “esmagada” (inscrição letra a letra) */
  min-width: min(280px, 90vw) !important;
  width: auto !important;
  max-width: min(340px, 92vw);
  max-height: min(70vh, 480px);
  overflow-x: hidden;
  overflow-y: auto;
  line-height: 1.45;
  font-size: 13px;
  scrollbar-width: thin;
  box-sizing: border-box;
}
.leaflet-container .leaflet-popup-content::-webkit-scrollbar {
  width: 6px;
}
.leaflet-container .leaflet-popup-content::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.3);
  border-radius: 3px;
}
.leaflet-container a.leaflet-popup-close-button {
  z-index: 3;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  line-height: 30px;
  border-radius: 8px;
  background: var(--surface-2, #f1f5f9);
  color: var(--text-muted, #475569) !important;
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  transition:
    background 150ms ease,
    color 150ms ease,
    transform 100ms ease;
  border: 1px solid var(--border, rgba(15, 23, 42, 0.08));
}
.leaflet-container a.leaflet-popup-close-button:hover,
.leaflet-container a.leaflet-popup-close-button:focus-visible {
  background: var(--surface-3, #e2e8f0);
  color: var(--text, #0f172a) !important;
  transform: scale(1.05);
}
.leaflet-container a.leaflet-popup-close-button:focus-visible {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 2px;
}
.leaflet-popup-tip {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, rgba(15, 23, 42, 0.08));
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.gis-popup {
  margin: 0;
  padding: 0.9rem 1rem 0.8rem;
  min-width: 0;
  max-width: 100%;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text, #0f172a);
  text-align: left;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.gis-popup-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  padding: 0 0 0.55rem 0;
  border-bottom: 1px solid var(--border, #e2e8f0);
  margin: 0;
}
.gis-popup-title {
  display: block;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.35;
  margin: 0 2.1rem 0 0;
  /* Inscrição formatada em uma linha se couber; quebra só em pontos lógicos */
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: break-word;
  color: var(--text, #0f172a);
  letter-spacing: -0.01em;
}
.gis-popup-layer {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted, #475569);
  padding: 0.15rem 0.6rem;
  line-height: 1.3;
  background: var(--surface-2, #f1f5f9);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  width: fit-content;
  flex-shrink: 0;
}
.gis-popup-layer::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
  flex-shrink: 0;
}
.gis-popup-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  min-width: 0;
}
/* Layout EMPILHADO (rótulo em cima, valor embaixo em linha inteira).
   Grid 2 colunas + overflow-wrap:anywhere quebrava “01.03.013.0189” letra a letra. */
.gis-popup-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.15rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border-soft, #f1f5f9);
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.gis-popup-row:first-child {
  padding-top: 0.28rem;
}
.gis-popup-row:last-child {
  border-bottom: none;
}
.gis-popup-k {
  display: block;
  font-size: 0.7rem;
  font-weight: 650;
  color: var(--text-muted, #64748b);
  letter-spacing: 0.02em;
  line-height: 1.35;
  word-break: normal;
  overflow-wrap: break-word;
  white-space: normal;
  text-transform: none;
  width: 100%;
}
.gis-popup-v {
  display: block;
  font-size: 0.9rem;
  font-weight: 650;
  color: var(--text, #0f172a);
  line-height: 1.4;
  /* Nunca quebrar no meio de cada caractere */
  word-break: normal;
  overflow-wrap: break-word;
  white-space: normal;
  min-width: 0;
  width: 100%;
  text-align: left;
  box-sizing: border-box;
}
.gis-popup-v[data-empty='true'] {
  color: var(--text-muted, #94a3b8);
  font-weight: 500;
  font-style: italic;
}
.gis-popup-v.mono {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.88rem;
  letter-spacing: 0.01em;
  /* Inscrição/coords em UMA linha; scroll se precisar */
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  scrollbar-width: thin;
  padding-bottom: 0.1rem;
}
.gis-popup-v .unit {
  color: var(--text-muted, #64748b);
  font-weight: 500;
  margin-left: 0.18rem;
  font-size: 0.72rem;
}
.gis-popup-hint {
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted, #64748b);
  line-height: 1.4;
  word-break: break-word;
  font-style: italic;
}
.gis-popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.55rem 0 0;
  margin: 0.05rem 0 0;
  border-top: 1px solid var(--border, #e2e8f0);
}
.gis-popup-btn {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 32px;
  padding: 0.38rem 0.7rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text, #0f172a);
  background: var(--surface-2, #f1f5f9);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  cursor: pointer;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    transform 100ms ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  line-height: 1.2;
  font-family: inherit;
}
.gis-popup-btn:hover,
.gis-popup-btn:focus-visible {
  background: var(--surface-3, #e2e8f0);
  border-color: var(--accent, #3b82f6);
  color: var(--accent, #3b82f6);
}
.gis-popup-btn:focus-visible {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 2px;
}
.gis-popup-btn:active {
  transform: translateY(1px);
}
.gis-popup-btn.is-primary {
  background: var(--accent, #3b82f6);
  color: #fff;
  border-color: var(--accent, #3b82f6);
}
.gis-popup-btn.is-primary:hover,
.gis-popup-btn.is-primary:focus-visible {
  background: var(--accent-hover, #2563eb);
  color: #fff;
}
.gis-popup-btn.is-copied {
  background: var(--ok, #10b981);
  color: #fff;
  border-color: var(--ok, #10b981);
}
.gis-popup-btn .ico {
  font-size: 0.95rem;
  line-height: 1;
  flex-shrink: 0;
}
/* legado tabela (se algum HTML antigo ainda usar) */
.gis-popup-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.gis-popup-table th,
.gis-popup-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.25rem 0.35rem 0.25rem 0;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  max-width: none;
  min-width: 0;
}
.gis-popup-table th {
  width: 40%;
  font-weight: 700;
  color: #64748b;
  font-size: 0.75rem;
}
.gis-popup-table td {
  width: 60%;
  font-weight: 600;
  color: #0f172a;
}

/* Painel lateral de feição */
.map-feature-panel {
  max-height: min(56vh, 480px);
  overflow: auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.map-feature-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  flex-shrink: 0;
}
.map-feature-title {
  min-width: 0;
  flex: 1 1 auto;
  word-break: break-word;
  line-height: 1.25;
}
.map-feature-insc {
  font-weight: 700;
  font-size: 0.98rem;
  margin: 0;
  font-family: var(--font-mono, ui-monospace, monospace);
  word-break: break-all;
  overflow-wrap: anywhere;
  line-height: 1.3;
  color: var(--text);
  min-width: 0;
}
.map-feature-dl {
  margin: 0.15rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}
.map-feature-row {
  display: grid;
  grid-template-columns: minmax(0, 38%) minmax(0, 1fr);
  gap: 0.3rem 0.55rem;
  align-items: start;
  font-size: 0.82rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.map-feature-row .map-feature-k,
.map-feature-row dt {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.75rem;
  line-height: 1.3;
  min-width: 0;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  hyphens: auto;
}
.map-feature-row .map-feature-v,
.map-feature-row dd {
  margin: 0;
  color: var(--text);
  font-weight: 600;
  font-size: 0.84rem;
  line-height: 1.35;
  min-width: 0;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}
.map-feature-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.35rem;
  flex-shrink: 0;
}
.map-feature-actions .btn-sm {
  flex: 1 1 auto;
  min-width: min(100%, 7.5rem);
  max-width: 100%;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
  padding: 0.4rem 0.55rem;
  height: auto;
  min-height: 2.1rem;
}
.map-feature-foot-details {
  margin-top: 0.25rem;
  flex-shrink: 0;
}
.map-feature-foot-details > summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.map-feature-foot-details > summary::-webkit-details-marker {
  display: none;
}
.map-feature-foot {
  margin: 0.35rem 0 0;
  line-height: 1.4;
}
.map-feature-agili-slot {
  margin-top: 0.25rem;
  min-width: 0;
}
.map-feature-agili .map-feature-row {
  margin: 0;
}
.map-layer-toggle.is-error {
  outline: 1px solid var(--danger, #dc2626);
  border-radius: 6px;
}
.map-layer-toggle.is-loading {
  opacity: 0.7;
}
.map-layer-toggle.is-active {
  font-weight: 600;
}
.leaflet-popup-content .gis-popup {
  margin: 0;
}

/* Popup em viewport estreita: rótulo empilha sobre o valor (evita colunas apertadas) */
@media (max-width: 560px) {
  .leaflet-container .leaflet-popup-content-wrapper {
    border-radius: 12px;
  }
  .leaflet-container .leaflet-popup-content {
    max-width: 94vw;
    max-height: min(72vh, 480px);
  }
  .gis-popup {
    padding: 0.75rem 0.85rem 0.7rem;
    gap: 0.45rem;
  }
  .gis-popup-row {
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    padding: 0.45rem 0;
  }
  .gis-popup-k {
    font-size: 0.68rem;
    letter-spacing: 0.02em;
  }
  .gis-popup-v {
    font-size: 0.88rem;
  }
  .gis-popup-v.mono {
    white-space: nowrap;
  }
  .gis-popup-title {
    font-size: 0.98rem;
  }
  .gis-popup-header {
    padding-bottom: 0.45rem;
  }
  .gis-popup-actions {
    gap: 0.35rem;
    padding-top: 0.5rem;
  }
  .gis-popup-actions .gis-popup-btn {
    min-height: 36px;
    font-size: 0.74rem;
    padding: 0.4rem 0.6rem;
    white-space: normal;
    line-height: 1.3;
    text-align: left;
  }
}
@media (max-width: 400px) {
  .leaflet-container .leaflet-popup-content {
    max-width: 96vw;
  }
  .gis-popup {
    padding: 0.7rem 0.75rem 0.65rem;
  }
  .gis-popup-actions {
    gap: 0.3rem;
  }
  .gis-popup-actions .gis-popup-btn {
    flex: 1 1 calc(50% - 0.2rem);
  }
}

/* Dark theme — popup usa tokens de surface */
html[data-theme='dark'] .leaflet-container .leaflet-popup-content-wrapper {
  background: var(--surface, #121a27);
  border-color: var(--border, #263246);
  box-shadow:
    0 10px 34px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3);
}
html[data-theme='dark'] .leaflet-popup-tip {
  background: var(--surface, #121a27);
  border-color: var(--border, #263246);
}
html[data-theme='dark'] .leaflet-container a.leaflet-popup-close-button {
  background: var(--surface-2, #182233);
  color: var(--text-muted, #94a3b8) !important;
  border-color: var(--border, #263246);
}
html[data-theme='dark'] .leaflet-container a.leaflet-popup-close-button:hover {
  background: var(--surface-3, #263246);
  color: var(--text, #eef3fb) !important;
}
html[data-theme='dark'] .gis-popup-title {
  color: var(--text, #eef3fb);
}
html[data-theme='dark'] .gis-popup-v {
  color: var(--text, #eef3fb);
}
html[data-theme='dark'] .gis-popup-v .unit {
  color: var(--text-muted, #94a3b8);
}
html[data-theme='dark'] .gis-popup-hint {
  color: var(--text-muted, #94a3b8);
}
html[data-theme='dark'] .gis-popup-layer {
  background: var(--surface-2, #182233);
  border-color: var(--border, #263246);
  color: var(--text-muted, #cbd5e1);
}
html[data-theme='dark'] .gis-popup-row {
  border-bottom-color: var(--border-soft, rgba(38, 50, 70, 0.6));
}
html[data-theme='dark'] .gis-popup-actions {
  border-top-color: var(--border, #263246);
}
html[data-theme='dark'] .gis-popup-btn {
  background: var(--surface-2, #182233);
  border-color: var(--border, #263246);
  color: var(--text, #eef3fb);
}
html[data-theme='dark'] .gis-popup-btn:hover,
html[data-theme='dark'] .gis-popup-btn:focus-visible {
  background: var(--surface-3, #263246);
  border-color: var(--accent, #60a5fa);
  color: var(--accent, #60a5fa);
}
html[data-theme='dark'] .gis-popup-btn.is-primary {
  background: var(--accent, #60a5fa);
  color: #0f172a;
  border-color: var(--accent, #60a5fa);
}
html[data-theme='dark'] .gis-popup-btn.is-primary:hover {
  background: var(--accent-hover, #3b82f6);
  color: #0f172a;
}
html[data-theme='dark'] .gis-popup-btn.is-copied {
  background: var(--ok, #10b981);
  color: #0f172a;
}

/* Legenda do mapa — dark theme */
html[data-theme='dark'] .map-legend {
  background: var(--surface-2, rgba(24, 34, 51, 0.9));
  border-color: var(--border, #263246);
  color: var(--text-muted, #94a3b8);
}
html[data-theme='dark'] .map-legend-dot {
  border-color: var(--surface, #121a27);
}
html[data-theme='dark'] .map-legend-badge {
  background: var(--accent, #60a5fa);
  color: #0f172a;
  border-color: var(--surface, #121a27);
}

/* Painel estreito / mobile: rótulo em cima do valor (zero sobreposição) */
@media (max-width: 900px) {
  .map-feature-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
    padding: 0.45rem 0;
  }
  .map-feature-row .map-feature-k {
    font-size: 0.72rem;
  }
  .map-feature-actions .btn-sm {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }
}
@media (max-width: 420px) {
  .map-feature-actions .btn-sm {
    flex: 1 1 100%;
  }
  .leaflet-container .leaflet-popup-content {
    max-width: min(280px, 86vw);
    max-height: min(46vh, 300px);
  }
}

/* �� Auditoria UX SPA 2026-07-14: densidade, 320px, map tools �� */
.map-intro code.mono-id {
  font-size: 0.78em;
  word-break: break-all;
}
.map-layer-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: center;
  max-width: 100%;
}
/* Toolbar: exportas n�o estouram em telefone */
.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.toolbar-exports {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
/* Login: full width confort�vel */
#login-form label,
.forgot-box label {
  display: block;
  width: 100%;
}
#login-form input,
.forgot-box input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
/* Pagina��o fichas */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  justify-content: center;
}
.page-jump-input {
  width: 3.5rem;
  min-height: 2.25rem;
}
/* Superadmin forms */
.superadmin-bar .filters {
  align-items: end;
}
@media (max-width: 960px) {
  .map-tools-row {
    flex-direction: column;
  }
  .map-tools-btns {
    width: 100%;
  }
  .toolbar-label {
    width: 100%;
  }
}
@media (max-width: 800px) {
  .map-intro {
    font-size: 0.82rem;
    line-height: 1.4;
  }
  .page-desc {
    font-size: 0.84rem;
    line-height: 1.4;
  }
  .timeline-card-head {
    flex-wrap: wrap;
    gap: 0.45rem;
  }
  #fichas-table .th-sortable {
    white-space: nowrap;
  }
  .bulk-parecer {
    max-width: none !important;
    width: 100%;
    flex: 1 1 100% !important;
  }
  .bulk-status-group {
    flex-wrap: wrap;
    width: 100%;
  }
  .bulk-status-label {
    width: 100%;
  }
  .bulk-status-label select {
    width: 100%;
    min-width: 0 !important;
  }
  #btn-bulk-apply {
    width: 100%;
    min-height: 2.5rem;
  }
}
@media (max-width: 380px) {
  /* Telas muito estreitas (�320�360) */
  .brand-text .sub {
    display: none;
  }
  .page-title {
    font-size: 1.15rem;
  }
  .nav-drawer-open {
    padding: 0.4rem 0.55rem;
    font-size: 0.85rem;
  }
  .kpi-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.45rem;
  }
  .quick-actions-card .quick-btn {
    flex: 1 1 calc(50% - 0.25rem);
    min-height: 2.5rem;
  }
  .top-action .top-label-full {
    display: none;
  }
  .top-action .top-label-short {
    display: inline !important;
  }
  .form-lead,
  .map-intro,
  .panel-intro > p.muted {
    font-size: 0.8rem;
  }
  .account-section-nav .account-jump {
    flex: 1 1 100%;
    white-space: normal;
    line-height: 1.25;
    padding-inline: 0.65rem;
  }
  .pagination .page-btn-full {
    display: none;
  }
  .pagination .page-btn-short {
    display: inline !important;
  }
  /* Esconde ações secundárias do topo (densidade) em telas minúsculas */
  #btn-density {
    display: none !important;
  }
  .top-right {
    gap: 0.2rem;
  }
  #btn-cmdk {
    display: none !important;
  }
}
/*
 * NÃO use @media (min-width: 381px) { .top-label-short { display:none } }:
 * conflita com (max-width: 420px) que mostra o short e esconde o full —
 * entre 381–420px os dois labels ficavam ocultos (botões vazios).
 * Defaults: .top-label-short / .page-btn-short já são display:none.
 * Mobile: max-width 420/560/380 ativa o short com especificidade adequada.
 */
/* Prefer reduced motion already handled elsewhere */
/* Focus ring for map toggles */
.map-layer-toggle:focus-within {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 2px;
  border-radius: 6px;
}

/* �� Alinhamento UI/UX forms e bot�es (2026-07) �� */
.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  width: 100%;
}
.filters label > input,
.filters label > select,
.filters label > textarea,
.filters label .password-field,
.filters label .color-field,
.filters label .logo-field {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
}
.filters .checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  padding-top: 0.35rem;
}
.filters .checkbox-row input[type='checkbox'] {
  width: auto;
  margin: 0;
  flex-shrink: 0;
}
.filter-actions,
.form-create-actions,
.account-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  grid-column: 1 / -1;
  width: 100%;
  padding-bottom: 0;
  margin-top: 0.15rem;
}
.filter-actions button,
.form-create-actions button,
.account-form-actions button {
  margin: 0;
  align-self: center;
}
.list-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
}
.list-card-head h2 {
  margin: 0;
  line-height: 1.25;
  flex: 1 1 auto;
  min-width: 0;
}
.list-head-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}
.password-field {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  width: 100%;
}
.password-field input {
  flex: 1 1 auto;
  min-width: 0;
}
.password-field .btn-toggle-pw,
.password-field .btn-sm {
  flex: 0 0 auto;
  align-self: center;
}
.field-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85em;
}
/* Status bulk alinhado */
.bulk-status-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: flex-end;
}
.bulk-status-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
}
/* Print: listas de equipe e t�cnicos */
@media print {
  .top,
  .sidebar,
  .toolbar,
  .toolbar-actions,
  .offline-banner,
  .sw-update-banner,
  .nav-drawer-open,
  #btn-nav-drawer,
  .bulk-bar,
  .filter-actions,
  .list-head-right,
  .account-section-nav,
  .devices-filters,
  .users-client-filters,
  .team-client-filters,
  .pagination,
  .modal,
  .map-tools-row,
  .map-basemap-row,
  .map-layer-toggles {
    display: none !important;
  }
  .dash-shell {
    display: block !important;
  }
  .tab-panel.hidden {
    display: none !important;
  }
  .tab-panel:not(.hidden) {
    display: block !important;
  }
  .card {
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #ccc;
  }
  .data-table {
    min-width: 0 !important;
    font-size: 10pt;
  }
  .data-table th,
  .data-table td {
    padding: 0.25rem 0.35rem;
  }
  /* Esconde bot�es de a��o nas linhas na impress�o */
  .td-actions,
  .action-group,
  .btn-sm {
    display: none !important;
  }
  body {
    background: #fff !important;
    color: #000 !important;
  }
}
@media (max-width: 360px) {
  .filters {
    grid-template-columns: 1fr !important;
    gap: 0.65rem;
  }
  .page-kicker {
    font-size: 0.65rem;
  }
  .list-card-head h2 {
    font-size: 1.05rem;
  }
  .btn-primary,
  .ghost {
    min-height: 2.55rem;
  }
  .inline-search {
    font-size: 16px !important; /* evita zoom iOS */
  }
  /* Header ainda mais denso em 320–360 */
  .top {
    padding: 0.5rem 0.55rem;
    gap: 0.35rem;
  }
  .brand-text .logo {
    font-size: 0.95rem;
  }
  .user-badge {
    max-width: 28vw;
    font-size: 0.68rem;
  }
  #btn-favs-header {
    font-size: 0.85rem;
  }
  .page-header-main {
    flex-wrap: wrap;
  }
  #btn-nav-drawer {
    width: 100%;
    justify-content: center;
  }
  .kpi-grid {
    gap: 0.4rem;
  }
  .kpi .num {
    font-size: 1.25rem;
  }
  .map-box {
    height: clamp(240px, 44dvh, 360px);
    min-height: 220px;
  }
  .toolbar-actions {
    gap: 0.35rem;
  }
  .toolbar-group {
    width: 100%;
  }
  .toolbar-group .btn-primary,
  .toolbar-group .ghost {
    flex: 1 1 auto;
  }
  .superadmin-bar .filter-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .superadmin-bar .filter-actions button {
    width: 100%;
  }
  .modal-panel:not(.cmdk-panel):not(.help-panel):not(.confirm-panel) {
    max-height: min(96dvh, 98vh);
  }
  .fields-grid {
    grid-template-columns: 1fr !important;
  }
  /* Tabela fichas: min-width menor = menos scroll forçado */
  #fichas-table {
    min-width: 520px;
  }
  #team-table {
    min-width: 480px;
  }
}
@media (max-width: 320px) {
  body {
    font-size: 14px;
  }
  .kpi-grid {
    grid-template-columns: 1fr !important;
  }
  .quick-actions-card .quick-btn {
    flex: 1 1 100%;
  }
  .account-form-actions button {
    flex: 1 1 100% !important;
  }
  .brand-mark {
    width: 32px;
    height: 32px;
  }
  #btn-theme,
  #btn-density {
    display: none !important;
  }
  .page-desc {
    /* redesing v3: não esconder — só limitar linhas (regra no final do arquivo) */
    display: -webkit-box !important;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .toolbar-hint {
    font-size: 0.72rem;
  }
  .login-hero {
    display: none;
  }
  .login-shell {
    max-width: 100%;
    margin: 0;
  }
  .login-card {
    border-radius: 0;
    min-height: calc(100dvh - var(--header-h, 64px));
  }
}

/* ==========================================================================
   Redesign SPA v3 — legibilidade, botões, formulários, tabelas (municipal)
   Não inventa features; corrige truncamento e layout profissional.
   ========================================================================== */

/* Tipografia e ritmo */
body {
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0.01em;
}
.page-title {
  font-size: clamp(1.25rem, 2.2vw, 1.55rem);
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.25;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.page-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.2rem;
}
.page-desc {
  display: block !important;
  margin: 0.35rem 0 0;
  max-width: 52rem;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  color: var(--muted);
  font-size: 0.88rem;
}
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.9rem;
  margin-bottom: 1rem;
}
.page-header-main {
  min-width: 0;
  flex: 1 1 16rem;
}

/* Top bar: não esmaga textos / botões */
.top {
  flex-wrap: wrap;
  row-gap: 0.5rem;
  column-gap: 0.75rem;
}
.top-right {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
  max-width: 100%;
}
.top-right .top-action,
.top-right .btn-sm {
  margin-top: 0;
  white-space: nowrap;
}
.brand-text .logo {
  max-width: min(42vw, 14rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sub {
  max-width: min(48vw, 18rem);
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.user-badge {
  max-width: min(260px, 42vw);
}
.user-badge-main {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  word-break: break-word;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.user-badge-role {
  white-space: normal;
  word-break: break-word;
}

/* Botões: legíveis, não cortados */
button,
.btn-primary,
.btn-sm,
.ghost {
  white-space: normal;
  line-height: 1.3;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  height: auto;
  min-height: 2.35rem;
}
.btn-sm {
  min-height: 2.1rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
}
.filter-actions,
.toolbar-group,
.bulk-bar,
.map-feature-actions,
.map-tools-btns,
.list-card-head,
.account-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.filter-actions button,
.toolbar-group button,
.bulk-bar button,
.list-card-head button {
  margin-top: 0;
  flex: 0 1 auto;
}

/* Toolbar */
.toolbar.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: flex-start;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  min-width: 0;
}
.toolbar-label {
  white-space: normal;
  line-height: 1.3;
}
.toolbar-hint {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

/* Sidebar nav */
.sidebar-nav .nav-tab {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  margin-top: 0;
  padding: 0.65rem 0.8rem;
  white-space: normal;
  line-height: 1.3;
  word-break: break-word;
  overflow-wrap: anywhere;
  border-radius: 10px;
  font-weight: 600;
}
.sidebar-foot {
  white-space: normal;
  line-height: 1.35;
  word-break: break-word;
  padding: 0.65rem 0.85rem;
}

/* Cards e seções */
.card {
  overflow: visible;
}
.card h1,
.card h2,
.section-label {
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}
.form-lead,
.panel-intro > p,
.muted.small {
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  line-height: 1.45;
}

/* Forms: labels e campos não cortados */
label {
  min-width: 0;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
label > span {
  display: inline-block;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}
input,
select,
textarea {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 11.5rem), 1fr));
  gap: 0.65rem 0.85rem;
  align-items: end;
}
.filters label {
  margin: 0;
  min-width: 0;
}
.filters .filter-actions {
  grid-column: 1 / -1;
  margin-top: 0.25rem;
}
.password-field {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  width: 100%;
}
.password-field input {
  flex: 1 1 10rem;
  min-width: 0;
  margin-top: 0.4rem;
}
.password-field button {
  margin-top: 0.4rem;
  flex: 0 0 auto;
}

/* Tabelas: menos ellipsis forçado; wrap controlado */
.data-table-wrap,
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th,
.data-table td {
  padding: 0.55rem 0.65rem;
  vertical-align: top;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.data-table th {
  white-space: normal;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
}
.td-contrib {
  max-width: 14rem;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mono-id {
  word-break: break-all;
  overflow-wrap: anywhere;
  white-space: normal;
  font-size: 0.78rem;
  line-height: 1.35;
}
.td-actions,
.td-actions-inner {
  white-space: normal;
  min-width: 5.5rem;
}
.td-actions-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.td-actions .btn-sm {
  white-space: normal;
  flex: 1 1 auto;
  min-width: 0;
}

/* Status pills / badges */
.status-badge,
.pill,
.pill-role,
.filter-chip {
  white-space: normal;
  word-break: break-word;
  line-height: 1.25;
  max-width: 100%;
}

/* Bulk bar */
.bulk-bar {
  gap: 0.5rem 0.75rem;
  padding: 0.7rem 0.85rem;
  align-items: flex-start;
}
.bulk-bar .bulk-label-full,
.bulk-count,
#bulk-count {
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
}
.bulk-secondary-wrap,
.bulk-status-wrap {
  min-width: 0;
  max-width: 100%;
}

/* Modal detalhe */
.modal-panel {
  max-width: min(980px, 98vw);
  width: 100%;
  box-sizing: border-box;
}
.modal-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-start;
  justify-content: space-between;
}
.modal-head h2,
.modal-title {
  min-width: 0;
  flex: 1 1 12rem;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.modal-head-actions {
  flex: 1 1 auto;
  justify-content: flex-end;
  max-width: 100%;
}
.modal-head-actions .btn-sm,
.modal-actions-group .btn-sm {
  white-space: normal;
  min-width: 0;
}
.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
  gap: 0.65rem 0.9rem;
}
.fields-grid label,
.field-block {
  min-width: 0;
}
.field-value,
.detail-field-value {
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  line-height: 1.4;
}

/* Login */
.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.95fr);
  gap: 1.5rem;
  align-items: stretch;
  max-width: 980px;
  margin: 1.5rem auto;
  padding: 0 0.5rem;
}
.login-card {
  min-width: 0;
}
.login-card h1 {
  line-height: 1.25;
  word-break: break-word;
}
.login-hero-title {
  line-height: 1.3;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.login-hero-list li {
  line-height: 1.4;
  word-break: break-word;
}
.btn-block {
  width: 100%;
  margin-top: 0.85rem;
}
.linkish {
  white-space: normal;
  word-break: break-word;
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  margin: 0;
  min-height: 0;
  box-shadow: none;
}

/* Account / forms longos */
.account-card .list-card-head {
  flex-wrap: wrap;
}
.account-form {
  max-width: 40rem;
}
.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
  line-height: 1.4;
}
.checkbox-row input[type='checkbox'] {
  width: auto;
  margin: 0.2rem 0 0;
  flex: 0 0 auto;
}
.checkbox-row span {
  flex: 1 1 12rem;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
  gap: 0.75rem;
}
.kpi {
  min-width: 0;
  cursor: pointer;
}
.kpi-label,
.kpi-hint {
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
}
.kpi .num {
  word-break: break-all;
  line-height: 1.15;
}

/* Cmdk / confirm */
.cmdk-panel,
.confirm-panel,
.help-panel {
  max-width: min(560px, 96vw);
}
.cmdk-item,
.confirm-msg {
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  line-height: 1.4;
}

/* Toasts: texto completo */
.toast,
.toast-item {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
  max-width: min(28rem, 92vw);
}

/* Map feature panel already handled; ensure buttons */
.map-feature-actions .btn-sm {
  white-space: normal;
  flex: 1 1 auto;
  min-width: min(100%, 7rem);
}

/* Light theme coherence */
html[data-theme='light'] .page-header {
  border-bottom-color: var(--border);
}
html[data-theme='light'] .toolbar.toolbar-actions {
  background: var(--surface);
}

/* Responsive refinements */
@media (max-width: 900px) {
  .login-shell {
    grid-template-columns: 1fr;
    margin: 0.75rem auto 1.5rem;
  }
  .login-hero {
    padding: 1rem 1.1rem;
  }
  .toolbar.toolbar-actions {
    padding: 0.65rem 0.7rem;
  }
  .page-desc {
    font-size: 0.84rem;
  }
  .top-right .top-label-full {
    /* em mobile estreito o short label já existe em vários botões */
  }
}
@media (max-width: 560px) {
  .page-desc {
    display: block !important;
    -webkit-line-clamp: 4;
    display: -webkit-box !important;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .filters {
    grid-template-columns: 1fr;
  }
  .filter-actions button,
  .toolbar-group button {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }
  .btn-logout .top-label-full,
  #btn-theme .top-label-full,
  #btn-density .top-label-full {
    /* short labels already in markup */
  }
  .user-badge {
    max-width: min(180px, 48vw);
  }
  .modal-head-actions {
    width: 100%;
    justify-content: stretch;
  }
  .modal-head-actions .btn-sm {
    flex: 1 1 calc(50% - 0.25rem);
  }
}
@media (max-width: 380px) {
  .filter-actions button,
  .toolbar-group button,
  .modal-head-actions .btn-sm {
    flex: 1 1 100%;
  }
  .sub {
    max-width: 55vw;
  }
  /* Não esconder descrição no mobile extremo — só limitar linhas */
  .page-desc {
    display: -webkit-box !important;
  }
}

/* Density: ainda legível */
html[data-density='compact'] button.btn-sm {
  min-height: 1.9rem;
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
}
html[data-density='compact'] .data-table th,
html[data-density='compact'] .data-table td {
  padding: 0.4rem 0.5rem;
  font-size: 0.82rem;
}
html[data-density='compact'] .page-desc {
  font-size: 0.82rem;
}
/* ==========================================================================
   Fichas + Minha conta — layout dedicado (portal municipal)
   Escopo: #panel-fichas e #panel-account apenas
   ========================================================================== */

/* —— Fichas —— */
#panel-fichas {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
#panel-fichas.hidden {
  display: none !important;
}
#panel-fichas > .card {
  margin-bottom: 0;
}
#panel-fichas .panel-intro-pro {
  padding: 1rem 1.15rem;
}
#panel-fichas .panel-intro-text {
  max-width: 48rem;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}
#panel-fichas .list-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin-bottom: 0.85rem;
}
#panel-fichas .list-card-head h2 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}
#panel-fichas .list-card-head-hint {
  flex: 1 1 12rem;
  min-width: 0;
  max-width: 100%;
  text-align: right;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}
#panel-fichas .fichas-filters-card .filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr));
  gap: 0.7rem 0.9rem;
  align-items: end;
}
#panel-fichas .fichas-filters-card .filters label {
  margin: 0;
  min-width: 0;
}
#panel-fichas .fichas-filters-card .filters input,
#panel-fichas .fichas-filters-card .filters select {
  min-width: 0;
  max-width: 100%;
}
#panel-fichas .filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  grid-column: 1 / -1;
}
#panel-fichas .filter-actions button {
  margin-top: 0;
  flex: 0 1 auto;
  white-space: normal;
  line-height: 1.3;
  min-height: 2.2rem;
}
#panel-fichas .filter-group-label {
  flex: 0 0 auto;
  margin-right: 0.15rem;
}
#panel-fichas .checkbox-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.45rem;
  padding: 0.35rem 0;
}
#panel-fichas .checkbox-row input[type='checkbox'] {
  width: auto;
  margin: 0.15rem 0 0;
  flex-shrink: 0;
}
#panel-fichas .checkbox-row span {
  flex: 1 1 10rem;
  min-width: 0;
  line-height: 1.4;
  word-break: break-word;
}
#panel-fichas .filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}
#panel-fichas .filter-chip {
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
}
#panel-fichas #list-meta {
  margin: 0.65rem 0 0;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}
#panel-fichas .list-kbd-details {
  margin-top: 0.5rem;
}
#panel-fichas .list-kbd-details summary {
  cursor: pointer;
  line-height: 1.4;
  word-break: break-word;
}
#panel-fichas .list-kbd-hint {
  line-height: 1.55;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Cabeçalho da lista + ordenação */
#panel-fichas .fichas-list-head .list-head-right {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.65rem;
  min-width: 0;
  max-width: 100%;
  justify-content: flex-end;
}
#panel-fichas .sort-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  min-width: 0;
  font-weight: 500;
}
#panel-fichas .sort-label-text {
  font-size: 0.75rem;
  line-height: 1.2;
}
#panel-fichas .sort-select {
  margin-top: 0;
  min-width: 8.5rem;
  max-width: 100%;
  width: auto;
  padding: 0.45rem 0.6rem;
}
#panel-fichas .list-count-badge {
  align-self: center;
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
  max-width: 100%;
}
#panel-fichas #btn-export-page {
  margin-top: 0;
  align-self: center;
}

/* Bulk bar Fichas */
#panel-fichas .bulk-bar {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.75rem 0.85rem;
  margin: 0 0 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
#panel-fichas .bulk-bar.hidden {
  display: none !important;
}
#panel-fichas .bulk-bar-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
}
#panel-fichas .bulk-count {
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
  flex: 1 1 auto;
  min-width: 0;
}
#panel-fichas .bulk-primary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-width: 0;
}
#panel-fichas .bulk-primary-actions .btn-sm {
  margin-top: 0;
  white-space: normal;
  line-height: 1.25;
  min-height: 2.15rem;
}
#panel-fichas .bulk-secondary-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.1rem;
  padding-top: 0.35rem;
}
#panel-fichas .bulk-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: min(100%, 12rem);
  flex: 1 1 12rem;
}
#panel-fichas .bulk-group-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.3;
  word-break: break-word;
}
#panel-fichas .bulk-copy-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
#panel-fichas .bulk-copy-group .btn-sm {
  margin-top: 0;
  white-space: normal;
}
#panel-fichas .bulk-status-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: flex-end;
  padding-top: 0.35rem;
}
#panel-fichas .bulk-status-label {
  flex: 1 1 10rem;
  min-width: 0;
  margin: 0;
}
#panel-fichas .bulk-parecer {
  flex: 1 1 100%;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
  line-height: 1.4;
}
#panel-fichas #btn-bulk-apply {
  margin-top: 0;
  white-space: normal;
}

/* Tabela fichas */
#panel-fichas .table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}
#panel-fichas #fichas-table {
  width: 100%;
  min-width: 640px;
}
#panel-fichas #fichas-table th,
#panel-fichas #fichas-table td {
  padding: 0.55rem 0.6rem;
  vertical-align: top;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}
#panel-fichas #fichas-table th {
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: normal;
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
#panel-fichas #fichas-table .th-check {
  width: 2.25rem;
  text-align: center;
}
#panel-fichas #fichas-table .mono-id {
  font-size: 0.76rem;
  word-break: break-all;
  white-space: normal;
}
#panel-fichas #fichas-table .td-contrib {
  max-width: 12rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
}
#panel-fichas #fichas-table .td-actions-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  min-width: 6rem;
}
#panel-fichas #fichas-table .td-actions-inner .btn-sm {
  margin-top: 0;
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  line-height: 1.25;
}
#panel-fichas .pager,
#panel-fichas .pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.85rem;
}
#panel-fichas .pager button,
#panel-fichas .pagination button {
  margin-top: 0;
}

/* —— Minha conta —— */
#panel-account {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: 52rem;
}
#panel-account.hidden {
  display: none !important;
}
#panel-account > .card {
  margin-bottom: 0;
}
#panel-account .panel-intro-pro {
  padding: 1rem 1.15rem 1.1rem;
}
#panel-account .panel-intro-text {
  max-width: 44rem;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}
#panel-account .account-section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
}
#panel-account .account-section-nav .account-jump {
  margin-top: 0;
  white-space: normal;
  line-height: 1.25;
  min-height: 2.15rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
}
#panel-account .account-section-nav .account-jump.is-active,
#panel-account .account-section-nav .account-jump[aria-current='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 700;
}
#panel-account .account-card {
  padding: 1.1rem 1.2rem 1.15rem;
  scroll-margin-top: calc(var(--header-h, 64px) + 0.75rem);
  transition:
    box-shadow 0.25s ease,
    border-color 0.25s ease;
}
#panel-account .account-card.account-card-focus {
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px var(--accent-soft),
    var(--shadow-sm);
}
#panel-account .list-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 0.85rem;
  margin-bottom: 0.75rem;
}
#panel-account .list-card-head h2 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
  text-transform: none;
  letter-spacing: -0.01em;
  font-size: 1.05rem;
  font-weight: 750;
  color: var(--text);
}
#panel-account .list-card-head .muted {
  flex: 0 1 auto;
  min-width: 0;
  text-align: right;
  line-height: 1.35;
  word-break: break-word;
}
#panel-account .form-lead {
  margin: 0 0 0.85rem;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 40rem;
}
#panel-account .account-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  max-width: 28rem;
}
#panel-account .account-form label {
  margin: 0;
  min-width: 0;
}
#panel-account .account-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.25rem;
}
#panel-account .account-form-actions button {
  margin-top: 0;
  white-space: normal;
  line-height: 1.3;
  min-height: 2.35rem;
}
#panel-account .password-field {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  width: 100%;
}
#panel-account .password-field input {
  flex: 1 1 12rem;
  min-width: 0;
  margin-top: 0.4rem;
}
#panel-account .password-field .btn-sm {
  margin-top: 0.4rem;
  flex: 0 0 auto;
}
#panel-account .field-hint {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.8rem;
}
#panel-account .pw-strength {
  margin-top: 0.4rem;
  height: 0.35rem;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
#panel-account .pw-strength-bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition:
    width 0.2s ease,
    background 0.2s ease;
}
#panel-account .pw-strength-label {
  display: block;
  margin-top: 0.3rem;
  line-height: 1.35;
  word-break: break-word;
}

/* Perfil */
#panel-account .profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
  gap: 1rem 1.25rem;
}
#panel-account .profile-col {
  min-width: 0;
}
#panel-account .profile-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
#panel-account .profile-name {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
  font-weight: 750;
  line-height: 1.3;
  word-break: break-word;
  overflow-wrap: anywhere;
}
#panel-account .profile-role {
  margin: 0 0 0.35rem;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
}
#panel-account .profile-login-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}
#panel-account .profile-login-actions .btn-sm {
  margin-top: 0;
  white-space: normal;
}
#panel-account .profile-caps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-width: 100%;
}
#panel-account .profile-caps .cap-chip {
  white-space: normal;
  word-break: break-word;
  line-height: 1.25;
  max-width: 100%;
}
#panel-account #profile-login,
#panel-account #profile-tenant,
#panel-account #profile-2fa {
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

/* 2FA */
#panel-account .twofa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.65rem 0;
}
#panel-account .twofa-actions button {
  margin-top: 0;
  white-space: normal;
  line-height: 1.3;
  min-height: 2.35rem;
}
#panel-account .twofa-steps {
  margin: 0.5rem 0 0.75rem 1.15rem;
  padding: 0;
  line-height: 1.45;
}
#panel-account .twofa-steps li {
  margin: 0.35rem 0;
  word-break: break-word;
}
#panel-account .twofa-setup-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem 1.25rem;
  align-items: start;
  margin-top: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}
#panel-account .twofa-qr-wrap {
  min-width: 0;
}
#panel-account .twofa-qr {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
}
#panel-account .twofa-secret-wrap {
  min-width: 0;
}
#panel-account .twofa-secret {
  word-break: break-all;
  overflow-wrap: anywhere;
  line-height: 1.45;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  margin: 0.4rem 0 0.55rem;
}
#panel-account #twofa-code {
  max-width: 12rem;
  letter-spacing: 0.12em;
  font-family: var(--font-mono);
  font-size: 1.05rem;
}
#panel-account .twofa-status-line {
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Tenant card */
#panel-account #tenant-form {
  max-width: 32rem;
}
#panel-account .color-field {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
}
#panel-account .color-field input[type='color'] {
  width: 3rem;
  height: 2.6rem;
  flex: 0 0 auto;
  padding: 0.15rem;
  margin: 0;
}
#panel-account .color-field input[type='text'],
#panel-account .color-field #t-color {
  flex: 1 1 8rem;
  min-width: 0;
  margin: 0;
}
#panel-account .logo-field {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
#panel-account .logo-field input[type='file'] {
  flex: 1 1 12rem;
  min-width: 0;
  max-width: 100%;
}
#panel-account .tenant-smtp-note {
  margin: 0.65rem 0 0;
  line-height: 1.45;
  word-break: break-word;
}
#panel-account .advanced-acl {
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}
#panel-account .advanced-acl summary {
  cursor: pointer;
  word-break: break-word;
  line-height: 1.4;
}
#panel-account .mono-input {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  word-break: break-all;
}

/* Prefs: botões em grade legível */
#panel-account #account-prefs-card .account-form-actions {
  max-width: none;
}
#panel-account #account-prefs-card .account-form-actions button {
  flex: 0 1 auto;
  min-width: min(100%, 9.5rem);
}
#panel-account #offline-queue-meta,
#panel-account #pref-msg,
#panel-account #pwa-status,
#panel-account #cp-msg,
#panel-account #twofa-msg,
#panel-account #tenant-msg {
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
  margin: 0.55rem 0 0;
}
#panel-account .offline-queue-list {
  display: grid;
  gap: 0;
  margin-top: 0.6rem;
  border-top: 1px solid var(--border);
}
#panel-account .offline-queue-list.hidden {
  display: none;
}
#panel-account .offline-queue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem 0.8rem;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}
#panel-account .offline-queue-copy {
  min-width: 0;
}
#panel-account .offline-queue-label {
  display: block;
  color: var(--text);
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
#panel-account .offline-queue-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.55rem;
  align-items: center;
  margin-top: 0.25rem;
}
#panel-account .offline-queue-state {
  display: inline-flex;
  align-items: center;
  min-height: 1.45rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.2;
}
#panel-account .offline-queue-state.is-ready {
  border-color: var(--ok-border, var(--border));
  color: var(--ok, var(--text));
}
#panel-account .offline-queue-state.is-warning {
  border-color: var(--warn-border, var(--border));
  color: var(--warn, var(--text));
}
#panel-account .offline-queue-remove {
  margin: 0;
  align-self: center;
}

@media (max-width: 720px) {
  #panel-fichas .list-card-head-hint {
    text-align: left;
    flex: 1 1 100%;
  }
  #panel-fichas .fichas-list-head .list-head-right {
    width: 100%;
    justify-content: flex-start;
  }
  #panel-fichas .sort-label {
    flex: 1 1 calc(50% - 0.35rem);
  }
  #panel-fichas .sort-select {
    width: 100%;
    min-width: 0;
  }
  #panel-fichas .filter-actions button {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }
  #panel-fichas .bulk-primary-actions .btn-sm {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }
  #panel-account {
    max-width: none;
  }
  #panel-account .twofa-setup-grid {
    grid-template-columns: 1fr;
  }
  #panel-account .list-card-head .muted {
    text-align: left;
    flex: 1 1 100%;
  }
  #panel-account #account-prefs-card .account-form-actions button {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }
}
@media (max-width: 420px) {
  #panel-fichas .filter-actions button,
  #panel-fichas .bulk-primary-actions .btn-sm,
  #panel-account #account-prefs-card .account-form-actions button,
  #panel-account .account-form-actions button,
  #panel-account .twofa-actions button {
    flex: 1 1 100%;
  }
  #panel-fichas .sort-label {
    flex: 1 1 100%;
  }
  #panel-account .offline-queue-row {
    grid-template-columns: 1fr;
  }
  #panel-account .offline-queue-remove {
    justify-self: stretch;
    width: 100%;
  }
  #panel-fichas #fichas-table {
    min-width: 520px;
  }
}
/* Fichas: linha aberta / abrindo + modal detalhe */
#panel-fichas #fichas-body tr.ficha-row.row-open {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
  background: var(--accent-soft);
}
#panel-fichas #fichas-body tr.ficha-row.row-opening {
  opacity: 0.85;
  box-shadow: inset 3px 0 0 var(--accent);
}
#panel-fichas #fichas-body tr.ficha-row.row-opening .btn-open {
  opacity: 0.75;
}
#panel-fichas #fichas-body tr.ficha-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
#detail-modal .detail-loading {
  padding: 0.75rem 0;
}
#detail-modal .skeleton-row {
  height: 0.85rem;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--border) 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.1s ease-in-out infinite;
  margin: 0.45rem 0;
  max-width: 100%;
}
#detail-modal .skeleton-row:nth-child(2) {
  width: 92%;
}
#detail-modal .skeleton-row:nth-child(3) {
  width: 78%;
}
#detail-modal .skeleton-row:nth-child(4) {
  width: 64%;
}
@keyframes skeleton-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}
#detail-modal .modal-head-actions {
  max-width: 100%;
}
#detail-modal .modal-head-actions .btn-sm {
  white-space: normal;
  line-height: 1.25;
}
#detail-modal #detail-error:not(.hidden) {
  margin: 0.5rem 0;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(248, 113, 113, 0.4);
  background: var(--danger-soft);
  color: #fecaca;
  word-break: break-word;
  line-height: 1.4;
}
#detail-modal .detail-meta {
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.45;
}
@media (prefers-reduced-motion: reduce) {
  #detail-modal .skeleton-row {
    animation: none;
  }
}
/* Shell SPA — coerência multi-dispositivo (web / tablet / mobile) */
.dash-shell {
  display: flex;
  min-height: calc(100vh - var(--header-h, 64px));
  min-height: calc(100dvh - var(--header-h, 64px));
  width: 100%;
}
.dash-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.25rem 0 1.5rem;
}
.tab-panel {
  min-width: 0;
  width: 100%;
}
.map-orto-status {
  margin: 0.25rem 0 0;
  line-height: 1.4;
  word-break: break-word;
}
.map-orto-status.is-ok {
  color: var(--ok, #34d399);
}
.map-orto-status.is-warn {
  color: var(--warn, #fbbf24);
}
.map-basemap-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
@media (max-width: 800px) {
  .dash-shell {
    display: block;
  }
  .dash-main {
    width: 100%;
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
  }
}
/* ==========================================================================
   #panel-map — pop-up + toolbar + painel + responsivo (produção)
   ========================================================================== */
#panel-map {
  min-width: 0;
  width: 100%;
}
#panel-map .map-panel-card-pro {
  padding: 0.95rem 1rem 1.05rem;
  max-width: 100%;
  box-sizing: border-box;
}
#panel-map .map-panel-title {
  margin: 0 0 0.3rem;
  font-size: clamp(1.05rem, 2.2vw, 1.2rem);
  line-height: 1.3;
  word-break: break-word;
}
#panel-map .map-intro {
  margin: 0;
  max-width: 48rem;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}
#panel-map .map-basemap-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.5rem;
  margin: 0.75rem 0 0.65rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
#panel-map .map-basemap-row > .muted {
  flex: 0 0 auto;
  width: 100%;
  margin: 0 0 0.15rem;
  font-weight: 650;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}
#panel-map .map-layer-toggle {
  margin: 0;
  max-width: 100%;
  white-space: normal;
  line-height: 1.3;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
}
#panel-map .map-layer-toggle span {
  word-break: break-word;
}
#panel-map .map-tools-row {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0 0 0.85rem;
}
#panel-map .map-layer-toggles {
  width: 100%;
  max-height: min(28vh, 220px);
  overflow: auto;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  box-sizing: border-box;
}
#panel-map .map-layer-group-head {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0.35rem 0 0.3rem;
}
#panel-map .map-layer-group:first-child .map-layer-group-head {
  margin-top: 0;
}
#panel-map .map-tools-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: stretch;
  width: 100%;
}
#panel-map .map-tools-btns .btn-sm,
#panel-map .map-tools-btns > details > summary {
  margin-top: 0;
  flex: 0 1 auto;
  min-width: 0;
  min-height: 2.2rem;
  white-space: normal;
  line-height: 1.25;
  word-break: break-word;
  padding: 0.4rem 0.7rem;
}
#panel-map .map-tools-more-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.4rem 0 0;
}
#panel-map .map-tools-more-body .btn-sm {
  margin-top: 0;
  white-space: normal;
}
#panel-map .map-act-short {
  display: none;
}
#panel-map .map-act-full {
  display: inline;
}
#panel-map .map-layout {
  gap: 0.75rem;
  min-width: 0;
}
#panel-map .map-stage {
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
#panel-map .map-box.map-box-tab {
  border: none;
  border-radius: 0;
}
#panel-map .map-feature-panel,
#panel-map .map-fichas-list-panel {
  max-height: min(58vh, 520px);
  min-width: 0;
  box-sizing: border-box;
}
#panel-map .map-feature-head {
  gap: 0.5rem;
  align-items: flex-start;
}
#panel-map .map-feature-title {
  min-width: 0;
  flex: 1 1 auto;
  word-break: break-word;
  line-height: 1.3;
  text-transform: none;
  letter-spacing: -0.01em;
  font-size: 0.95rem;
  font-weight: 750;
  color: var(--text);
}
#panel-map #map-feature-close {
  margin-top: 0;
  flex-shrink: 0;
  white-space: nowrap;
}
#panel-map .map-feature-insc {
  font-size: 0.95rem;
  line-height: 1.35;
  margin: 0.15rem 0 0.45rem;
  white-space: nowrap;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: thin;
}
#panel-map .map-feature-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}
#panel-map .map-feature-actions .btn-sm {
  margin-top: 0;
  flex: 1 1 calc(50% - 0.25rem);
  min-width: min(100%, 7.5rem);
  min-height: 2.25rem;
  white-space: normal;
  line-height: 1.25;
  text-align: center;
  word-break: break-word;
  padding: 0.4rem 0.55rem;
}
#panel-map .map-feature-foot-details {
  margin-top: 0.55rem;
}
#panel-map .map-feature-foot-details summary {
  cursor: pointer;
  line-height: 1.4;
  word-break: break-word;
  padding: 0.25rem 0;
}
#panel-map .map-feature-foot {
  margin: 0.4rem 0 0;
  line-height: 1.45;
  word-break: break-word;
}
#panel-map #map-meta,
#panel-map #map-orto-status {
  margin: 0.45rem 0 0;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}
#panel-map .map-list-kbd-hint {
  line-height: 1.45;
  word-break: break-word;
}
#panel-map .map-fichas-list-head {
  flex-wrap: wrap;
  gap: 0.35rem;
}
#panel-map .map-fichas-list-head strong {
  word-break: break-word;
}
#panel-map #map-list-search {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0.4rem 0;
}

/* Pop-up: botões sem cortar texto */
.gis-popup-btn {
  white-space: normal !important;
  text-overflow: unset !important;
  overflow: visible !important;
  line-height: 1.3 !important;
  min-height: 2.15rem !important;
  height: auto !important;
  padding: 0.42rem 0.7rem !important;
  flex: 1 1 calc(50% - 0.25rem);
}
.gis-popup-btn span:not(.ico) {
  word-break: break-word;
  text-align: center;
}
.gis-popup-actions {
  gap: 0.4rem !important;
}
.gis-feature-popup .leaflet-popup-content {
  min-width: min(290px, 92vw) !important;
}

/* Labels curtos no mapa em mobile */
@media (max-width: 640px) {
  #panel-map .map-act-full {
    display: none;
  }
  #panel-map .map-act-short {
    display: inline;
  }
  #panel-map .map-tools-btns .btn-sm {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }
  #panel-map .map-basemap-row > .muted {
    margin-bottom: 0.05rem;
  }
  #panel-map .map-layer-toggle {
    flex: 1 1 calc(50% - 0.3rem);
    justify-content: flex-start;
    font-size: 0.78rem;
  }
  #panel-map .map-feature-actions .btn-sm {
    flex: 1 1 calc(50% - 0.25rem);
  }
  #panel-map .map-panel-card-pro {
    padding: 0.75rem 0.7rem 0.9rem;
  }
  #panel-map .map-layer-toggles {
    max-height: min(34vh, 200px);
  }
}
@media (max-width: 420px) {
  #panel-map .map-tools-btns .btn-sm,
  #panel-map .map-feature-actions .btn-sm,
  #panel-map .map-layer-toggle {
    flex: 1 1 100%;
  }
  .gis-popup-btn {
    flex: 1 1 100% !important;
  }
  #panel-map .map-box.map-box-tab {
    height: clamp(280px, 48dvh, 420px);
    min-height: 260px;
  }
}
@media (min-width: 901px) {
  #panel-map .map-layout.has-side {
    grid-template-columns: 1fr minmax(260px, 340px);
  }
  #panel-map .map-feature-actions .btn-sm {
    flex: 1 1 calc(50% - 0.25rem);
  }
}
