/* DM Sans local (OFL, ver static/fonts/OFL.txt): fonte variável, subconjunto latin.
   `optional` = nunca troca de fonte a meio da página (sem salto de largura do texto);
   o <link rel="preload"> no <head> torna raro cair na fonte do sistema. */
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 900;
  font-display: optional;
  src: url("../fonts/dm-sans-latin.6c1e961057d2.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Transições entre páginas (#199): a sidebar e a barra de topo ficam paradas e só o
   conteúdo faz um fade curto. Chrome 126+; browsers mais antigos (Android 7) ignoram. */
@view-transition {
  navigation: auto;
}
.sidebar {
  view-transition-name: sidebar;
}
.topbar {
  view-transition-name: topbar;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 120ms;
}
@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}

/* Sinal de clique (#199): barra fina no topo, só aparece se a página demorar. */
.nav-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100000;
  width: 100%;
  height: 3px;
  background: #2563eb;
  transform: scaleX(0);
  transform-origin: left center;
  opacity: 0;
  pointer-events: none;
}
html[data-theme="dark"] .nav-progress {
  background: #60a5fa;
}
.nav-progress.is-active {
  opacity: 1;
  transform: scaleX(0.9);
  transition: transform 8s cubic-bezier(0.1, 0.6, 0.2, 1);
}
@media (prefers-reduced-motion: reduce) {
  .nav-progress.is-active {
    transform: scaleX(0.9);
    transition: none;
  }
}

:root {
  --sidebar-w: 230px;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f3f4f6;
  --ok-bg: #ecfdf5;
  --ok-border: #a7f3d0;
  --ok-text: #065f46;
  --bad-bg: #fef2f2;
  --bad-border: #fecaca;
  --bad-text: #991b1b;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #92400e;
  --sidebar-bg: #14294a;
  --sidebar-grad-top: #244a7a;
  --sidebar-grad-mid: #15294a;
  --sidebar-grad-bottom: #080f1c;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-text: rgba(255, 255, 255, 0.6);
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active-bg: rgba(255, 255, 255, 0.11);
  --sidebar-active: #ffffff;
  /* Superuser: cor roxa para ações exclusivas (validações, processo automático) */
  --superuser-bg: #f5f3ff;
  --superuser-bg-alt: #ede9fe;
  --superuser-border: #c4b5fd;
  --superuser-text: #5b21b6;
  --superuser-accent: #7c3aed;
  --superuser-shadow: rgba(124, 58, 237, 0.15);
}

/* Blocos superuser: fundo roxo + borda roxa — validações, processo automático */
.card.superuser-accent,
.superuser-accent {
  position: relative;
  background: #f0ebff !important;
  border: 1.5px solid var(--superuser-border) !important;
  border-top: 4px solid var(--superuser-accent) !important;
  box-shadow: 0 2px 16px var(--superuser-shadow), 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}
.card.superuser-accent:hover {
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.22), 0 2px 8px rgba(0, 0, 0, 0.06) !important;
}
.card.superuser-accent::after {
  content: '⚡ só superuser';
  position: absolute;
  top: 10px;
  right: 14px;
  background: var(--superuser-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.6;
  pointer-events: none;
}
/* Cards superuser em <details>: sem badge no canto (título no summary) */
details.superuser-drill.card.superuser-accent::after {
  display: none;
}
.superuser-strip {
  position: relative;
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
  border: 1.5px solid var(--superuser-border);
  border-left: 5px solid var(--superuser-accent);
  box-shadow: 0 2px 16px var(--superuser-shadow), 0 1px 3px rgba(0, 0, 0, 0.04);
}
.superuser-strip::after {
  content: '⚡ só superuser';
  position: absolute;
  top: 8px;
  right: 12px;
  background: var(--superuser-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.6;
  pointer-events: none;
}

/* Faixa processo automático: colapsada por defeito — sem badge duplicado (título no summary) */
details.superuser-drill-strip.superuser-strip::after {
  display: none;
}

/* ─── Superuser em <details>: minimizado até expandir ─── */
details.superuser-drill.card {
  overflow: hidden;
}
details.superuser-drill > summary.superuser-drill__summary {
  list-style: none;
  cursor: pointer;
  font-weight: 800;
  font-size: 22px;
  line-height: 1;
  color: var(--superuser-text);
  padding: 10px 14px 12px;
  /* Só o símbolo ⚡ — alvo de toque confortável */
  min-height: 44px;
  display: flex;
  align-items: center;
}
details.superuser-drill > summary::-webkit-details-marker {
  display: none;
}
details.superuser-drill[open] > summary.superuser-drill__summary {
  margin-bottom: 10px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--superuser-border);
}
details.superuser-drill > .superuser-drill__body {
  padding-top: 2px;
}

details.superuser-drill-strip {
  margin-top: 10px;
}
details.superuser-drill-strip > summary.superuser-drill-strip__summary {
  list-style: none;
  cursor: pointer;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: var(--superuser-text);
  padding: 12px 14px;
  min-height: 44px;
  display: flex;
  align-items: center;
}
details.superuser-drill-strip > summary::-webkit-details-marker {
  display: none;
}
details.superuser-drill-strip[open] > summary.superuser-drill-strip__summary {
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--superuser-border);
}
details.superuser-drill-strip .superuser-drill-strip__body {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 4px 16px 14px;
}
.superuser-strip:hover {
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.22), 0 2px 8px rgba(0, 0, 0, 0.06);
}
.superuser-strip .switch-on {
  background: var(--superuser-accent);
  color: #fff;
  border-color: var(--superuser-accent);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-x: hidden;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: #f0f2f5;
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: var(--sidebar-bg);
  background: linear-gradient(
    180deg,
    var(--sidebar-grad-top) 0%,
    var(--sidebar-grad-mid) 50%,
    var(--sidebar-grad-bottom) 100%
  );
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow: hidden;
}

/* Wrapper interior que faz scroll — isola do position:fixed do <aside> */
.sidebar-nav {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; /* Firefox: barra fina sempre visível */
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

/* Scroll da sidebar: barra fina e discreta, sempre visível (também no telemóvel) */
.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
}

.sidebar-brand {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand .brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.sidebar-brand .brand-row:hover { opacity: .85; }

.sidebar-brand .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, #1f2937, #0b1220);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #e5e7eb;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.sidebar-brand .brand-mark svg {
  width: 24px;
  height: 24px;
  display: block;
}

.sidebar-brand .brand-logo-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.sidebar-brand .brand-text-col {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.sidebar-brand .app-name {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #fff;
  text-shadow: none;
  text-decoration: none;
}
.sidebar-brand .app-sub {
  font-size: 8.6px;
  font-weight: 600;
  letter-spacing: 1.1px;
  line-height: 1.15;
  font-family: "DM Sans", sans-serif;
  text-transform: uppercase;
  color: #9fb2cf;
  margin-top: 3px;
  text-decoration: none;
}

.sidebar-brand .empresa-name {
  font-size: 13px;
  color: var(--sidebar-text);
  margin-top: 4px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand .restaurante-name {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 2px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-section {
  padding: 16px 8px 4px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  min-height: 44px;
  border-radius: 9px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 1px;
  cursor: pointer;
  border: none;
  width: 100%;
  background: transparent;
  overflow: hidden;
}

.nav-item-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active);
  font-weight: 700;
  box-shadow: inset 2px 0 0 #93c5fd;
}

.nav-item-locked {
  opacity: 0.55;
}

.nav-plan-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .06em;
  background: rgba(251,191,36,.18);
  color: #fbbf24;
  border: 1px solid rgba(251,191,36,.3);
  padding: 1px 5px;
  border-radius: 4px;
  line-height: 1.5;
  flex-shrink: 0;
}

.nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* Foto de perfil no lugar do ícone (sidebar) — sem alterar a altura da linha */
.nav-avatar-img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* Foto de perfil na barra de topo, antes do nome */
.topbar-avatar-img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 7px;
}

/* Foto de perfil na lista da equipa, antes do nome */
.equipa-avatar-img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 7px;
}

.sidebar-legal {
  padding: 6px 12px 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: center;
}
.sidebar-legal-link {
  font-size: 11px;
  color: var(--sidebar-muted, #9ca3af);
  text-decoration: none;
  opacity: 0.82;
  white-space: nowrap;
}
.sidebar-legal-link:hover { opacity: 1; text-decoration: underline; }
.sidebar-legal-sep { font-size: 10px; color: var(--sidebar-muted, #9ca3af); opacity: 0.5; }

.sidebar-footer {
  margin-top: auto;
  padding: 10px 8px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  position: relative;
}

/* Pista discreta de scroll: leve esbatido + traço central no fim da lista. */
.sidebar-footer::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -22px;
  height: 22px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(10, 19, 34, 0) 0%, rgba(10, 19, 34, 0.35) 100%);
}

.sidebar-footer::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -11px;
  width: 44px;
  height: 4px;
  border-radius: 99px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.62);
  pointer-events: none;
}

/* MAIN */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 13px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.topbar .topbar-search-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  margin-right: 10px;
}

.topbar-search-input {
  min-width: 280px;
  max-width: 420px;
  padding: 7px 10px;
  font-size: 12px;
}

.topbar-search-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.topbar .topbar-search-shortcut {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.login-transition-page {
  max-width: 760px;
  margin: 28px auto;
  padding: 10px 12px;
}

.login-transition-card {
  padding: 28px 24px;
  border-radius: 16px;
  border: 1px solid #dbe3ef;
}

.login-transition-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.login-transition-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  border: 1px solid #dbe3ef;
}

.login-transition-logo svg {
  width: 22px;
  height: 22px;
}

.login-transition-logo img {
  width: 36px;
  height: 36px;
  display: block;
  object-fit: contain;
  border-radius: 10px;
}

.login-transition-wordmark {
  font-size: 14px;
  letter-spacing: 0.08em;
  font-weight: 900;
  color: #0f172a;
}

.login-transition-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.login-transition-subtitle {
  margin-top: 8px;
  margin-bottom: 18px;
  color: #64748b;
  font-size: 14px;
}

.login-transition-progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

.login-transition-progress-fill {
  width: 42%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6 0%, #2563eb 60%, #1d4ed8 100%);
  animation: loginTransitionLoad 1.2s ease-in-out infinite;
}

.login-transition-dots {
  display: inline-flex;
  gap: 6px;
  margin-top: 12px;
}

.login-transition-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: loginTransitionDot 1.1s ease-in-out infinite;
}

.login-transition-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.login-transition-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.login-transition-fallback {
  margin-top: 14px;
  color: #64748b;
  font-size: 13px;
}

@keyframes loginTransitionLoad {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(320%);
  }
}

@keyframes loginTransitionDot {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.search-hit {
  background: #facc15;
  color: #111827;
  padding: 0 3px;
  border-radius: 4px;
  border: 1px solid #eab308;
  font-weight: 700;
}

.search-hit.search-hit--active {
  background: #f59e0b;
  border-color: #d97706;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
}

.search-row-focus {
  animation: search-row-pulse 2.4s ease-out 1;
  outline: 2px solid #f59e0b;
  outline-offset: -2px;
}

.search-row-focus > td,
.search-row-focus > th {
  background: rgba(250, 204, 21, 0.22) !important;
}

@keyframes search-row-pulse {
  0% {
    background-color: rgba(250, 204, 21, 0.55);
  }
  100% {
    background-color: transparent;
  }
}

.topbar-meta {
  font-size: 13px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  text-align: right;
}

.topbar-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid #dbe3ef;
  background: #f8fafc;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-logout-mobile-form {
  display: none;
  margin: 0;
}

.topbar-logout-mobile {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}

/* Tablet: garantir acesso rápido ao logout no topo */
@media (max-width: 1024px) {
  .topbar .topbar-search-form {
    margin-right: 4px;
  }

  .topbar-search-input {
    min-width: 150px;
    max-width: 190px;
  }

  .topbar-search-btn {
    padding: 6px 8px;
    font-size: 11px;
  }

  .topbar-logout-mobile-form {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
    flex-shrink: 0;
  }
}


.tenant-switch-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tenant-switch-select {
  min-width: 190px;
  max-width: 290px;
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 12px;
}

.tenant-switch-btn {
  padding: 6px 9px;
  font-size: 12px;
}

.tenant-switch-btn-icon {
  display: none;
}

.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 24px;
  flex: 1;
}

/* CARDS */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
}

.card:hover {
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  border-color: color-mix(in srgb, var(--line) 55%, #94a3b8);
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
}

/* Hub /relatorios/ — usa toda a largura útil do .container (alinha com módulos Temperaturas/Óleo/Limpezas). */
.wrap.wrap--reports-hub {
  max-width: 100%;
  width: 100%;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.row .card {
  flex: 1;
  min-width: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.section-gap {
  margin-top: 12px;
}

.module-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.module-actions form {
  margin: 0;
}

.module-actions form .btn {
  height: 100%;
}

.subtle-note {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.plan-base-callout {
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
}

.plan-base-callout-summary {
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 800;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.plan-base-callout-summary::-webkit-details-marker {
  display: none;
}

.plan-base-callout-summary::after {
  content: "▾";
  color: #64748b;
  font-size: 14px;
  transition: transform 0.15s ease;
}

.plan-base-callout[open] .plan-base-callout-summary::after {
  transform: rotate(180deg);
}

.plan-base-callout-body {
  margin-top: 8px;
}

.plan-base-callout-title {
  font-size: 14px;
  font-weight: 800;
  color: #334155;
  margin-bottom: 4px;
}

.plan-base-callout-text {
  color: #64748b;
  font-size: 13px;
  line-height: 1.45;
}

.plan-base-callout-form {
  margin-top: 10px;
}

.section-label {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-title {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Dashboard KPI sections — sombreado discreto único */
.dashboard-kpi-section {
  border-radius: var(--radius-lg);
  padding: 16px 18px 18px;
  margin-bottom: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}
.dashboard-kpi-section .section-label,
.dashboard-kpi-section .section-title {
  color: var(--muted);
}

/* Diário + mensal dentro do mesmo bloco visual (sem corte no meio) */
.dashboard-kpi-stack {
  border-radius: var(--radius-lg);
  padding: 16px 18px 18px;
  margin-bottom: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}

.dashboard-kpi-stack .dashboard-kpi-section--diario,
.dashboard-kpi-stack .dashboard-kpi-section--mensal {
  background: transparent;
  border: 0;
  box-shadow: none;
  margin-bottom: 0;
  padding: 0;
}

.dashboard-kpi-stack .dashboard-kpi-section--mensal {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}

.dashboard-head-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

/* Mesma altura nos dois cartões (Registos rápidos | Pronto para inspeção) */
.dashboard-head-grid > .card,
.dashboard-top-bento > .card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.dashboard-quick-card {
  padding: 12px 14px;
}

.dashboard-quick-card > .rowline.between {
  align-items: flex-start;
  gap: 12px;
  flex-wrap: nowrap;
}

.dashboard-quick-lines {
  margin-top: 6px;
  display: grid;
  gap: 4px;
}

.dashboard-quick-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: #334155;
}

.dashboard-quick-cta {
  align-self: center;
  flex: 0 0 auto;
  min-width: 84px !important;
  min-height: 36px !important;
  padding: 8px 14px !important;
  border-radius: 10px !important;
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  background: var(--sidebar-bg) !important;
  border-color: var(--sidebar-bg) !important;
  color: #fff !important;
}

.dashboard-head-inspecao {
  min-width: 0;
}

.dashboard-inspecao-card {
  padding: 12px 14px;
  border-top: 3px solid #cbd5e1;
  border-left: 4px solid transparent;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  container-type: inline-size;
  container-name: inspecao-card;
}

.dashboard-inspecao-grid {
  display: grid;
  grid-template-columns: minmax(9.5rem, max-content) minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 16px;
  row-gap: 6px;
  align-items: center;
  min-width: 0;
}

.dashboard-inspecao-grid > .dashboard-inspecao-title:first-child {
  grid-column: 1;
  grid-row: 1;
}

.dashboard-inspecao-main {
  grid-column: 1;
  grid-row: 2;
}

.dashboard-inspecao-col-modulos {
  grid-column: 2;
  grid-row: 1 / -1;
  justify-self: stretch;
  align-self: stretch;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding-left: 14px;
  border-left: 1px dashed #e2e8f0;
}

.dashboard-inspecao-title--modulos {
  text-align: left;
  width: 100%;
}

.dashboard-inspecao-card--sem-modulos .dashboard-inspecao-grid {
  grid-template-columns: 1fr;
}

.dashboard-inspecao-lado {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px 14px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.dashboard-inspecao-grupo {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.dashboard-inspecao-grupo + .dashboard-inspecao-grupo {
  padding-left: 10px;
  border-left: 1px dashed #e8eef4;
}

.dashboard-inspecao-grupo-titulo {
  margin: 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #64748b;
  line-height: 1.2;
  text-align: left;
}

.dashboard-inspecao-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.dashboard-inspecao-main--full {
  grid-column: 1 / -1;
  grid-row: 2;
}

/* Ordem da lista = ordem da sidebar (esquerda → direita, quebra de linha se necessário) */
.dashboard-inspecao-modulos {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px 6px;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dashboard-inspecao-modulo-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 0;
  padding: 3px 5px 2px;
  text-align: center;
  background: #f8fafc;
  border: 1px solid #e8eef4;
  border-radius: 6px;
}

.dashboard-inspecao-modulos-nome {
  font-size: 9px;
  line-height: 1.15;
  color: #64748b;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.dashboard-inspecao-modulos-pct {
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: #0f172a;
}

/* Ecrã largo (card ao lado do semáforo): cumprimento centrado na coluna direita */
@container inspecao-card (min-width: 721px) {
  .dashboard-inspecao-col-modulos {
    align-items: center;
  }

  .dashboard-inspecao-title--modulos {
    text-align: center;
  }

  .dashboard-inspecao-lado {
    justify-content: center;
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
  }

  .dashboard-inspecao-grupo {
    align-items: center;
  }

  .dashboard-inspecao-grupo-titulo {
    text-align: center;
  }

  .dashboard-inspecao-modulos {
    justify-content: center;
  }
}

/* Tablet / mobile / janela estreita: empilha e alinha à esquerda */
@container inspecao-card (max-width: 720px) {
  .dashboard-inspecao-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .dashboard-inspecao-grid > .dashboard-inspecao-title:first-child {
    grid-column: 1;
    grid-row: auto;
  }

  .dashboard-inspecao-main {
    grid-column: 1;
    grid-row: auto;
  }

  .dashboard-inspecao-col-modulos {
    grid-column: 1;
    grid-row: auto;
    justify-self: stretch;
    align-items: flex-start;
    width: 100%;
    padding-left: 0;
    padding-top: 8px;
    border-left: none;
    border-top: 1px dashed #e2e8f0;
  }

  .dashboard-inspecao-title--modulos {
    text-align: left;
  }

  .dashboard-inspecao-lado {
    flex-direction: column;
    justify-content: flex-start;
    width: 100%;
    margin-inline: 0;
    overflow: visible;
  }

  .dashboard-inspecao-grupo {
    align-items: flex-start;
  }

  .dashboard-inspecao-grupo-titulo {
    text-align: left;
  }

  .dashboard-inspecao-modulos {
    justify-content: flex-start;
  }

  .dashboard-inspecao-grupo + .dashboard-inspecao-grupo {
    padding-left: 0;
    padding-top: 8px;
    border-left: none;
    border-top: 1px dashed #e8eef4;
  }
}

@container inspecao-card (max-width: 520px) {
  .dashboard-inspecao-modulo-chip {
    flex: 1 1 calc(50% - 4px);
    max-width: calc(50% - 4px);
  }
}

.dashboard-inspecao-card--verde {
  border-top-color: #16a34a;
  border-left-color: #16a34a;
}

.dashboard-inspecao-card--amarelo {
  border-top-color: #f59e0b;
  border-left-color: #f59e0b;
}

.dashboard-inspecao-card--vermelho {
  border-top-color: #ef4444;
  border-left-color: #ef4444;
}

.dashboard-inspecao-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #334155;
  margin: 0;
  line-height: 1.2;
}

@media (max-width: 768px) {
  /* Mobile: cards pequenas e de tamanho igual em Importancia Alta e Normal.
     Colunas de largura fixa (nao esticam com nomes longos) para os dois
     grupos ficarem visualmente iguais; nomes compridos quebram de linha. */
  .dashboard-inspecao-grupo {
    width: 100%;
  }

  .dashboard-inspecao-modulos {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 104px));
    justify-content: start;
    gap: 4px;
  }

  .dashboard-inspecao-modulo-chip {
    flex: initial;
    max-width: none;
    min-width: 0;
    padding: 2px 4px 1px;
  }

  .dashboard-inspecao-modulos-nome {
    font-size: 8.5px;
  }

  .dashboard-inspecao-modulos-pct {
    font-size: 10.5px;
  }
}

@media (max-width: 360px) {
  /* Ecrãs muito estreitos: 2 colunas para os nomes não ficarem apertados */
  .dashboard-inspecao-modulos {
    grid-template-columns: repeat(2, minmax(0, 104px));
  }
}

.dashboard-inspecao-semaforo {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.dashboard-inspecao-luz {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  opacity: 0.14;
  filter: grayscale(35%);
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.2);
  transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-inspecao-luz.on {
  opacity: 1;
  filter: none;
  transform: scale(1.12);
}

.dashboard-inspecao-luz--vermelho {
  background: #ef4444;
}

.dashboard-inspecao-luz--amarelo {
  background: #f59e0b;
}

.dashboard-inspecao-luz--verde {
  background: #22c55e;
}

.dashboard-inspecao-luz--vermelho.on {
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.18), 0 0 10px rgba(239, 68, 68, 0.55);
}

.dashboard-inspecao-luz--amarelo.on {
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2), 0 0 10px rgba(245, 158, 11, 0.55);
}

.dashboard-inspecao-luz--verde.on {
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2), 0 0 10px rgba(34, 197, 94, 0.55);
}

.dashboard-inspecao-score {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  color: #0f172a;
}

.dashboard-inspecao-card--verde .dashboard-inspecao-score {
  color: #15803d;
}

.dashboard-inspecao-card--amarelo .dashboard-inspecao-score {
  color: #b45309;
}

.dashboard-inspecao-card--vermelho .dashboard-inspecao-score {
  color: #b91c1c;
}

.dashboard-inspecao-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #475569;
  font-weight: 600;
}

.table-wrap {
  margin-top: 8px;
  overflow-x: auto;
}

.table-wrap table {
  min-width: 640px;
}

/* Colunas secundárias: escondidas em mobile e tablet */
@media (max-width: 1024px) {
  .hide-mobile {
    display: none !important;
  }
}

/* Em tablet, tabelas sem min-width fixo — colunas restantes cabem na área disponível */
@media (min-width: 769px) and (max-width: 1024px) {
  .table-wrap table {
    min-width: 0;
  }
}

.table-wrap.compact {
  overflow-x: visible;
}

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

.table-wrap.compact th,
.table-wrap.compact td {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Receção — lista: acções dentro do cartão (não sair à direita do .card) */
.table-wrap.recepcao-list-table {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.table-wrap.recepcao-list-table table {
  width: 100%;
}
/* width:1% só em desktop (encolhe a coluna). Em mobile o cartão usa
   display:block + width:100%; se 1% ficar activo, «Ações»/botões
   colapsam letra a letra (bug Home Sushi, 05/11/2026). */
@media (min-width: 769px) {
  .table-wrap.recepcao-list-table td.cell-actions {
    width: 1%;
    white-space: normal;
    vertical-align: middle;
  }
}
.recepcao-row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
  max-width: 100%;
}
.recepcao-row-actions .btn {
  font-size: 12px;
  padding: 5px 10px;
}
.recepcao-row-actions__form {
  display: inline;
  margin: 0;
}

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
  font-weight: inherit;
}

.th-sort:hover {
  color: var(--accent, #111827);
  text-decoration: underline;
}

.th-sort.is-active {
  font-weight: 700;
}

.th-sort-icon {
  font-size: 11px;
  line-height: 1;
  opacity: 0.85;
}

/* Tabela Histórico de consumo — alinhamentos por coluna */
.consumo-table-wrap th:nth-child(2),
.consumo-table-wrap td:nth-child(2),
.consumo-table-wrap th:nth-child(3),
.consumo-table-wrap td:nth-child(3),
.consumo-table-wrap th:nth-child(4),
.consumo-table-wrap td:nth-child(4),
.consumo-table-wrap th:nth-child(5),
.consumo-table-wrap td:nth-child(5),
.consumo-table-wrap th:nth-child(6),
.consumo-table-wrap td:nth-child(6) {
  text-align: center;
}
.consumo-table-wrap th:nth-child(7),
.consumo-table-wrap td:nth-child(7) {
  text-align: right;
}

/* Equipa: Nome+email na mesma coluna, email quebra para evitar scroll horizontal */
.equipa-table-wrap .col-nome-email .email-subline {
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

/* Equipa: inativo + data de saída — contraste forte (evita texto cinza pequeno) */
.equipa-table-wrap .equipa-inativo-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  line-height: 1.35;
}
.equipa-table-wrap .equipa-saida-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #0f172a;
  background: #e2e8f0;
  border: 1px solid #94a3b8;
}

/* Equipa: botões de ação numa linha em desktop, colunas Cargo/Entrada mais compactas */
@media (min-width: 1025px) {
  .equipa-table-wrap .col-compact {
    width: 1%;
    white-space: nowrap;
  }
  .equipa-table-wrap td.cell-actions {
    white-space: nowrap;
  }
  .equipa-table-wrap td.cell-actions > * + * {
    margin-left: 6px;
  }
}

/* Plano: consumo por recurso (Conta + Dashboard) */
.plan-usage-head {
  margin-top: 12px;
  margin-bottom: 8px;
}

.plan-usage-head-note {
  margin: 4px 0 0;
  font-size: 12px;
}

.plan-usage-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
  margin-bottom: 20px;
}

.plan-usage-grid--dashboard {
  margin-top: 12px;
}

.plan-usage-item {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.plan-usage-name {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

.plan-usage-value {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.plan-usage-bar {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin: 7px 0 4px;
}

.plan-usage-fill {
  height: 100%;
  background: #60a5fa;
  border-radius: 999px;
}

.plan-usage-warning {
  margin: 4px 0 0;
  font-size: 12px;
  color: #b45309;
}

@media (max-width: 768px) {
  .plan-usage-grid {
    grid-template-columns: 1fr;
  }
}

/* TYPOGRAPHY */
.k {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.big {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.5px;
}

.muted {
  color: var(--muted);
}

/* BAR */
.bar {
  height: 7px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.fill {
  height: 100%;
  width: 0;
  background: #111827;
  border-radius: 999px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #111827;
  color: #fff;
  padding: 8px 14px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 1px 2px rgba(2, 6, 23, 0.08);
}

.btn:hover {
  filter: brightness(1.12);
}

.btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.btn.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.btn.secondary:hover {
  background: var(--soft);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.16);
}

.btn.dark {
  background: #111;
  color: #fff;
  border-color: #111;
}

/* Botão superuser: vermelho para ações exclusivas */
.btn.superuser-accent-btn {
  background: var(--superuser-accent);
  color: #fff;
  border-color: var(--superuser-accent);
}
.btn.superuser-accent-btn:hover {
  background: #6d28d9;
  border-color: #6d28d9;
}

.btn.danger {
  background: #b00020;
  color: #fff;
  border-color: #b00020;
}

.btn.danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(127, 29, 29, 0.28);
}

.btn:active {
  transform: translateY(0) scale(0.985);
  box-shadow: 0 1px 3px rgba(2, 6, 23, 0.12);
}

.btn.soft {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}

.btn.soft:hover {
  background: #eef2f7;
}

/* Back navigation button: unified look across modules */
.btn.btn-back {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}

.btn.btn-back:hover {
  background: #eef2f7;
}

/* PDF action button: unified icon + color */
.btn.btn-pdf {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}

.btn.btn-pdf:hover {
  background: #eef2f7;
}

.btn.btn-compact {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
}

.btn.btn-compact.btn-eliminar-text {
  color: var(--bad-text);
  border-color: var(--bad-border);
  background: var(--bad-bg);
}

.btn.btn-compact.btn-eliminar-text:hover {
  background: #fee2e2;
  border-color: #f87171;
}

.btn.logout-btn {
  color: rgba(255, 255, 255, 0.4);
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}

.btn.logout-btn:hover {
  color: rgba(255, 255, 255, 0.9);
  background: var(--sidebar-hover);
}

/* Botões ícone + etiqueta (congelação peixe) — alinhado ao estilo do projecto */
.btn-icon-label {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 52px;
  min-width: 52px;
  padding: 8px 6px;
  font-size: 13px;
  line-height: 1.2;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(2, 6, 23, 0.08);
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.btn-icon-label:hover {
  background: var(--soft);
  border-color: #94a3b8;
  box-shadow: 0 2px 4px rgba(2, 6, 23, 0.1);
  transform: translateY(-1px);
}
.btn-icon-label:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 1px 2px rgba(2, 6, 23, 0.08);
}
.btn-icon-label .btn-icon-char {
  font-size: 15px;
  margin-bottom: 3px;
  opacity: 0.9;
}
.btn-icon-label .btn-icon-text {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.btn-icon-label.btn-eliminar {
  color: var(--bad-text);
  border-color: var(--bad-border);
  background: var(--bad-bg);
}
.btn-icon-label.btn-eliminar:hover {
  background: #fee2e2;
  border-color: #f87171;
  box-shadow: 0 2px 4px rgba(127, 29, 29, 0.12);
}
.btn-icon-label.btn-eliminar .btn-icon-char {
  opacity: 1;
}
.btn-icon-label.btn-eliminar .btn-icon-text {
  color: var(--bad-text);
}
button.btn-icon-label {
  font: inherit;
  cursor: pointer;
  outline: none;
}
button.btn-icon-label:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}
.btn-actions-row {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Histórico de consumo: manter Editar/Eliminar na mesma linha. */
.consumo-table-wrap .btn-actions-row {
  flex-wrap: nowrap;
  white-space: nowrap;
}

.consumo-table-wrap .btn-actions-row form {
  display: inline-flex;
}

/* Equipamentos de refrigeração: ações e limites numa linha em desktop/tablet */
.equipamentos-table-wrap .btn-actions-row {
  gap: 6px;
}

@media (min-width: 769px) {
  .equipamentos-table-wrap .btn-actions-row {
    flex-wrap: nowrap;
    white-space: nowrap;
  }

  .equipamentos-table-wrap .btn-actions-row form {
    display: inline-flex;
  }

  .equipamentos-table-wrap th.col-limites,
  .equipamentos-table-wrap td.col-limites {
    white-space: nowrap;
  }
}

.nav-label-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* PILLS */
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--soft);
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  border: 1px solid var(--line);
}

.pill.ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-text);
}

.pill.bad {
  background: var(--bad-bg);
  border-color: var(--bad-border);
  color: var(--bad-text);
}

/* Pico pontual justificado (não-falha): âmbar, distinto do vermelho de falha. */
.pill.warn {
  background: #fff3e0;
  border-color: #e0a36b;
  color: #b45309;
}

.pill.green {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-text);
}

.pill.red {
  background: var(--bad-bg);
  border-color: var(--bad-border);
  color: var(--bad-text);
}

.pill.amber {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

/* MESSAGES */
.msg {
  padding: 10px 14px;
  border-radius: 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  margin-bottom: 14px;
  font-size: 14px;
}

.msg.err,
.msg.error {
  background: var(--bad-bg);
  border-color: var(--bad-border);
  color: var(--bad-text);
}

.msg.success {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-text);
}

/* TABLE */
table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

/* Células com texto longo — truncar em mobile */
.table-wrap td.cell-truncate {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

tbody tr:hover {
  background: #f8fafc;
}

tr.row-clickable {
  cursor: pointer;
}

tr.row-clickable:hover {
  background: #f1f5f9;
}

tr.row-clickable:focus-visible {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: -2px;
}

.right {
  text-align: right;
}

/* FORMS */
input,
select,
textarea {
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #111827;
  outline-offset: 1px;
}

textarea {
  line-height: 1.45;
  min-height: 88px;
  resize: vertical;
}

.input {
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  width: 100%;
  display: block;
}

.input.input-readonly,
.input[readonly] {
  background: #f1f5f9;
  color: #64748b;
  border-color: #e2e8f0;
  cursor: default;
  pointer-events: none;
}

label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  display: block;
  margin-bottom: 5px;
}

.field {
  min-width: 160px;
}

.status-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.status-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.status-switch-track {
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: #cbd5e1;
  border: 1px solid #94a3b8;
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.status-switch-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  transition: transform 0.18s ease;
}

.status-switch input[type="checkbox"]:checked + .status-switch-track {
  background: #16a34a;
  border-color: #15803d;
}

.status-switch input[type="checkbox"]:checked + .status-switch-track .status-switch-thumb {
  transform: translateX(22px);
}

.status-switch-text {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

html[data-theme="dark"] .status-switch-text {
  color: #e2e8f0;
}

html[data-theme="dark"] .status-switch-track {
  background: #475569;
  border-color: #64748b;
}

html[data-theme="dark"] .status-switch input[type="checkbox"]:checked + .status-switch-track {
  background: #16a34a;
  border-color: #15803d;
}

.module-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.module-chip-grid--two-cols {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.platform-account-card .module-chip-grid ul,
.platform-account-card .module-chip-grid li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.module-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #dbe4ea;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.module-chip:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.module-chip input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.module-chip-mark {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1.5px solid #94a3b8;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
}

.module-chip-mark::after {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: #0f172a;
  transform: scale(0);
  transition: transform 0.12s ease;
}

.module-chip input[type="checkbox"]:checked + .module-chip-mark {
  border-color: #0f172a;
  background: #e2e8f0;
}

.module-chip input[type="checkbox"]:checked + .module-chip-mark::after {
  transform: scale(1);
}

.module-chip input[type="checkbox"]:checked ~ .module-chip-text {
  color: #0f172a;
  font-weight: 700;
}

/* Chip desactivado via :disabled — estilo visual (ex.: outros formulários) */
.module-chip:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.62;
  background: #f8fafc;
  border-style: dashed;
}
.module-chip:has(input:disabled):hover {
  border-color: #dbe4ea;
  background: #f8fafc;
}
.module-chip:has(input:disabled) .module-chip-text a {
  pointer-events: auto;
  cursor: pointer;
  text-decoration: underline;
}

.module-chip.is-checked {
  border-color: #0f172a;
  background: #f1f5f9;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.module-chip-text {
  font-size: 13px;
  color: #334155;
  line-height: 1.2;
}

.module-chip--full-access {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.module-chip--full-access .module-chip-text {
  font-weight: 700;
}

@media (max-width: 860px) {
  .module-chip-grid--two-cols {
    grid-template-columns: 1fr;
  }
}

/* WhatsApp signup — limitações + consentimento (padrão module-chip, alinhado ao Check) */
.whatsapp-signup-card .whatsapp-limitations {
  margin-top: 10px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
}

.whatsapp-limitations-list {
  margin: 0;
  padding-left: 1.15rem;
  color: #475569;
}

.whatsapp-limitations-list li + li {
  margin-top: 8px;
}

.whatsapp-limitations-list strong {
  color: #0f172a;
  font-weight: 700;
}

.whatsapp-consent-grid {
  margin-top: 14px;
  grid-template-columns: 1fr;
}

.whatsapp-consent-chip {
  width: 100%;
  margin: 0;
  font-weight: 500;
  color: #334155;
}

.whatsapp-consent-chip .module-chip-text {
  font-size: 14px;
  line-height: 1.35;
  font-weight: 600;
  color: #0f172a;
}

.whatsapp-signup-note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: #64748b;
}

.whatsapp-signup-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.btn-whatsapp {
  background: #25d366;
  color: #fff;
  border-color: #25d366;
}

.btn-whatsapp:hover:not(:disabled) {
  background: #1ebe57;
  border-color: #1ebe57;
  color: #fff;
}

.btn-whatsapp:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-whatsapp .wa-icon {
  vertical-align: -2px;
  margin-right: 6px;
}

.ligacao-estado {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ligacao-estado-icon {
  font-size: 18px;
  line-height: 1;
  flex: 0 0 auto;
}

.ligacao-estado-meta {
  font-size: 12px;
}

html[data-theme="dark"] .whatsapp-limitations-list {
  color: #94a3b8;
}

html[data-theme="dark"] .whatsapp-limitations-list strong {
  color: #e2e8f0;
}

html[data-theme="dark"] .whatsapp-consent-chip .module-chip-text {
  color: #e2e8f0;
}

html[data-theme="dark"] .whatsapp-signup-note {
  color: #94a3b8;
}

/* Banner descoberta ESPHome (#156) — boa notícia, não erro */
.sensores-descoberta-banner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sensores-descoberta-linha {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px dashed #38bdf8;
  border-radius: 12px;
  background: #f0f9ff;
  color: #0c4a6e;
}

.sensores-descoberta-texto {
  flex: 1 1 220px;
  font-size: 14px;
  line-height: 1.45;
}

.sensores-descoberta-cta {
  flex: 0 0 auto;
  background: #0284c7;
  border-color: #0284c7;
  color: #fff;
}

.sensores-descoberta-cta:hover {
  background: #0369a1;
  border-color: #0369a1;
  color: #fff;
}

html[data-theme="dark"] .sensores-descoberta-linha {
  border-color: #38bdf8;
  background: rgba(14, 165, 233, 0.12);
  color: #e0f2fe;
}

html[data-theme="dark"] .sensores-descoberta-cta {
  background: #0ea5e9;
  border-color: #0ea5e9;
  color: #0f172a;
}

/* Funcionalidades — sensores IoT */
.func-sensores-settings {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.func-sensores-group {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  padding: 14px 16px;
}

.func-sensores-group-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #475569;
}

.func-sensores-form .field + .field {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}

.func-sensores-form .field-help {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
}

.func-sensores-form .field.is-disabled {
  opacity: 0.5;
}

.func-sensores-form .field.is-disabled .input {
  background: #f1f5f9;
}

.func-sensores-form .form-grid.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.input-unit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 240px;
}

.input-unit-row .input {
  width: 100%;
  max-width: 110px;
  flex: 1 1 auto;
}

.input-unit {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
}

/* Auto-contido (não depende de cor herdada) — mesma lição da hora invisível
   no tema escuro: definir claro e escuro explicitamente aqui. */
.unit-toggle {
  display: inline-flex;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  flex: 0 0 auto;
}

.unit-toggle-btn {
  border: none;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}

.unit-toggle-btn + .unit-toggle-btn {
  border-left: 1px solid #cbd5e1;
}

.unit-toggle-btn.active {
  background: #0f172a;
  color: #f8fafc;
}

html[data-theme="dark"] .unit-toggle {
  border-color: #334155;
}

html[data-theme="dark"] .unit-toggle-btn {
  background: #1e293b;
  color: #cbd5e1;
}

html[data-theme="dark"] .unit-toggle-btn + .unit-toggle-btn {
  border-left-color: #334155;
}

html[data-theme="dark"] .unit-toggle-btn.active {
  background: #f8fafc;
  color: #0f172a;
}

@media (max-width: 640px) {
  .input-unit-row {
    max-width: none;
  }

  .input-unit-row .input {
    max-width: none;
  }
}

.form-help {
  margin-top: 8px;
  font-size: 12px;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #dbe4ea;
  border-radius: 8px;
  padding: 7px 10px;
}

.field-invalid {
  border-color: #ef4444 !important;
  background: #fff1f2 !important;
}

.field-live-badge {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 5px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.field-live-badge.ok {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
}

.field-live-badge.bad {
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fecaca;
}

/* CHECK BUTTON */
.check {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-weight: 900;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.check.on {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-text);
}

.check.off {
  background: #fff;
  color: #d1d5db;
}

.rowline {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.rowline.between {
  justify-content: space-between;
}

.mt-6 {
  margin-top: 6px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-10 {
  margin-top: 10px;
}

.mt-4 {
  margin-top: 4px;
}

.mb-6 {
  margin-bottom: 6px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-10 {
  margin-bottom: 10px;
}

.mb-12 {
  margin-bottom: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

.fs-12 {
  font-size: 12px;
}

.fw-800 {
  font-weight: 800;
}

.kpi-grid-tight {
  gap: 10px;
}

.stack {
  display: flex;
  flex-direction: column;
}

.stack.gap-8 {
  gap: 8px;
}

.task-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}

.text-ok {
  color: #166534;
  font-weight: 700;
}

.text-bad {
  color: #b00020;
  font-weight: 700;
}

.list-compact {
  margin: 6px 0 0 16px;
}

.list-compact li {
  margin: 2px 0;
}

.card-corner-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-corner-icon svg {
  width: 17px;
  height: 17px;
}

.kpi-icon-badge svg {
  width: 17px;
  height: 17px;
}

.kpi-card {
  position: relative;
  overflow: hidden;
  border-top: 4px solid #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.kpi-visual-panel {
  background: #f8fafc;
  border: 1px solid #dbe2ec;
  border-radius: 14px;
  padding: 12px;
}

.kpi-visual-panel--flat {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.kpi-panel-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #64748b;
  margin: 0 0 10px;
}

.kpi-card.kpi-ok {
  border-top-color: #16a34a;
}

.kpi-card.kpi-warn {
  border-top-color: #f59e0b;
}

.kpi-card.kpi-bad {
  border-top-color: #ef4444;
}

.kpi-card.kpi-card--danger {
  border-top-color: #ef4444;
}

.kpi-card.kpi-neutral {
  border-top-color: #cbd5e1;
}

.kpi-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.kpi-card-link:hover {
  color: inherit;
}

.kpi-card-link .kpi-card {
  cursor: pointer;
}

/* Página principal: sombreado consistente por estado (diário/mensal/anual) */
.dashboard-kpi-section .kpi-card.kpi-ok {
  box-shadow: 0 6px 18px rgba(22, 163, 74, 0.12);
}

.dashboard-kpi-section .kpi-card.kpi-warn {
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.14);
}

.dashboard-kpi-section .kpi-card.kpi-bad,
.dashboard-kpi-section .kpi-card.kpi-card--danger {
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.14);
}

.kpi-label {
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-row {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 7px;
}

.kpi-row.kpi-row--donut {
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.kpi-row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.kpi-ring {
  --pct: 0;
  --kpi-ring-start: #60a5fa;
  --kpi-ring-end: #2563eb;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background:
    conic-gradient(
      from -90deg,
      var(--kpi-ring-start) 0deg,
      var(--kpi-ring-end) calc(var(--pct) * 1%),
      #d9e2ec 0deg
    );
  box-shadow:
    inset 0 0 0 1px rgba(148, 163, 184, 0.28),
    0 3px 10px rgba(15, 23, 42, 0.1);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.kpi-ring::before {
  content: "";
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.8);
}

.kpi-ring__text {
  position: absolute;
  font-size: 14px;
  font-weight: 900;
  color: #1e293b;
  line-height: 1;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.kpi-ring.kpi-ring--ok {
  --kpi-ring-start: #2dd4bf;
  --kpi-ring-end: #22c55e;
}

.kpi-ring.kpi-ring--warn {
  --kpi-ring-start: #facc15;
  --kpi-ring-end: #f59e0b;
}

.kpi-ring.kpi-ring--bad {
  --kpi-ring-start: #fb923c;
  --kpi-ring-end: #ef4444;
  background:
    conic-gradient(
      from -90deg,
      var(--kpi-ring-start) 0deg,
      var(--kpi-ring-end) calc(var(--pct) * 1%),
      #fee2e2 0deg
    );
}

.kpi-ring.kpi-ring--neutral {
  --kpi-ring-start: #94a3b8;
  --kpi-ring-end: #94a3b8;
}

.kpi-ring.kpi-ring--neutral .kpi-ring__text {
  color: #64748b;
}

.kpi-card-link:hover .kpi-ring {
  transform: translateY(-1px) scale(1.01);
  box-shadow:
    inset 0 0 0 1px rgba(148, 163, 184, 0.24),
    0 6px 14px rgba(15, 23, 42, 0.13);
}

.kpi-compact-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.kpi-compact-board.kpi-compact-board--triple {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* KPIs de gestão: evitar 4 cartões espremidos em meia janela desktop */
.dashboard-kpi-section .kpi-compact-board.kpi-compact-board--triple {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.kpi-module-card {
  padding: 10px;
  border: 1px solid var(--line);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.05);
  background: var(--card);
}

.kpi-module-card__title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 6px;
  opacity: 0.85;
}

.kpi-module-card__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.kpi-period-tile {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: var(--card);
}

.kpi-period-tile:hover {
  border-color: color-mix(in srgb, var(--line) 70%, #64748b);
  background: var(--soft);
}

.kpi-period-tile .kpi-detail {
  min-height: 0;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
}

.kpi-period-tile__kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 6px;
}

.kpi-period-tile--ok {
  border-top: 3px solid #16a34a;
}

.kpi-period-tile--warn {
  border-top: 3px solid #f59e0b;
}

.kpi-period-tile--bad {
  border-top: 3px solid #ef4444;
}

.kpi-period-tile--neutral {
  border-top: 3px solid #cbd5e1;
}

/* KPIs do dashboard: stack de registo e secção de gestão com o mesmo tamanho compacto */
.dashboard-kpi-stack .kpi-compact-board,
.dashboard-kpi-section .kpi-compact-board {
  gap: 8px;
}
.dashboard-kpi-stack .kpi-module-card,
.dashboard-kpi-section .kpi-module-card {
  padding: 7px 8px;
}
.dashboard-kpi-stack .kpi-module-card__title,
.dashboard-kpi-section .kpi-module-card__title {
  margin-bottom: 4px;
  font-size: 10px;
  letter-spacing: 0.06em;
}
.dashboard-kpi-stack .kpi-module-card__grid,
.dashboard-kpi-section .kpi-module-card__grid {
  gap: 5px;
}
.dashboard-kpi-stack .kpi-period-tile,
.dashboard-kpi-section .kpi-period-tile {
  padding: 6px 7px;
  border-radius: 8px;
}
.dashboard-kpi-stack .kpi-period-tile__kicker,
.dashboard-kpi-section .kpi-period-tile__kicker {
  margin-bottom: 3px;
  font-size: 9px;
}
.dashboard-kpi-stack .kpi-period-tile .kpi-detail,
.dashboard-kpi-section .kpi-period-tile .kpi-detail {
  margin-top: 4px;
  font-size: 10px;
}
.dashboard-kpi-stack .kpi-row.kpi-row--donut,
.dashboard-kpi-section .kpi-row.kpi-row--donut {
  gap: 8px;
  margin-top: 0;
}
.dashboard-kpi-stack .kpi-ring,
.dashboard-kpi-section .kpi-ring {
  width: 70px;
  height: 70px;
}
.dashboard-kpi-stack .kpi-ring::before,
.dashboard-kpi-section .kpi-ring::before {
  width: 50px;
  height: 50px;
}
.dashboard-kpi-stack .kpi-ring__text,
.dashboard-kpi-section .kpi-ring__text {
  font-size: 12px;
}

/* Congelação (peixe / produto): mini-KPIs com a mesma “pegada” visual das tiles de registo no dashboard */
.congelacao-stage-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.congelacao-stage-kpis__tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 7px;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.05);
}

.congelacao-stage-kpis__tile--accent-blue {
  border-top: 3px solid #3b82f6;
}

.congelacao-stage-kpis__tile--accent-green {
  border-top: 3px solid #10b981;
}

.congelacao-stage-kpis__tile--accent-amber {
  border-top: 3px solid #f59e0b;
}

.congelacao-stage-kpis__tile--accent-neutral {
  border-top: 3px solid #e5e7eb;
}

.congelacao-stage-kpis__tile--accent-red {
  border-top: 3px solid #ef4444;
}

.congelacao-stage-kpis__value {
  font-size: 18px;
  font-weight: 900;
  line-height: 1.15;
}

.congelacao-stage-kpis__label {
  margin-top: 3px;
  font-size: 10px;
  line-height: 1.25;
  color: #64748b;
}

/* Ranking de equipa (MTD) */
.team-motivation-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 12px;
}

.team-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 10px;
}

.team-panel-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #334155;
  margin-bottom: 8px;
}

.team-bars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.team-bar-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 8px 8px 10px;
}

.team-bar-plot {
  height: 150px;
  border: 1px solid #dbe2ec;
  border-radius: 10px;
  background:
    linear-gradient(to top, rgba(148, 163, 184, 0.18) 1px, transparent 1px) 0 0 / 100% 25%,
    #f8fafc;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 8px;
}

.team-bar-fill {
  width: 54px;
  min-height: 8px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.team-bar-fill.team-bar-fill--1 {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.team-bar-fill.team-bar-fill--2 {
  background: linear-gradient(180deg, #06b6d4 0%, #0891b2 100%);
  box-shadow: 0 4px 10px rgba(8, 145, 178, 0.25);
}

.team-bar-fill.team-bar-fill--3 {
  background: linear-gradient(180deg, #8b5cf6 0%, #7c3aed 100%);
  box-shadow: 0 4px 10px rgba(124, 58, 237, 0.24);
}

.team-bar-value {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 900;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #dbe2ec;
  border-radius: 999px;
  padding: 1px 8px;
}

.team-bar-name {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-bar-meta {
  margin-top: 2px;
  font-size: 11px;
  color: #64748b;
}

.mission-week-card {
  --mission-pct: 0;
  --mission-hue: calc(var(--mission-pct) * 1.1);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  padding: 10px;
}

.mission-week-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.mission-week-pct {
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  color: hsl(var(--mission-hue) 72% 28%);
}

.mission-week-frac {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
}

.mission-week-road {
  position: relative;
  margin-top: 8px;
  padding-right: 0;
}

.mission-week-road__base {
  height: 12px;
  border-radius: 999px;
  background:
    repeating-linear-gradient(
      135deg,
      #dbe2ec 0 8px,
      #cfd8e3 8px 16px
    );
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.mission-week-road__fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    hsl(var(--mission-hue) 74% 44%) 0%,
    hsl(var(--mission-hue) 68% 30%) 100%
  );
}

.mission-week-road__marker {
  position: absolute;
  top: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #f8fafc;
  background: radial-gradient(
    circle at 32% 30%,
    #fff 0%,
    hsl(var(--mission-hue) 72% 62%) 42%,
    hsl(var(--mission-hue) 68% 34%) 100%
  );
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.14), 0 4px 10px rgba(15, 23, 42, 0.2);
}

.mission-week-road__marker::after {
  content: "📋";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -58%);
  font-size: 11px;
  line-height: 1;
}

.mission-week-road__checkpoints {
  position: absolute;
  left: 0;
  right: 0;
  top: -4px;
  height: 20px;
  pointer-events: none;
}

.mission-week-road__checkpoint {
  position: absolute;
  top: 0;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
}

.mission-week-road__checkpoint.done {
  background: hsl(var(--mission-hue) 66% 40%);
  border-color: hsl(var(--mission-hue) 62% 32%);
  box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.12);
}

.mission-week-road__legend {
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  padding: 0 2px;
  font-size: 9px;
  font-weight: 800;
  color: #64748b;
}

.mission-week-levels {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
}

.mission-week-level {
  position: relative;
  border-radius: 8px;
  border: 1px solid #dbe2ec;
  background: #f8fafc;
  min-height: 30px;
  padding: 4px 4px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  opacity: 0.7;
  transform: translateY(0);
}

.mission-week-level:nth-child(1) { min-height: 30px; }
.mission-week-level:nth-child(2) { min-height: 38px; }
.mission-week-level:nth-child(3) { min-height: 46px; }
.mission-week-level:nth-child(4) { min-height: 54px; }

.mission-week-level__emoji {
  font-size: 13px;
  line-height: 1;
}

.mission-week-level__label {
  margin-top: 2px;
  font-size: 9px;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0.02em;
}

.mission-week-level.done {
  opacity: 1;
  border-color: #cbd5e1;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.mission-week-level.done .mission-week-level__emoji {
  opacity: 0.8;
}

.mission-week-level.current {
  opacity: 1;
  transform: translateY(-2px);
  border-color: hsl(var(--mission-hue) 62% 40%);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
  background: linear-gradient(180deg, #ffffff 0%, #eef2ff 100%);
}

.mission-week-level.current::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: hsl(var(--mission-hue) 64% 38%);
  box-shadow: 0 0 0 2px #ffffff;
}

.mission-week-level-note {
  margin-top: 7px;
  font-size: 11px;
  font-weight: 800;
  color: #1e293b;
}

.mission-week-text {
  margin-top: 8px;
  font-size: 12px;
  color: #334155;
  font-weight: 600;
}

.mission-week-card--neutral .mission-week-pct {
  color: #64748b;
}

@media (max-width: 1100px) {
  .dashboard-head-grid,
  .dashboard-top-bento {
    grid-template-columns: 1fr;
  }

  .kpi-compact-board {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  /* KPIs de registo (MTD): evitar layout 3+1 em meia janela desktop */
  .dashboard-kpi-stack .kpi-compact-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-compact-board.kpi-compact-board--triple {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .dashboard-kpi-section .kpi-compact-board.kpi-compact-board--triple {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .team-bars-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .team-motivation-grid {
    grid-template-columns: 1fr;
  }
}

.kpi-value {
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -1.1px;
  color: #0f172a;
}

.kpi-value.kpi-value-ok {
  color: #15803d;
}

.kpi-value.kpi-value-warn {
  color: #b45309;
}

.kpi-value.kpi-value-bad {
  color: #b91c1c;
}

.kpi-value.kpi-value-neutral {
  color: #64748b;
}

/* Gestão (Manutenção / Formação / Documental): KPIs padronizados */
.manutencao-kpis {
  align-items: stretch;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  margin-bottom: 16px;
}

.manutencao-kpis .kpi-card {
  flex: 1 1 136px;
  min-height: 67px;
  padding: 8px 8px;
  border: 1px solid #dbe5f5;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.045);
}

.manutencao-kpis .kpi-value {
  font-size: 24px;
  letter-spacing: -0.35px;
}

.manutencao-kpis .kpi-label {
  font-size: 10px;
  letter-spacing: 0.14px;
  margin-top: 3px;
}

.documental-kpis,
.formacao-kpis {
  margin-top: 14px;
  margin-bottom: 16px;
}

.formacao-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(4, minmax(130px, 1fr)) auto auto;
  align-items: end;
  gap: 10px;
}

.formacao-filter-field {
  min-width: 0;
}

.formacao-filter-field .input {
  width: 100%;
  min-width: 0;
}

.formacao-filter-actions {
  display: flex;
  align-items: flex-end;
  min-height: 0;
}

.formacao-filter-actions .btn {
  white-space: nowrap;
}

@media (max-width: 1280px) {
  .formacao-filters {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .formacao-filters {
    grid-template-columns: repeat(2, 1fr);
  }
}

.formacao-table td strong {
  color: #0f172a;
}

.formacao-saldo {
  font-weight: 600;
}

.formacao-saldo--devedor {
  color: #dc2626;
}

.formacao-saldo--credito {
  color: #15803d;
}

.formacao-saldo--neutro {
  color: #64748b;
}

.formacao-breadcrumb {
  margin-bottom: 1rem;
}

.formacao-section-title {
  margin: 1.5rem 0 .75rem;
}

.formacao-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}

.formacao-list-header .section-title {
  margin: 0;
}

.formacao-pill-atual {
  margin-left: 6px;
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

.formacao-registo-card {
  max-width: 780px;
}

.formacao-registo-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.formacao-registo-form .form-group {
  margin: 0;
}

.formacao-registo-form .form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.formacao-registo-form input[type="file"] {
  width: 100%;
  border: 1px solid #dbe2ec;
  border-radius: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  color: #334155;
}

.formacao-registo-form input[type="file"]::file-selector-button {
  appearance: none;
  border: 1px solid #cbd5e1;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  color: #0f172a;
  font-weight: 700;
  font-size: 12px;
  border-radius: 9px;
  padding: 7px 12px;
  margin-right: 10px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.08s ease;
}

.formacao-registo-form input[type="file"]:hover::file-selector-button {
  background: linear-gradient(180deg, #ffffff 0%, #e2e8f0 100%);
  border-color: #94a3b8;
}

.formacao-registo-form input[type="file"]:focus-visible::file-selector-button {
  border-color: #1d4ed8;
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.16);
}

/* Pesquisa global: regras próprias para manter responsivo após resultados */
.pesquisa-global-page .pesquisa-search-card {
  padding: 16px 20px;
}

.pesquisa-global-page .pesquisa-field-main {
  min-width: 280px;
  flex: 1;
}

@media (max-width: 1024px) {
  .pesquisa-global-page .filter-form-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .pesquisa-global-page .pesquisa-field-main {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 768px) {
  .pesquisa-global-page .pesquisa-search-card {
    padding: 12px;
  }

  .pesquisa-global-page .filter-form-fields .btn {
    width: 100%;
    justify-content: center;
  }

  /* Anula min-width global de mobile-compact para esta página */
  .pesquisa-global-page .table-wrap table,
  .pesquisa-global-page.mobile-compact .table-wrap table {
    min-width: 0 !important;
    table-layout: fixed;
  }

  .pesquisa-global-page .table-wrap th,
  .pesquisa-global-page .table-wrap td {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .pesquisa-global-page .table-wrap td.right {
    text-align: left;
  }

  .pesquisa-global-page .table-wrap td.right a.btn,
  .pesquisa-global-page .table-wrap td.right .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Temperaturas: evitar scroll horizontal (desktop, tablet e mobile) */
.mobile-compact.temperaturas-page {
  overflow-x: hidden;
  max-width: 100%;
}

.mobile-compact.temperaturas-page .module-header-left,
.mobile-compact.temperaturas-page .module-header-left > div,
.mobile-compact.temperaturas-page .subtle-note {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.temperaturas-page .temps-pending-lote .table-wrap,
.temperaturas-page .table-wrap.compact {
  overflow-x: visible;
  max-width: 100%;
}

.temperaturas-page .temps-pending-lote .table-wrap table,
.temperaturas-page .table-wrap.compact table,
.registos-rapidos-form-card .temps-rapido-table table {
  min-width: 0 !important;
  width: 100%;
  table-layout: fixed;
}

.temperaturas-page .temps-pending-lote .quick-table th,
.temperaturas-page .temps-pending-lote .quick-table td,
.registos-rapidos-form-card .temps-rapido-table th,
.registos-rapidos-form-card .temps-rapido-table td {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  vertical-align: middle;
}

.temperaturas-page .temps-pending-lote .quick-table .col-eq,
.registos-rapidos-form-card .temps-rapido-table .col-eq {
  width: 34%;
}

.temperaturas-page .temps-pending-lote .quick-table .col-turno,
.registos-rapidos-form-card .temps-rapido-table .col-turno {
  width: 14%;
}

.temperaturas-page .temps-pending-lote .quick-table .col-limite,
.registos-rapidos-form-card .temps-rapido-table .col-limite {
  width: 26%;
}

.temperaturas-page .temps-pending-lote .quick-table .col-temp,
.registos-rapidos-form-card .temps-rapido-table .col-temp {
  width: 26%;
}

.temperaturas-page .temps-pending-lote .temp-field,
.registos-rapidos-form-card .temps-rapido-table .temp-field {
  max-width: 100%;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.temperaturas-page .temps-card-head {
  margin-bottom: 8px;
}

.temperaturas-page .temps-card-title {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.temperaturas-page .temps-card-title .pill {
  padding: 2px 8px;
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: middle;
}

.temperaturas-page .temps-pending-summary {
  font-size: 13px;
}

.temperaturas-page .temps-turno-header td {
  padding: 11px 12px 9px;
  border-bottom: 1px solid #cbd5e1;
}

.temperaturas-page .temps-turno-header--almoco td {
  background: linear-gradient(90deg, #fff7ed 0%, #ffedd5 100%);
  border-left: 4px solid #f97316;
}

.temperaturas-page .temps-turno-header--jantar td {
  background: linear-gradient(90deg, #eef2ff 0%, #e0e7ff 100%);
  border-left: 4px solid #6366f1;
}

.temperaturas-page .temps-turno-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #0f172a;
}

.temperaturas-page .temps-turno-header--almoco .temps-turno-label::before {
  content: "☀";
  font-size: 15px;
}

.temperaturas-page .temps-turno-header--jantar .temps-turno-label::before {
  content: "☾";
  font-size: 15px;
}

.temperaturas-page .temps-turno-meta {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
}

.temperaturas-page .temps-turno-guardar td {
  padding: 12px 12px 18px;
  border-bottom: none;
  background: transparent;
}

.temperaturas-page .temps-turno-guardar--almoco td {
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 20px;
}

.temperaturas-page tbody tr.temps-turno-header + tr td {
  padding-top: 10px;
}

.temperaturas-page .temps-turno-table .col-zona {
  width: 14%;
  font-size: 13px;
}

.temperaturas-page .temps-ultimo-flag {
  margin-left: 4px;
  font-size: 10px;
  padding: 1px 6px;
  vertical-align: middle;
}

.temperaturas-page .temps-turno-table .col-eq {
  width: 28%;
}

.temperaturas-page .temps-turno-table .col-limite {
  width: 18%;
}

.temperaturas-page .temps-turno-table .col-ultimo {
  width: 28%;
}

.temperaturas-page .temps-turno-table .col-temp {
  width: 12%;
}

.temperaturas-page .temps-turno-table .temp-field {
  width: 72px;
  max-width: 100%;
  min-width: 0;
  display: inline-block;
}

html[data-theme="dark"] .temperaturas-page .temps-turno-header--almoco td {
  background: linear-gradient(90deg, #431407 0%, #7c2d12 100%);
  border-left-color: #fb923c;
  border-bottom-color: #334155;
}

html[data-theme="dark"] .temperaturas-page .temps-turno-header--jantar td {
  background: linear-gradient(90deg, #1e1b4b 0%, #312e81 100%);
  border-left-color: #818cf8;
  border-bottom-color: #334155;
}

html[data-theme="dark"] .temperaturas-page .temps-turno-label {
  color: #f8fafc;
}

html[data-theme="dark"] .temperaturas-page .temps-turno-meta {
  color: #cbd5e1;
}

.temperaturas-page .temps-dashboard-side .card {
  flex: 1 1 280px;
  max-width: 100%;
  min-width: 0;
}

@media (max-width: 1024px) {
  .temperaturas-page .row.temps-dashboard-side {
    flex-direction: column;
  }

  .temperaturas-page .temps-dashboard-side .card {
    flex: 1 1 100%;
  }
}

@media (max-width: 768px) {
  .temperaturas-page .temps-pending-lote .table-wrap table,
  .temperaturas-page .table-wrap.compact table,
  .registos-rapidos-form-card .temps-rapido-table table {
    table-layout: auto;
  }

  .temperaturas-page .temps-pending-lote .quick-table .col-eq,
  .temperaturas-page .temps-pending-lote .quick-table .col-turno,
  .temperaturas-page .temps-pending-lote .quick-table .col-zona,
  .temperaturas-page .temps-pending-lote .quick-table .col-limite,
  .temperaturas-page .temps-pending-lote .quick-table .col-ultimo,
  .temperaturas-page .temps-pending-lote .quick-table .col-temp,
  .registos-rapidos-form-card .temps-rapido-table .col-eq,
  .registos-rapidos-form-card .temps-rapido-table .col-turno,
  .registos-rapidos-form-card .temps-rapido-table .col-limite,
  .registos-rapidos-form-card .temps-rapido-table .col-temp {
    width: auto;
  }

  .temperaturas-page .table-wrap-mobile:not(.equipa-table-wrap) td.text-right,
  .registos-rapidos-form-card .table-wrap-mobile:not(.equipa-table-wrap) td.text-right {
    text-align: left;
  }

  .temperaturas-page .table-wrap-mobile:not(.equipa-table-wrap) td.text-right .temp-field,
  .registos-rapidos-form-card .table-wrap-mobile:not(.equipa-table-wrap) td.text-right .field-compact {
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 430px) {
  .temperaturas-page .table-wrap table,
  .temperaturas-page.mobile-compact .table-wrap table,
  .registos-rapidos-form-card .table-wrap table,
  .registos-rapidos-form-card.mobile-compact .table-wrap table {
    min-width: 0 !important;
  }
}

/* Óleo: evitar scroll horizontal (desktop, tablet e mobile) */
.mobile-compact.oleo-page {
  overflow-x: hidden;
  max-width: 100%;
}

.mobile-compact.oleo-page .module-header-left,
.mobile-compact.oleo-page .module-header-left > div,
.mobile-compact.oleo-page .subtle-note {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.oleo-page .oleo-pending-lote .table-wrap,
.oleo-page .table-wrap.compact {
  overflow-x: visible;
  max-width: 100%;
}

.oleo-page .oleo-pending-lote .table-wrap table,
.oleo-page .table-wrap.compact table,
.registos-rapidos-form-card .oleo-rapido-table table {
  min-width: 0 !important;
  width: 100%;
  table-layout: fixed;
}

.oleo-page .oleo-pending-lote .quick-table th,
.oleo-page .oleo-pending-lote .quick-table td,
.registos-rapidos-form-card .oleo-rapido-table th,
.registos-rapidos-form-card .oleo-rapido-table td {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  vertical-align: middle;
}

.oleo-page .oleo-pending-lote .quick-table .col-frit,
.registos-rapidos-form-card .oleo-rapido-table .col-frit {
  width: 34%;
}

.oleo-page .oleo-pending-lote .quick-table .col-temp-oil,
.registos-rapidos-form-card .oleo-rapido-table .col-temp-oil {
  width: 22%;
}

.oleo-page .oleo-pending-lote .quick-table .col-tpm,
.registos-rapidos-form-card .oleo-rapido-table .col-tpm {
  width: 18%;
}

.registos-rapidos-form-card .oleo-rapido-table .col-check {
  width: 8%;
}

.oleo-page .oleo-pending-lote .oil-temp-field,
.oleo-page .oleo-pending-lote .oil-tpm-field,
.registos-rapidos-form-card .oleo-rapido-table .oil-temp-field,
.registos-rapidos-form-card .oleo-rapido-table .oil-tpm-field {
  max-width: 100%;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.oleo-page .oleo-dashboard-side .card {
  flex: 1 1 280px;
  max-width: 100%;
  min-width: 0;
}

@media (max-width: 1024px) {
  .oleo-page .row.oleo-dashboard-side {
    flex-direction: column;
  }

  .oleo-page .oleo-dashboard-side .card {
    flex: 1 1 100%;
  }
}

@media (max-width: 768px) {
  .oleo-page .oleo-pending-lote .table-wrap table,
  .oleo-page .table-wrap.compact table,
  .registos-rapidos-form-card .oleo-rapido-table table {
    table-layout: auto;
  }

  .oleo-page .oleo-pending-lote .quick-table .col-frit,
  .oleo-page .oleo-pending-lote .quick-table .col-temp-oil,
  .oleo-page .oleo-pending-lote .quick-table .col-tpm,
  .registos-rapidos-form-card .oleo-rapido-table .col-frit,
  .registos-rapidos-form-card .oleo-rapido-table .col-temp-oil,
  .registos-rapidos-form-card .oleo-rapido-table .col-tpm,
  .registos-rapidos-form-card .oleo-rapido-table .col-check {
    width: auto;
  }

  .oleo-page .table-wrap-mobile:not(.equipa-table-wrap) td.text-right,
  .registos-rapidos-form-card .table-wrap-mobile:not(.equipa-table-wrap) td.text-right {
    text-align: left;
  }

  .oleo-page .table-wrap-mobile:not(.equipa-table-wrap) td.text-right .oil-temp-field,
  .oleo-page .table-wrap-mobile:not(.equipa-table-wrap) td.text-right .field-compact,
  .registos-rapidos-form-card .table-wrap-mobile:not(.equipa-table-wrap) td.text-right .field-compact {
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 430px) {
  .oleo-page .table-wrap table,
  .oleo-page.mobile-compact .table-wrap table {
    min-width: 0 !important;
  }
}

/* Higienização: evitar scroll horizontal (desktop, tablet e mobile) */
.mobile-compact.limpezas-page {
  overflow-x: hidden;
  max-width: 100%;
}

.mobile-compact.limpezas-page .module-header-left,
.mobile-compact.limpezas-page .module-header-left > div,
.mobile-compact.limpezas-page .subtle-note {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.limpezas-page .limp-pending-lote .table-wrap,
.limpezas-page .table-wrap.compact {
  overflow-x: visible;
  max-width: 100%;
}

.limpezas-page .limp-pending-lote .table-wrap table,
.limpezas-page .table-wrap.compact table,
.registos-rapidos-form-card .higien-rapido-table table {
  min-width: 0 !important;
  width: 100%;
  table-layout: fixed;
}

.limpezas-page .limp-pending-lote .quick-table th,
.limpezas-page .limp-pending-lote .quick-table td,
.registos-rapidos-form-card .higien-rapido-table th,
.registos-rapidos-form-card .higien-rapido-table td {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  vertical-align: middle;
}

.limpezas-page .limp-pending-lote .quick-table .col-check,
.registos-rapidos-form-card .higien-rapido-table .col-check {
  width: 52px;
}

.limpezas-page .limp-pending-lote .quick-table .col-zona,
.registos-rapidos-form-card .higien-rapido-table .col-zona {
  width: 18%;
}

.limpezas-page .limp-pending-lote .quick-table .col-tarefa,
.registos-rapidos-form-card .higien-rapido-table .col-tarefa {
  width: 32%;
}

.limpezas-page .limp-pending-lote .quick-table .col-obs,
.registos-rapidos-form-card .higien-rapido-table .col-obs {
  width: 38%;
}

.limpezas-page .limp-pending-lote .field-compact,
.registos-rapidos-form-card .higien-rapido-table .field-compact {
  max-width: 100%;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.limpezas-page .higien-select-all-bar {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 12px;
  padding: 12px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
}

.limpezas-page .higien-select-all-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  width: 100%;
  margin: 0;
  min-height: 44px;
  font-size: 15px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}

.limpezas-page .higien-select-all-label .table-check-input {
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  background-size: 16px 16px;
}

.limpezas-page .higien-select-all-text {
  flex: 1;
  min-width: 0;
}

html[data-theme="dark"] .limpezas-page .higien-select-all-bar {
  background: #052e16;
  border-color: #166534;
}

html[data-theme="dark"] .limpezas-page .higien-select-all-text .muted {
  color: #86efac;
}

.limpezas-page .limp-zona-header td,
.quick-table tbody tr.limp-zona-header td {
  padding: 11px 12px 9px;
  border-bottom: 1px solid #cbd5e1;
  background: #f8fafc;
  font-weight: 600;
}

html[data-theme="dark"] .limpezas-page .limp-zona-header td,
html[data-theme="dark"] .quick-table tbody tr.limp-zona-header td {
  background: #1e293b;
  border-bottom-color: #334155;
  color: #f8fafc;
}

.limpezas-page .limp-zona-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.limpezas-page .higien-zona-select-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #1e40af;
  white-space: nowrap;
  min-height: 36px;
  -webkit-tap-highlight-color: transparent;
}

.limpezas-page .higien-zona-select-bar:hover {
  background: #dbeafe;
}

.limpezas-page .higien-zona-select-bar .table-check-input {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
}

html[data-theme="dark"] .limpezas-page .higien-zona-select-bar {
  background: #1e3a5f;
  border-color: #1d4ed8;
  color: #93c5fd;
}

html[data-theme="dark"] .limpezas-page .higien-zona-select-bar:hover {
  background: #1e3a8a;
}

@media (max-width: 768px) {
  .limpezas-page .limp-pending-lote .table-wrap table,
  .limpezas-page .table-wrap.compact table,
  .registos-rapidos-form-card .higien-rapido-table table {
    table-layout: auto;
  }

  .limpezas-page .limp-pending-lote .quick-table .col-check,
  .limpezas-page .limp-pending-lote .quick-table .col-zona,
  .limpezas-page .limp-pending-lote .quick-table .col-tarefa,
  .limpezas-page .limp-pending-lote .quick-table .col-obs,
  .registos-rapidos-form-card .higien-rapido-table .col-check,
  .registos-rapidos-form-card .higien-rapido-table .col-zona,
  .registos-rapidos-form-card .higien-rapido-table .col-tarefa,
  .registos-rapidos-form-card .higien-rapido-table .col-obs {
    width: auto;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) tr.limp-zona-header,
  .table-wrap-mobile:not(.equipa-table-wrap) tr.temps-turno-header {
    border: none;
    padding: 0;
    margin: 12px 0 4px;
    background: transparent;
    box-shadow: none;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) tr.temps-turno-guardar {
    border: none;
    padding: 0;
    margin: 0 0 16px;
    background: transparent;
    box-shadow: none;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) tr.temps-turno-guardar td {
    padding: 8px 0 16px;
    border: none;
    background: transparent;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) tr.temps-turno-guardar td::before {
    display: none;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) tr.limp-zona-header td,
  .table-wrap-mobile:not(.equipa-table-wrap) tr.temps-turno-header td {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) tr.limp-zona-header td::before,
  .table-wrap-mobile:not(.equipa-table-wrap) tr.temps-turno-header td::before {
    display: none;
  }

  html[data-theme="dark"] .table-wrap-mobile:not(.equipa-table-wrap) tr.limp-zona-header td,
  html[data-theme="dark"] .table-wrap-mobile:not(.equipa-table-wrap) tr.temps-turno-header td {
    background: #1e293b;
    border-color: #334155;
    color: #f8fafc;
  }

  .limpezas-page .higien-select-all-bar {
    position: sticky;
    top: 8px;
    z-index: 3;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  }

  .limpezas-page .limp-zona-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .limpezas-page .higien-zona-select-bar {
    width: 100%;
    font-size: 14px;
    padding: 8px 12px;
    min-height: 44px;
    box-sizing: border-box;
  }

  .limpezas-page .limp-pending-lote .table-wrap-mobile tr:not(.limp-zona-header) td.col-check {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
  }

  .limpezas-page .limp-pending-lote .table-wrap-mobile tr:not(.limp-zona-header) td.col-check::before {
    display: block;
    margin-bottom: 0;
    font-size: 12px;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 600;
    color: #15803d;
  }

  .limpezas-page .limp-pending-lote .table-wrap-mobile tr:not(.limp-zona-header) td.col-check .table-check-input {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    background-size: 17px 17px;
  }

  .limpezas-page .limp-pending-lote .table-wrap-mobile tr:has(.table-check-input[name^="feito_"]:checked) {
    border-color: #86efac;
    background: #f0fdf4;
  }

  .limpezas-page .limp-lote-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    margin: 0;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    background: var(--card);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.1);
  }

  .limpezas-page .limp-pending-lote form {
    padding-bottom: 76px;
  }

  .limpezas-page .limp-lote-actions .btn.dark {
    width: 100%;
    min-height: 44px;
    font-size: 15px;
  }
}

@media (max-width: 430px) {
  .limpezas-page .table-wrap table,
  .limpezas-page.mobile-compact .table-wrap table,
  .registos-rapidos-form-card .higien-rapido-table table {
    min-width: 0 !important;
  }
}

.formacao-registo-form input[type="file"]:active::file-selector-button {
  transform: translateY(1px);
}

/* Fallback para motores antigos */
.formacao-registo-form input[type="file"]::-webkit-file-upload-button {
  appearance: none;
  border: 1px solid #cbd5e1;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  color: #0f172a;
  font-weight: 700;
  font-size: 12px;
  border-radius: 9px;
  padding: 7px 12px;
  margin-right: 10px;
  cursor: pointer;
}

.formacao-registo-form textarea {
  min-height: 118px;
}

.equipa-form-card {
  max-width: 620px;
}

.equipa-form-header {
  flex-wrap: nowrap;
  align-items: center;
  max-width: 620px;
}

.equipa-form-divider {
  margin: 20px 0 16px;
  border-top: 1px solid var(--line);
}

.equipa-form-section-title {
  margin-bottom: 12px;
}

.equipa-form-help {
  font-size: 12px;
  margin-top: 4px;
}

.equipa-danger-card {
  border-left: 3px solid var(--color-danger);
}

.equipa-danger-title {
  margin-bottom: 8px;
}

.equipa-danger-text {
  font-size: 13px;
  margin-bottom: 12px;
}

@media (max-width: 900px) {
  .equipa-form-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }
}

@media (max-width: 768px) {
  /* Em mobile, MTD deve seguir o mesmo empilhamento estável dos KPIs de gestão */
  .dashboard-kpi-stack .kpi-compact-board,
  .dashboard-kpi-section .kpi-compact-board {
    grid-template-columns: 1fr;
  }

  .manutencao-kpis .kpi-card {
    flex: 1 1 calc(50% - 6px);
    min-height: 59px;
  }

  .manutencao-kpis .kpi-value {
    font-size: 20px;
  }

  .manutencao-kpis .kpi-label {
    font-size: 9px;
  }

  .formacao-filters {
    gap: 8px;
    grid-template-columns: 1fr;
  }

  .formacao-filter-field {
    min-width: 0;
    width: 100%;
  }

  .formacao-filter-field .input {
    width: 100%;
    min-width: 0;
  }

  .formacao-filter-actions {
    min-height: 0;
    width: 100%;
  }

  .formacao-filter-actions .btn {
    width: 100%;
  }

  .formacao-list-header {
    gap: 8px;
    flex-wrap: wrap;
  }

  .formacao-registo-form .form-grid-2 {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

.kpi-detail {
  margin-top: 7px;
  font-size: 12px;
  color: #475569;
  font-weight: 500;
  min-height: 40px;
}

.fill.fill-ok {
  background: #16a34a;
}

.fill.fill-warn {
  background: #f59e0b;
}

.fill.fill-bad {
  background: #ef4444;
}

.fill.fill-neutral {
  background: #cbd5e1;
}

.alert-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 16px;
}

.alert-critical {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 16px;
}

.alert-panel-kicker {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 10px;
}

.alert-panel-shell {
  background: #fff5f5;
  border: 2px solid #ef4444;
  border-radius: 14px;
  padding: 10px 12px;
}

/* Pilha: painel crítico (vermelho) + painéis informativos (cinza) — nunca misturar no mesmo .alert-panel-shell */
.dashboard-alerts-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-alerts-stack > .alert-panel {
  margin-bottom: 0;
}

/* Grelha 2×2: alertas | IA na 1.ª linha; registos rápidos | inspeção na 2.ª — mesmas colunas que .dashboard-head-grid. */
.dashboard-top-bento {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

/* Sem margem extra sob os alertas dentro do bento (o gap da grelha separa as linhas). */
.dashboard-top-bento .dashboard-alerts-stack--in-bento {
  margin-bottom: 0;
}

.dashboard-top-bento > .dashboard-alerts-stack,
.dashboard-top-bento > .dashboard-ia-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Não forçar flex 1 + min-height:0 no interior (evita transbordo sobre a linha seguinte). */
.dashboard-top-bento .alert-panel,
.dashboard-top-bento .dashboard-ia-panel-card {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.dashboard-top-bento details.alert-panel-drilldown {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
}

.dashboard-top-bento details.alert-panel-drilldown > .alert-panel-shell,
.dashboard-top-bento details.alert-panel-drilldown > .dashboard-ia-shell {
  flex: 0 1 auto;
}

.dashboard-top-bento details.alert-panel-drilldown > .alert-panel-shell {
  display: flex;
  flex-direction: column;
}

.dashboard-top-bento details.alert-panel-drilldown > .dashboard-ia-shell {
  display: flex;
  flex-direction: column;
}

.dashboard-top-bento .dashboard-ia-list {
  display: flex;
  flex-direction: column;
}

/* Barra do <summary> (cartão «fechado» / cabeçalho) com altura mínima alinhada entre as duas colunas. */
.dashboard-top-bento .alert-panel-drilldown > summary,
.dashboard-top-bento .dashboard-ia-summary {
  min-height: 44px;
}

.dashboard-ia-panel-card {
  border-color: rgba(59, 130, 246, 0.45);
  background: linear-gradient(145deg, rgba(239, 246, 255, 0.95), rgba(248, 250, 252, 0.98));
}

.dashboard-ia-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  padding: 4px 0;
}

.dashboard-ia-summary::-webkit-details-marker {
  display: none;
}

.dashboard-ia-summary-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.dashboard-ia-mascot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  color: #1d4ed8;
}

.dashboard-ia-mascot-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.dashboard-ia-heading {
  font-size: 1.25rem;
  font-weight: 900;
  color: #1e3a5f;
  letter-spacing: -0.02em;
}

.dashboard-ia-shell {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(59, 130, 246, 0.2);
}

.dashboard-ia-lead {
  font-size: 0.92rem;
  margin-bottom: 12px;
}

.dashboard-ia-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dashboard-ia-item {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: 12px;
  padding: 12px 14px;
}

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

.dashboard-ia-titulo {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0 0 8px;
  color: #0f172a;
  line-height: 1.35;
}

.dashboard-ia-desc {
  font-size: 0.95rem;
  line-height: 1.45;
  color: #334155;
}

/* Alerta de variação de preços — % compactas (subida / descida), tom sóbrio */
.dashboard-ia-desc--precos {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.dashboard-ia-desc--precos .var-preco-produto {
  margin-top: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  color: #0f172a;
}
.dashboard-ia-desc--precos .var-preco-produto:first-child {
  margin-top: 2px;
}
.dashboard-ia-desc--precos .var-preco-actual {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
}
.dashboard-ia-desc--precos .var-preco-comp {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  color: #64748b;
  font-size: 0.84rem;
  line-height: 1.35;
}
.var-preco {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.84em;
  line-height: 1.25;
  white-space: nowrap;
  letter-spacing: 0;
}
.var-preco__seta {
  font-size: 0.85em;
  line-height: 1;
  opacity: 0.9;
}
.var-preco--up {
  color: #b91c1c;
  background: rgba(254, 226, 226, 0.7);
}
.var-preco--down {
  color: #15803d;
  background: rgba(220, 252, 231, 0.7);
}
html[data-theme="dark"] .dashboard-ia-desc--precos .var-preco-produto,
html[data-theme="dark"] .dashboard-ia-desc--precos .var-preco-actual {
  color: #e2e8f0;
}
html[data-theme="dark"] .dashboard-ia-desc--precos .var-preco-comp {
  color: #94a3b8;
}
html[data-theme="dark"] .var-preco--up {
  color: #fca5a5;
  background: rgba(127, 29, 29, 0.28);
}
html[data-theme="dark"] .var-preco--down {
  color: #86efac;
  background: rgba(20, 83, 45, 0.28);
}

.dashboard-ia-actions {
  margin-top: 12px;
}

.dashboard-ia-empty {
  margin: 0;
  padding: 6px 0 4px;
  font-size: 0.95rem;
}

/* ──────────────────────────────────────────────────────────────
   Card IA alinhado 1:1 ao card de Alertas Críticos.
   Mesmo frame (outer box), mesma moldura interior, mesmo cabeçalho
   e mesmas margens — em todos os tamanhos de ecrã (incl. mobile).
   Só muda a cor (azul IA vs vermelho crítico).
   ────────────────────────────────────────────────────────────── */

/* 1) Neutralizar o wrapper extra sem lhe mexer no fluxo: o
      .dashboard-ia-panel continua a ser o flex-item da stack (mantém o
      gap de 16px entre os dois cards) e o .alert-panel interior fica com
      a mesma margem do card crítico.
      NÃO usar display:contents aqui — anula o gap da flexbox nalguns
      browsers e cola os dois cards. */
.dashboard-ia-panel {
  margin: 0;
}

.dashboard-ia-panel-card {
  margin-bottom: 0;
}

/* 2) Moldura interior igual à .alert-panel-shell do card crítico
      (mesmo box-model; só muda a cor para azul). */
.dashboard-ia-shell {
  margin-top: 10px;
  padding: 10px 12px;
  background: #eff6ff;
  border: 2px solid #3b82f6;
  border-radius: 14px;
}

/* 3) Cabeçalho com o mesmo tamanho/altura do título crítico. A mascote
      é escalada para não forçar altura extra nem quebrar linha. */
.dashboard-ia-summary {
  padding: 0;
}

.dashboard-ia-heading {
  font-size: 23px;
}

.dashboard-ia-mascot {
  width: 1.9rem;
  height: 1.9rem;
}

@media (max-width: 768px) {
  .dashboard-ia-heading {
    font-size: 19px;
  }
}

.alert-panel--info {
  border-color: rgba(100, 116, 139, 0.35);
  background: rgba(241, 245, 249, 0.75);
  margin-bottom: 0;
}

.alert-panel-info-inner {
  background: rgba(248, 250, 252, 0.95);
  border: 1px solid rgba(100, 116, 139, 0.35);
  border-radius: 14px;
  padding: 10px 12px;
}

.alert-panel-info-kicker {
  padding: 0 4px 8px;
  font-size: 0.92em;
}

.alert-panel-drilldown--info > .alert-panel-title {
  color: #334155;
}

.pill--info {
  background: rgba(100, 116, 139, 0.2);
  color: #334155;
}

.alert-panel--info .alert-item--info {
  border-top-color: rgba(148, 163, 184, 0.4);
}

.alert-panel--info .alert-item-main {
  color: #334155;
}

.alert-dot--muted {
  background: #64748b;
}

.alert-meta--info {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.alert-panel-title {
  font-size: 23px;
  font-weight: 900;
  color: #b00020;
  margin-bottom: 10px;
}

.alert-panel-drilldown > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}

.alert-panel-drilldown > summary::-webkit-details-marker {
  display: none;
}

.alert-panel-drilldown:not([open]) .alert-panel-title {
  margin-bottom: 0;
}

.alert-panel-drilldown[open] .alert-panel-title {
  margin-bottom: 10px;
}

.alert-card {
  border-top: 1px solid #f1c7c7;
  padding-top: 8px;
  margin-top: 8px;
}

.alert-card:first-of-type {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.alert-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
  color: #9f1239;
  list-style: none;
}

.alert-card > summary::-webkit-details-marker {
  display: none;
}

.alert-list {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.alert-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid #f4d7d7;
}

.alert-item:first-child {
  border-top: 0;
  padding-top: 4px;
}

.alert-item-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  color: #7f1d1d;
}

.alert-entity {
  font-weight: 900;
  color: #7f1d1d;
}

.alert-text {
  color: #991b1b;
}

.alert-meta {
  font-size: 11px;
  color: #7f1d1d;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .alert-panel-title {
    font-size: 19px;
  }

  .alert-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .alert-meta {
    white-space: normal;
  }
}

.grid-auto-fit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.filter-toolbar .field {
  min-width: 170px;
  flex: 1 1 170px;
  max-width: 260px;
}

.filter-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  flex-wrap: wrap;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

.active-filters-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  margin-right: 2px;
}

.pill.filter-chip {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.module-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.module-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.module-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.4px;
  font-weight: 900;
  color: #0f172a;
}

.module-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.module-empty-state {
  text-align: center;
  padding: 24px 20px;
}

.module-empty-emoji {
  font-size: 34px;
  line-height: 1;
  margin-bottom: 10px;
}

.module-empty-title {
  font-size: 19px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 6px;
}

.module-empty-text {
  max-width: 520px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 20px 16px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
}

.empty-state-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
}

.empty-state-text {
  margin: 6px auto 0;
  color: #475569;
  max-width: 560px;
  font-size: 14px;
}

.empty-state-actions {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.module-icon-box {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.module-icon-box svg {
  width: 38px;
  height: 38px;
}

.date-highlight {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--sidebar-bg);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
}

.date-highlight::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
}

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  flex-shrink: 0;
}

.hamburger:hover {
  background: var(--soft);
}

.hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.hamburger.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger.open span:nth-child(2) {
  opacity: 0;
}

.hamburger.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
}

.sidebar-overlay.visible {
  display: block;
}

@media (max-width: 768px) {
  .sidebar {
    height: 100dvh;
    max-height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Push layout: main desloca à direita quando sidebar aberta — não sobrepõe */
  .main {
    margin-left: 0;
    transition: margin-left 0.25s ease;
  }

  body.sidebar-open .main {
    margin-left: var(--sidebar-w);
  }

  /* Bloqueia scroll do body em mobile quando a sidebar está aberta.
     Evita aparecer fundo branco por baixo ao continuar a fazer scroll.
     `top` é injectado pelo JS para preservar a posição actual. */
  body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  /* Overlay só sobre a área do main (não cobre o sidebar) */
  .sidebar-overlay {
    left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
  }

  .sidebar-overlay.visible {
    display: block;
  }

  /* Topbar fixa — hamburger sempre visível ao scroll em mobile */
  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 10px 12px;
    min-height: 58px;
    z-index: 60;
    gap: 8px;
  }

  .topbar-title {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }

  .topbar .topbar-search-form {
    display: none;
  }

  .topbar .topbar-search-shortcut {
    display: inline-flex;
    flex-shrink: 0;
    padding: 4px 8px;
    font-size: 11px;
    line-height: 1.1;
  }

  .topbar-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
    flex-shrink: 0;
    min-width: 0;
    max-width: 56vw;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar-meta::-webkit-scrollbar {
    display: none;
  }

  .topbar-meta .topbar-user-name {
    display: none;
  }

  /* Tema só ícone em mobile — liberta espaço para o seletor de empresa */
  .topbar-theme-label {
    display: none;
  }

  .topbar-theme-btn {
    padding: 4px 8px;
  }

  /* Notificações: em mobile o dropdown não pode ser cortado pelo overflow da topbar. */
  .notif-dropdown {
    position: fixed;
    top: 64px;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
    max-height: min(70vh, 520px);
    overflow: hidden;
  }

  .notif-list {
    max-height: min(58vh, 420px);
  }

  .topbar-chip {
    max-width: 110px;
    font-size: 10px;
    padding: 2px 7px;
  }

  .topbar-logout-mobile-form {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
    flex-shrink: 0;
  }

  .topbar-logout-mobile {
    min-height: 30px;
    padding: 4px 8px;
    font-size: 11px;
    line-height: 1.1;
  }

  /* Compensar espaço da topbar fixa */
  .container {
    padding: 12px 10px;
    /* Evita que a topbar fixa sobreponha o início da página */
    padding-top: 72px;
  }

  .wrap {
    max-width: 100%;
  }

  .card {
    padding: 12px;
    border-radius: 12px;
  }

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

  .kpi-grid,
  .kpi-grid-tight {
    grid-template-columns: 1fr !important;
  }

  .kpi-compact-board {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .kpi-compact-board.kpi-compact-board--triple {
    grid-template-columns: 1fr;
  }

  .kpi-module-card {
    padding: 10px;
  }

  .kpi-period-tile {
    padding: 9px;
  }

  .dashboard-inspecao-score {
    font-size: 24px;
  }

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

  .team-bar-plot {
    height: 132px;
  }

  .team-bar-fill {
    width: 42px;
  }

  .mission-week-pct {
    font-size: 24px;
  }

  .mission-week-road {
    margin-top: 7px;
  }

  .mission-week-road__marker {
    width: 18px;
    height: 18px;
    top: -4px;
  }

  .mission-week-road__marker::after {
    font-size: 9px;
  }

  .mission-week-road__legend {
    font-size: 8px;
  }

  .mission-week-level__label {
    font-size: 8px;
  }

  /* Formulários: todos os grids de 2+ colunas → 1 coluna em mobile */
  .form-row,
  .form-grid-2,
  .grid-3 {
    grid-template-columns: 1fr !important;
  }

  /* Inline 2-col também (registos, etc.) — com ou sem espaço após : */
  .container [style*="grid-template-columns: 1fr 1fr"],
  .container [style*="grid-template-columns:1fr 1fr"],
  .wrap [style*="grid-template-columns: 1fr 1fr"],
  .wrap [style*="grid-template-columns:1fr 1fr"],
  .card [style*="grid-template-columns: 1fr 1fr"],
  .card [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .hamburger {
    display: flex;
  }

  .module-header {
    align-items: flex-start;
  }

  .module-actions {
    width: 100%;
  }

  .module-actions .btn {
    flex: 1 1 calc(50% - 10px);
    justify-content: center;
  }

  .topbar-meta .tenant-switch-form {
    flex-shrink: 0;
    min-width: 0;
  }

  .topbar-meta .tenant-switch-select {
    min-width: 0;
    max-width: 150px;
    font-size: 11px;
    padding: 4px 6px;
  }

  .topbar-meta .tenant-switch-btn {
    display: none;
  }

  .module-actions form {
    flex: 1 1 calc(50% - 10px);
  }

  .module-actions form .btn {
    width: 100%;
    justify-content: center;
  }

  .module-title {
    font-size: 21px;
  }

  .module-subtitle {
    font-size: 12px;
  }

  .module-icon-box {
    width: 52px;
    height: 52px;
    border-radius: 12px;
  }

  .module-icon-box svg {
    width: 30px;
    height: 30px;
  }

  .big {
    font-size: 22px;
  }

  .kpi-value {
    font-size: 20px;
  }

  .kpi-ring {
    width: 74px;
    height: 74px;
  }

  .kpi-ring::before {
    width: 52px;
    height: 52px;
  }

  .kpi-ring__text {
    font-size: 13px;
  }

  .dashboard-kpi-stack .kpi-module-card,
  .dashboard-kpi-section .kpi-module-card {
    padding: 6px 7px;
  }

  .dashboard-kpi-stack .kpi-period-tile,
  .dashboard-kpi-section .kpi-period-tile {
    padding: 5px 6px;
  }

  .dashboard-kpi-stack .kpi-ring,
  .dashboard-kpi-section .kpi-ring {
    width: 62px;
    height: 62px;
  }

  .dashboard-kpi-stack .kpi-ring::before,
  .dashboard-kpi-section .kpi-ring::before {
    width: 44px;
    height: 44px;
  }

  .dashboard-kpi-stack .kpi-ring__text,
  .dashboard-kpi-section .kpi-ring__text {
    font-size: 11px;
  }

  .congelacao-stage-kpis__tile {
    padding: 5px 6px;
  }

  .congelacao-stage-kpis__value {
    font-size: 16px;
  }

  .k,
  .muted,
  .subtle-note {
    font-size: 12px;
  }

  .btn {
    padding: 10px 14px;
    min-height: 44px;
    font-size: 14px;
  }

  th,
  td {
    padding: 7px 6px;
  }

  th {
    font-size: 12px;
  }

  td {
    font-size: 14px;
  }

  /* Inputs em mobile: 16px evita zoom no iOS */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea,
  .input {
    font-size: 16px;
    min-height: 44px;
    padding: 10px 14px;
  }

  .table-wrap table {
    min-width: 320px;
  }

  .table-wrap.compact table,
  .table-wrap-mobile table {
    min-width: 0;
  }

  html {
    -webkit-text-size-adjust: 100%;
  }

  /* Modo compacto: manter legibilidade, sem escala forçada */
  .mobile-compact {
    transform: none;
    transform-origin: initial;
    width: 100%;
    margin-left: 0;
  }

  .mobile-compact .card {
    padding: 12px;
    border-radius: 10px;
  }

  .mobile-compact .section-gap {
    margin-top: 8px;
  }

  .mobile-compact .row {
    gap: 8px;
  }

  .mobile-compact .row .card {
    flex: 1 1 100%;
  }

  .mobile-compact .grid-auto-fit {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .mobile-compact .module-title {
    font-size: 21px;
  }

  .mobile-compact .module-subtitle {
    font-size: 13px;
  }

  .mobile-compact .module-icon-box {
    width: 46px;
    height: 46px;
    border-radius: 10px;
  }

  .mobile-compact .module-icon-box svg {
    width: 26px;
    height: 26px;
  }

  .mobile-compact .big {
    font-size: 19px;
  }

  .mobile-compact .kpi-value {
    font-size: 20px;
  }

  .mobile-compact .btn {
    padding: 8px 10px;
    min-height: 42px;
    font-size: 12px;
    border-radius: 8px;
  }

  .mobile-compact .module-actions {
    gap: 6px;
  }

  .mobile-compact .module-actions .btn {
    flex: 1 1 100%;
    justify-content: center;
  }

  .mobile-compact .module-actions form {
    flex: 1 1 100%;
  }

  .mobile-compact .module-actions form .btn {
    width: 100%;
  }

  .mobile-compact th,
  .mobile-compact td {
    padding: 6px 5px;
  }

  .mobile-compact th {
    font-size: 11px;
  }

  .mobile-compact td {
    font-size: 12px;
  }

  .mobile-compact .table-wrap table {
    min-width: 620px;
  }

  .mobile-compact .table-wrap.compact table {
    min-width: 0;
  }

  .mobile-compact .k,
  .mobile-compact .muted,
  .mobile-compact .subtle-note {
    font-size: 13px;
  }

  .filter-toolbar .field {
    min-width: 140px;
    max-width: none;
    flex: 1 1 100%;
  }

  .filter-actions {
    margin-left: 0;
    width: 100%;
  }

  /* Formulários de congelação — empilhar colunas em mobile */
  .mobile-compact .form-row {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .mobile-compact .form-actions {
    flex-direction: column;
    gap: 8px;
  }

  .mobile-compact .form-actions .btn,
  .mobile-compact .form-actions a.btn {
    width: 100%;
    justify-content: center;
  }

  /* Touch targets maiores — inputs e selects */
  .mobile-compact .input,
  .mobile-compact select.input {
    min-height: 44px;
    font-size: 16px; /* Evita zoom automático no iOS ao focar */
    padding: 10px 14px;
  }

  /* Card de contexto do lote — colunas empilháveis em mobile */
  .mobile-compact .lote-contexto-grid {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }

  .mobile-compact .module-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .mobile-compact .module-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
  }

  .mobile-compact .module-actions .btn {
    width: 100%;
  }

  /* Equipa: layout card da tabela apenas em mobile (<768px) */
  .mobile-compact.equipa-page .table-wrap-mobile thead {
    display: none;
  }
  .mobile-compact.equipa-page .table-wrap-mobile table,
  .mobile-compact.equipa-page .table-wrap-mobile tbody,
  .mobile-compact.equipa-page .table-wrap-mobile tr,
  .mobile-compact.equipa-page .table-wrap-mobile td {
    display: block;
    width: 100%;
  }
  .mobile-compact.equipa-page .table-wrap-mobile table {
    min-width: 0 !important;
    table-layout: auto;
  }
  .mobile-compact.equipa-page .table-wrap-mobile tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  }
  .mobile-compact.equipa-page .table-wrap-mobile td {
    border: 0;
    padding: 6px 0;
  }
  .mobile-compact.equipa-page .table-wrap-mobile td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
  }
  .mobile-compact.equipa-page .table-wrap-mobile td.right {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
  }
  .mobile-compact.equipa-page .table-wrap-mobile td.right a.btn,
  .mobile-compact.equipa-page .table-wrap-mobile td.right .btn {
    width: 100%;
  }
  .mobile-compact.equipa-page .table-wrap-mobile td.right .inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
}

@media (max-width: 480px) {
  .mobile-compact.equipa-page .manutencao-kpis {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .topbar-chip {
    display: none;
  }

  .topbar-meta {
    max-width: none;
  }
}

@media (max-width: 430px) {
  .topbar {
    padding: 8px 10px;
  }

  .topbar-title {
    font-size: 13px;
  }

  .container {
    padding: 10px 8px;
    padding-top: 70px; /* manter espaço para topbar fixa */
  }

  .card {
    padding: 10px;
    border-radius: 10px;
  }

  .module-title {
    font-size: 19px;
  }

  .module-subtitle {
    font-size: 12px;
  }

  .btn {
    min-height: 42px;
    padding: 8px 10px;
    font-size: 12px;
  }

  .table-wrap table {
    min-width: 560px;
  }

  .table-wrap.compact table {
    min-width: 520px;
  }

  .mobile-compact .table-wrap table {
    min-width: 560px;
  }
}

@media (max-width: 390px) {
  .topbar-title {
    font-size: 12px;
  }

  .module-title {
    font-size: 18px;
  }

  .module-icon-box {
    width: 44px;
    height: 44px;
  }

  .module-icon-box svg {
    width: 24px;
    height: 24px;
  }

  .kpi-value {
    font-size: 18px;
  }

  .kpi-ring {
    width: 68px;
    height: 68px;
  }

  .kpi-ring::before {
    width: 48px;
    height: 48px;
  }

  .kpi-ring__text {
    font-size: 12px;
  }

  .table-wrap table {
    min-width: 520px;
  }

  .table-wrap.compact table {
    min-width: 480px;
  }
}

/* Equipa: overflow/min-width para evitar scroll horizontal em janelas médias */
@media (max-width: 1400px) {
  .mobile-compact.equipa-page {
    overflow-x: hidden;
    max-width: 100%;
  }
  .mobile-compact.equipa-page .module-header-left,
  .mobile-compact.equipa-page .module-header-left > div {
    min-width: 0;
  }
  .mobile-compact.equipa-page .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }
}

/* Congelação de peixe e produtos: tabelas em cartão para tablet/mobile */
@media (max-width: 1024px) {
  /* Congelação: blindagem anti-overflow horizontal em todas as abas */
  .mobile-compact.peixe-page,
  .mobile-compact.produto-page {
    overflow-x: hidden;
    max-width: 100%;
  }

  .mobile-compact.peixe-page .module-header-left,
  .mobile-compact.peixe-page .module-header-left > div,
  .mobile-compact.peixe-page .processo-auto-strip > *,
  .mobile-compact.produto-page .module-header-left,
  .mobile-compact.produto-page .module-header-left > div,
  .mobile-compact.produto-page .processo-auto-strip > * {
    min-width: 0;
  }

  .mobile-compact.peixe-page .module-subtitle,
  .mobile-compact.peixe-page .subtle-note,
  .mobile-compact.peixe-page .processo-auto-resumo,
  .mobile-compact.produto-page .module-subtitle,
  .mobile-compact.produto-page .subtle-note,
  .mobile-compact.produto-page .processo-auto-resumo {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .mobile-compact.peixe-page .processo-auto-strip,
  .mobile-compact.produto-page .processo-auto-strip {
    align-items: flex-start !important;
  }

  .mobile-compact .tab-bar {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .mobile-compact .tab-bar::-webkit-scrollbar {
    display: none;
  }

  .mobile-compact .tab-bar .tab-link {
    flex: 0 0 auto;
    max-width: 100%;
  }

  .mobile-compact.peixe-page .tab-bar,
  .mobile-compact.produto-page .tab-bar {
    flex-wrap: wrap !important;
    overflow: visible;
    gap: 6px !important;
  }

  /* Tabs devem caber no viewport sem scroll horizontal */
  .mobile-compact.peixe-page .tab-bar .tab-link,
  .mobile-compact.produto-page .tab-bar .tab-link {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    white-space: normal !important;
    padding: 8px 10px !important;
    font-size: 12px !important;
    line-height: 1.2;
    text-align: center;
  }

  .mobile-compact.peixe-page .peixe-stage-kpis,
  .mobile-compact.produto-page .peixe-stage-kpis,
  .mobile-compact.peixe-page .congelacao-stage-kpis,
  .mobile-compact.produto-page .congelacao-stage-kpis,
  .mobile-compact.recepcao-merc-dashboard .congelacao-stage-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .mobile-compact .table-wrap.peixe-table-wrap,
  .mobile-compact.produto-page .table-wrap {
    overflow-x: hidden;
    max-width: 100%;
  }

  /* Faixa de superuser: permitir quebra total de texto para não alargar a página */
  .mobile-compact .processo-auto-strip,
  .mobile-compact .processo-auto-strip form {
    max-width: 100%;
    overflow: hidden;
  }

  .mobile-compact .processo-auto-strip form {
    flex-wrap: wrap;
  }

  .mobile-compact .processo-auto-strip span {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Equipa, EPI, Formação e NC: blindagem anti-overflow horizontal */
  .mobile-compact.equipa-page,
  .mobile-compact.equipa-epi-page,
  .mobile-compact.formacao-page,
  .mobile-compact.nc-page {
    overflow-x: hidden;
    max-width: 100%;
  }

  .mobile-compact.equipa-page .module-header-left,
  .mobile-compact.equipa-page .module-header-left > div,
  .mobile-compact.equipa-epi-page .module-header-left,
  .mobile-compact.equipa-epi-page .module-header-left > div,
  .mobile-compact.formacao-page .module-header-left,
  .mobile-compact.formacao-page .module-header-left > div,
  .mobile-compact.nc-page .module-header-left,
  .mobile-compact.nc-page .module-header-left > div {
    min-width: 0;
  }

  .mobile-compact.equipa-page .table-wrap,
  .mobile-compact.equipa-epi-page .table-wrap,
  .mobile-compact.formacao-page .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }

  /* Nova formação: barra "Selecionar todos" fica fora do scroll da tabela; não herdar largura mínima */
  .mobile-compact.formacao-page .formacao-nova-select-all-wrap {
    position: relative;
    z-index: 1;
  }

  /* Tabela participantes: em ecrãs muito estreitos reduzir um pouco o min-width para menos scroll lateral */
  @media (max-width: 480px) {
    .mobile-compact.formacao-page .formacao-nova-table-wrap table {
      min-width: 520px;
    }
  }

  /* Equipa: KPIs em 2 colunas em janela estreita para não cortar */
  .mobile-compact.equipa-page .manutencao-kpis {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  /* Botão de descongelação em massa é longo: empilhar para caber no viewport */
  .mobile-compact #form-descongelacao-massa {
    flex-direction: column;
    align-items: stretch !important;
  }

  .mobile-compact #form-descongelacao-massa .btn {
    width: 100%;
    white-space: normal;
    text-align: center;
  }

  .peixe-table-wrap table,
  .peixe-table-wrap tbody,
  .peixe-table-wrap tr,
  .peixe-table-wrap td {
    display: block;
    width: 100%;
  }

  .peixe-table-wrap thead {
    display: none;
  }

  .peixe-table-wrap table {
    min-width: 0 !important;
  }

  .peixe-table-wrap tr {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  }

  .peixe-table-wrap td {
    border: 0;
    border-bottom: 1px dashed #e5e7eb;
    padding: 8px 0 8px 42%;
    position: relative;
    min-height: 30px;
    text-align: left;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .peixe-table-wrap td:last-child {
    border-bottom: 0;
  }

  .peixe-table-wrap td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 8px;
    width: 38%;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-transform: uppercase;
  }

  .peixe-table-wrap td.cell-actions {
    padding-left: 0;
    padding-top: 10px;
  }

  .peixe-table-wrap td.cell-actions::before {
    display: none;
  }

  .peixe-table-wrap td.cell-actions .btn-actions-row {
    display: flex;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .peixe-table-wrap td.cell-actions .btn-actions-row .btn,
  .peixe-table-wrap td.cell-actions .btn-actions-row form,
  .peixe-table-wrap td.cell-actions .btn-actions-row form .btn {
    width: 100%;
  }

  /* Histórico de consumo: no modo responsivo em cartão, manter ações empilhadas
     como nas restantes páginas para evitar corte em janelas estreitas. */
  .consumo-table-wrap.peixe-table-wrap td.cell-actions .btn-actions-row {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .consumo-table-wrap.peixe-table-wrap td.cell-actions .btn-actions-row .btn,
  .consumo-table-wrap.peixe-table-wrap td.cell-actions .btn-actions-row form,
  .consumo-table-wrap.peixe-table-wrap td.cell-actions .btn-actions-row form .btn {
    width: 100%;
  }
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  align-content: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.confirm-modal[hidden] {
  display: none;
}

.confirm-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.confirm-modal__panel {
  position: relative;
  width: 100%;
  max-width: min(460px, calc(100vw - 24px));
  min-width: 0;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 16px 34px rgba(2, 6, 23, 0.24);
  padding: 18px;
  max-height: min(88vh, calc(100dvh - 24px));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.confirm-modal__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.confirm-modal__icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 900;
  background: #fee2e2;
  color: #991b1b;
  flex-shrink: 0;
}

.confirm-modal__kicker {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 6px;
}

.confirm-modal__title {
  margin: 0;
  font-size: 19px;
  font-weight: 900;
  color: #0f172a;
}

.confirm-modal__message {
  margin: 8px 0 0;
  color: #334155;
  font-size: 14px;
}

.confirm-modal__reason {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.confirm-modal__reason[hidden] {
  display: none;
}

.confirm-modal__reason-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  margin: 0 0 2px;
}

.confirm-modal__reason-select,
.confirm-modal__reason-detail .input {
  width: 100%;
  box-sizing: border-box;
}

.confirm-modal__reason-error {
  font-size: 12px;
  color: #dc2626;
  font-weight: 600;
}

.confirm-modal__actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .confirm-modal__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .confirm-modal__actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Assinatura formação: largura máxima coerente com o viewport */
.confirm-modal__panel.formacao-ass-modal-panel {
  max-width: min(560px, calc(100vw - 24px));
}
@media (min-width: 600px) {
  .confirm-modal__panel.formacao-ass-modal-panel {
    max-width: min(820px, calc(100vw - 48px));
  }
}
@media (orientation: landscape) and (max-width: 768px) {
  .confirm-modal__panel.formacao-ass-modal-panel {
    max-width: min(680px, calc(100vw - 24px));
  }
}

.formacao-ass-signature-box canvas {
  max-width: 100%;
  height: auto;
  min-height: 120px;
}

#confirmModalSubmit {
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  box-shadow: 0 1px 2px rgba(2, 6, 23, 0.12);
}

#confirmModalSubmit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.18);
}

#confirmModalSubmit:active {
  transform: translateY(0) scale(0.985);
  box-shadow: 0 1px 3px rgba(2, 6, 23, 0.12);
}

body.modal-open {
  overflow: hidden;
}

.confirm-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.confirm-modal.is-open .confirm-modal__backdrop {
  opacity: 1;
}

.confirm-modal.is-open .confirm-modal__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.confirm-modal[data-tone="warning"] .confirm-modal__icon {
  background: #fef3c7;
  color: #92400e;
}

.confirm-modal[data-tone="warning"] .confirm-modal__kicker {
  color: #92400e;
}

.confirm-modal[data-tone="danger"] .confirm-modal__icon {
  background: #fee2e2;
  color: #991b1b;
}

.confirm-modal[data-tone="danger"] .confirm-modal__kicker {
  color: #991b1b;
}

.confirm-modal[data-tone="neutral"] .confirm-modal__icon {
  background: #e2e8f0;
  color: #334155;
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .btn.secondary,
  .btn.danger,
  .btn:active,
  .confirm-modal,
  .confirm-modal__backdrop,
  .confirm-modal__panel,
  #confirmModalSubmit {
    transition: none;
  }
}

.turno-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.turno-choice {
  position: relative;
}

.turno-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.turno-choice__card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
  text-align: center;
}

.turno-choice__title {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}

.turno-choice input:checked + .turno-choice__card {
  border-color: #111827;
  background: #eef2ff;
}

.turno-choice__card:hover {
  background: #f3f4f6;
}

.turno-choice input:checked + .turno-choice__card:hover {
  background: #e5e7eb;
}

.turno-choice-summary {
  margin-top: 10px;
  color: #374151;
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 720px) {
  .turno-choice-grid {
    grid-template-columns: 1fr;
  }
}

.cal-col-half {
  flex: 1 1 calc(50% - 6px);
}

.cal-col-full {
  flex: 1 1 100%;
}

.cal-table-wrap {
  margin-top: 6px;
}

.cal-table-wrap table {
  min-width: 0;
  table-layout: auto;
}

.cal-table-wrap th,
.cal-table-wrap td {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Calendário: tablet — empilhar colunas e layout card para tabelas */
@media (min-width: 769px) and (max-width: 1024px) {
  .cal-col-half {
    flex-basis: 100%;
  }

  .cal-table-wrap thead {
    display: none;
  }

  .cal-table-wrap table,
  .cal-table-wrap tbody,
  .cal-table-wrap tr,
  .cal-table-wrap td {
    display: block;
    width: 100%;
  }

  .cal-table-wrap tr {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 8px;
    background: #fff;
  }

  .cal-table-wrap td {
    border: 0;
    padding: 4px 0;
  }

  .cal-table-wrap td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
  }

  .cal-table-wrap td.right { text-align: left; }

  .cal-table-wrap td.right .inline-form,
  .cal-table-wrap td.right .btn { width: 100%; }

  .cal-table-wrap .empty-cell { display: block; padding: 8px 0; text-align: left; }
}

/* Calendário: 2 colunas → 1 coluna em mobile (<768px) */
@media (max-width: 768px) {
  .cal-col-half,
  .cal-col-full {
    flex-basis: 100%;
  }

  .cal-kpis {
    grid-template-columns: 1fr;
  }

  .cal-table-wrap thead {
    display: none;
  }

  .cal-table-wrap table,
  .cal-table-wrap tbody,
  .cal-table-wrap tr,
  .cal-table-wrap td {
    display: block;
    width: 100%;
  }

  .cal-table-wrap tr {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 8px;
    background: #fff;
  }

  .cal-table-wrap td {
    border: 0;
    padding: 4px 0;
  }

  .cal-table-wrap td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
  }

  .cal-table-wrap td.right {
    text-align: left;
  }

  .cal-table-wrap td.right .inline-form,
  .cal-table-wrap td.right .btn {
    width: 100%;
  }

  .cal-table-wrap .empty-cell {
    display: block;
    padding: 8px 0;
    text-align: left;
  }

  /* Tabelas genéricas: layout card em mobile (requer data-label nas td)
     Equipa mantém tabela até 768px — :not(.equipa-table-wrap) exclui-a aqui */
  .table-wrap-mobile:not(.equipa-table-wrap) thead {
    display: none;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) table,
  .table-wrap-mobile:not(.equipa-table-wrap) tbody,
  .table-wrap-mobile:not(.equipa-table-wrap) tr,
  .table-wrap-mobile:not(.equipa-table-wrap) td {
    display: block;
    width: 100%;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) table {
    min-width: 0 !important;
    table-layout: auto;
  }

  .mobile-compact .table-wrap.table-wrap-mobile:not(.equipa-table-wrap) table {
    min-width: 0 !important;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) tr {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    /* Mais espaço entre cartões e sombra mais nítida: no telemóvel os registos
       deixam de parecer colados/misturados (pedido do Ricardo). */
    margin-bottom: 18px;
    background: var(--card);
    box-shadow: 0 5px 16px rgba(15, 23, 42, 0.1);
  }

  .table-wrap-mobile:not(.equipa-table-wrap) td {
    border: 0;
    padding: 6px 0;
  }

  /* Primeiro campo = cabeçalho do cartão: separador + rótulo azul, para se ver
     de relance onde começa cada registo. */
  .table-wrap-mobile:not(.equipa-table-wrap) td:first-child {
    border-bottom: 1px solid var(--line);
    padding-bottom: 9px;
    margin-bottom: 4px;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) td:first-child::before {
    color: #2563eb;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) td.right {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) td.right .inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) td.right .inline-form .input,
  .table-wrap-mobile:not(.equipa-table-wrap) td.right .inline-form select {
    width: 100%;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) td.right .btn,
  .table-wrap-mobile:not(.equipa-table-wrap) td.right a.btn {
    width: 100%;
  }

  .table-wrap-mobile:not(.equipa-table-wrap) td.right .inline-form select {
    flex: 1;
    min-width: 0;
  }

  /* Receção — acções a largura total no cartão mobile (como peixe/equipa) */
  .table-wrap-mobile.recepcao-list-table td.cell-actions {
    width: 100%;
    text-align: left;
    padding-top: 10px;
  }
  .table-wrap-mobile.recepcao-list-table td.cell-actions .recepcao-row-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
    max-width: 100%;
  }
  .table-wrap-mobile.recepcao-list-table td.cell-actions .recepcao-row-actions .btn,
  .table-wrap-mobile.recepcao-list-table td.cell-actions .recepcao-row-actions__form,
  .table-wrap-mobile.recepcao-list-table td.cell-actions .recepcao-row-actions__form .btn {
    width: 100%;
    box-sizing: border-box;
  }
}

/* Minha Conta: evitar cards "espremidos" em tablet */
@media (max-width: 1024px) {
  .conta-page .conta-layout .row {
    flex-direction: column;
  }

  .conta-page .conta-layout .cal-col-half {
    flex: 1 1 100%;
  }
}

/* Conta / definições: títulos e logótipo */
.cal-form-card h3.k {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #334155;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.logo-upload-box {
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  background: #f8fafc;
  padding: 16px;
}

.logo-upload-current {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Receção peixe: em mobile, dar largura útil aos inputs */
@media (max-width: 900px) {
  .rececao-itens-wrap table,
  .mobile-compact .table-wrap.rececao-itens-wrap table {
    min-width: 0 !important;
    table-layout: fixed;
  }

  .rececao-itens-wrap thead {
    display: none;
  }

  .rececao-itens-wrap table,
  .rececao-itens-wrap tbody {
    display: block;
    width: 100%;
  }

  .rececao-itens-wrap .rececao-item-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
    background: var(--card);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  }

  .rececao-itens-wrap .rececao-item-row td {
    display: block;
    width: 100%;
    border: 0;
    padding: 0;
  }

  .rececao-itens-wrap .rececao-item-row td.col-tipo,
  .rececao-itens-wrap .rececao-item-row td.col-lote,
  .rececao-itens-wrap .rececao-item-row td.col-origem,
  .rececao-itens-wrap .rececao-item-row td.col-remove {
    grid-column: 1 / -1;
  }

  .rececao-itens-wrap .rececao-item-row td.col-remove {
    display: flex;
    justify-content: flex-end;
  }

  .rececao-itens-wrap .rececao-item-row .input {
    width: 100%;
    min-width: 0;
  }
}

.logo-preview {
  flex-shrink: 0;
  max-width: 140px;
  max-height: 72px;
  overflow: hidden;
}

.logo-preview-img {
  display: block;
  max-height: 64px;
  max-width: 120px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.logo-upload-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.logo-filename {
  font-size: 13px;
  color: #64748b;
  word-break: break-all;
}

.logo-clear-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.logo-upload-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.logo-upload-actions .logo-upload-btn {
  margin: 0;
}

.btn-remove-logo {
  color: #dc2626;
  border-color: #fecaca;
}

.btn-remove-logo:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.logo-upload-current.logo-pending-remove .logo-preview {
  opacity: 0.5;
}

.logo-upload-current.logo-pending-remove .logo-filename::after {
  content: " · Será removido ao guardar";
  color: #dc2626;
  font-weight: 500;
}

.logo-upload-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 12px 0;
}

.logo-upload-new {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.logo-upload-input {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.logo-upload-btn {
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

.logo-upload-hint {
  font-size: 13px;
  color: #64748b;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-help-above {
  display: block;
  margin-top: 0;
  margin-bottom: 8px;
}

/* ============================================================
   GESTÃO DOCUMENTAL
   ============================================================ */

.doc-cat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.doc-cat-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
}
.doc-cat-label.doc-cat-haccp         { background: #dbeafe; color: #1e40af; }
.doc-cat-label.doc-cat-licenciamento { background: #fef3c7; color: #92400e; }
.doc-cat-label.doc-cat-higiene       { background: #dcfce7; color: #166534; }
.doc-cat-label.doc-cat-formacao      { background: #f3e8ff; color: #6b21a8; }
.doc-cat-label.doc-cat-fornecedores  { background: #ffedd5; color: #9a3412; }
.doc-cat-label.doc-cat-seguranca     { background: #fee2e2; color: #b91c1c; }
.doc-cat-label.doc-cat-disticos_entrada    { background: #fae8ff; color: #86198f; }
.doc-cat-label.doc-cat-disticos_balnearios { background: #ecfeff; color: #0e7490; }
.doc-cat-label.doc-cat-rh            { background: #cffafe; color: #0f766e; }
.doc-cat-label.doc-cat-hotelaria     { background: #e0e7ff; color: #3730a3; }
.doc-cat-label.doc-cat-outro         { background: #e2e8f0; color: #334155; }

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.doc-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.doc-row:last-child { border-bottom: none; }

.doc-row-focus {
  background: #f8fafc;
  border: 1px solid #dbe4ea;
  border-radius: 10px;
  padding: 12px;
  margin: 4px 0;
}

.doc-status-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 1px;
}
.doc-status-icon svg { width: 22px; height: 22px; }

.doc-info {
  flex: 1;
  min-width: 0;
}

.doc-nome {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.doc-pill-obrigatorio {
  background: rgba(185, 28, 28, 0.08);
  color: #b91c1c;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.doc-base-legal {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.doc-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}
.doc-meta-missing { color: #dc2626; font-style: italic; }

.doc-link {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
}
.doc-link:hover { text-decoration: underline; }

.doc-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.doc-upload-form { display: flex; align-items: center; gap: 6px; }

.doc-upload-label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.doc-file-input {
  display: none;
}

/* Acordeão por categoria */
.doc-categoria-details {
  padding: 0;
  overflow: hidden;
}
.doc-categoria-details > .doc-list {
  padding: 0 16px 12px;
}
.doc-categoria-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.doc-categoria-summary::-webkit-details-marker { display: none; }
.doc-cat-progress {
  font-size: 13px;
}
.doc-cat-chevron {
  color: var(--muted);
  font-size: 14px;
  transition: transform 0.18s ease;
  flex-shrink: 0;
}
.doc-categoria-details[open] .doc-cat-chevron {
  transform: rotate(180deg);
}

/* Lista de ficheiros dentro de um tipo */
.doc-ficheiros-lista {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.doc-ficheiro-linha {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
}
.doc-del-btn {
  all: unset;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  line-height: 1.4;
}
.doc-del-btn:hover { color: #dc2626; background: #fee2e2; }

/* Linha verde/vermelha discreta no fundo da row */
.doc-row.doc-ok .doc-nome   { color: var(--text); }
.doc-row.doc-missing .doc-nome { color: var(--text); }

@media (max-width: 768px) {
  .doc-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .doc-info {
    flex-basis: calc(100% - 34px);
  }

  .doc-actions {
    flex-basis: 100%;
    padding-left: 34px;
    flex-wrap: wrap;
  }

  .doc-upload-form {
    flex-wrap: wrap;
  }

  .doc-upload-label,
  .doc-actions .btn {
    min-height: 44px;
    padding: 0 16px;
    font-size: 14px;
  }
}

/* ── Plans comparison (conta/definicoes) ─────────────────────────── */
.plan-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.plan-current-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 99px;
  letter-spacing: .01em;
}
.plan-current-chip--basic,
.plan-current-chip--standard,
.plan-current-chip--premium {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1.5px solid #bfdbfe;
}

/* Comparação de planos (Minha Conta): 2×2 em ecrã largo — cartões mais largos e legíveis */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 2.2vw, 28px);
  align-items: stretch;
  width: 100%;
  max-width: 1100px;
  margin-inline: auto;
}

.plan-card {
  border: 1.5px solid #dbe2ea;
  border-radius: 16px;
  padding: clamp(18px, 1.8vw, 24px) clamp(18px, 2vw, 26px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  min-width: 0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.plan-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
}
/* Plano em uso: teal (estado) — distinto do «Mais escolhido» índigo e do PRO âmbar */
.plan-card--current {
  border: 2px solid #0d9488;
  background: linear-gradient(180deg, #f0fdfa 0%, #f8fafc 100%);
  box-shadow: 0 10px 24px rgba(13, 148, 136, 0.14);
}
/* Standard «mais escolhido»: índigo (separado do Premium âmbar) */
.plan-card--highlight {
  border: 2px solid #6366f1;
  background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%);
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.12);
}
/* Premium PRO: âmbar / ouro (tier topo) */
.plan-card--pro {
  border: 2px solid #d97706;
  background: linear-gradient(180deg, #fffbeb 0%, #fffaf5 100%);
  box-shadow: 0 10px 24px rgba(180, 83, 9, 0.12);
}

.plan-tier-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 99px;
  letter-spacing: .05em;
  text-transform: uppercase;
  width: fit-content;
}
.plan-tier-badge--current {
  background: linear-gradient(90deg, #0f766e, #0d9488);
  color: #fff;
}
.plan-tier-badge--popular { background: linear-gradient(90deg, #4f46e5, #6366f1); color: #fff; }
.plan-tier-badge--pro     { background: linear-gradient(90deg, #b45309, #d97706); color: #fff; }

.plan-name {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -.02em;
  margin-top: 2px;
}

.plan-subtitle {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: #64748b;
}

.plan-feature-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 800;
  color: #475569;
}

.plan-price {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin-top: -4px;
}
.plan-price-amount {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -.03em;
  line-height: 1;
}
.plan-price-period {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.plan-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}
.plan-features li {
  font-size: clamp(12.5px, 1.05vw, 13.5px);
  color: var(--fg);
  display: flex;
  align-items: flex-start;
  gap: 7px;
  line-height: 1.45;
}
.plan-features li.pf-off {
  color: var(--muted);
}
.pf-ok {
  flex-shrink: 0;
  color: #16a34a;
  font-weight: 900;
  font-size: 12px;
  margin-top: 1px;
}
.pf-no {
  flex-shrink: 0;
  color: #d1d5db;
  font-weight: 900;
  font-size: 12px;
  margin-top: 1px;
}
.plan-feat-note {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.plan-limits {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.plan-limits-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: #475569;
  font-size: 12px;
  line-height: 1.5;
}

.plan-footnote {
  margin-top: 8px;
  font-size: 11px;
  color: #64748b;
}

.plan-cta {
  margin-top: 4px;
}
.plan-upgrade-cta {
  width: 100%;
  justify-content: center;
  text-align: center;
  display: block;
  cursor: pointer;
  font-weight: 700;
}
.plan-upgrade-cta + .plan-upgrade-cta {
  margin-top: 8px;
}
.plan-upgrade-cta:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}
.plan-upgrade-cta--pro {
  background: linear-gradient(90deg, #b45309, #d97706);
  color: #fff;
  border: none;
}
.plan-upgrade-cta--pro:hover {
  background: linear-gradient(90deg, #92400e, #b45309);
  color: #fff;
}

@media (max-width: 768px) {
  .plans-grid {
    grid-template-columns: 1fr;
    max-width: none;
    gap: 14px;
  }
  .plan-card {
    padding: 16px 14px;
    gap: 8px;
  }
  .plan-price-amount {
    font-size: 24px;
  }
  .plan-features {
    gap: 6px;
  }
  .plan-features li {
    font-size: 12.5px;
  }
  .plan-section-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── Storage bar (gestao_documental) ────────────────────────────────── */
.storage-wrap {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.storage-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}
.storage-label-left {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.storage-label-right {
  font-weight: 700;
  color: var(--muted);
}
.storage-label-warn   { color: #b45309; }
.storage-label-danger { color: #dc2626; }

.storage-track {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.storage-fill {
  height: 100%;
  border-radius: 99px;
  background: #2563eb;
  transition: width .3s ease;
}
.storage-fill--warn   { background: #f59e0b; }
.storage-fill--danger { background: #dc2626; }


/* ────────────────────────────────────────────────────────
   MANUTENÇÃO — Badge, estados, row highlights
   ──────────────────────────────────────────────────────── */

/* Badge de contagem no nav (sidebar) */
.nav-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  margin-left: auto;
  line-height: 1;
}

/* Checkbox de seleção em tabelas (congelação, peixe) */
.th-check,
.td-check {
  width: 52px;
  min-width: 52px;
  text-align: center;
  vertical-align: middle;
}
.table-check-input {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  margin: 0;
  padding: 0;
  border: 2px solid #cbd5e1;
  border-radius: 6px;
  background-color: #fff;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
  cursor: pointer;
  flex-shrink: 0;
  vertical-align: middle;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.1s ease;
}
.table-check-input:hover {
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}
.table-check-input:focus-visible {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.28);
}
.table-check-input:checked {
  background-color: #16a34a;
  border-color: #15803d;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3.5 8.5l3 3 6-7' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.table-check-input:indeterminate {
  background-color: #2563eb;
  border-color: #1d4ed8;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 8h8' stroke='%23fff' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
}
.table-check-input:active {
  transform: scale(0.94);
}
.td-check .table-check-input {
  display: inline-block;
}
.quick-table tbody tr:has(.table-check-input[name^="feito_"]:checked) {
  background: #f0fdf4;
}

/* Estado badges para tabelas */
.estado-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.estado-ok      { background: #dcfce7; color: #15803d; }
.estado-nok     { background: #fee2e2; color: #b91c1c; }
.estado-atraso  { background: #fee2e2; color: #dc2626; }
.estado-alerta  { background: #fef3c7; color: #b45309; }
.estado-pendente { background: #f1f5f9; color: #475569; }

/* Row highlights */
.row-danger { background: #fff5f5; }
.row-warn   { background: #fffbeb; }
.row-muted  { background: #f3f4f6; opacity: 0.9; }

/* text helpers */
.text-danger { color: #dc2626; }
.text-warn   { color: #d97706; }
.text-right  { text-align: right; }

/* alert dot */
.alert-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 6px;
}
.alert-dot--danger { background: #dc2626; }
.alert-dot--warn   { background: #f59e0b; }

/* Filter tabs */
.filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.filter-tab {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
.filter-tab:hover  { background: #f3f4f6; border-color: #d1d5db; }
.filter-tab.active { background: #2563eb; border-color: #2563eb; color: #fff; }

/* Botão de danger soft (eliminar) */
.btn-danger-soft {
  color: #dc2626 !important;
  border-color: #fecaca !important;
  background: #fff5f5 !important;
}
.btn-danger-soft:hover {
  background: #fee2e2 !important;
  border-color: #dc2626 !important;
}

.app-footer-legal {
  margin: 24px auto 16px;
  max-width: 1100px;
  padding: 0 16px 8px;
  font-size: 12px;
  color: #6b7280;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.app-footer-legal a {
  color: #4b5563;
  text-decoration: none;
}

.app-footer-legal a:hover {
  text-decoration: underline;
}

/* .cookie-banner / .cookie-prefs: os estilos passaram para o partial
   partials/_cookie_banner.html — o banner também vive no landing_base.html,
   que não carrega este ficheiro. */

.legal-page {
  max-width: 960px;
}

.legal-card {
  max-width: 860px;
  margin: 0 auto;
  border: 1px solid #e2e8f0;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.legal-doc {
  line-height: 1.65;
}

.legal-callout {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #dbeafe;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 14px;
}

.legal-callout--danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.legal-block + .legal-block {
  border-top: 1px solid #e5e7eb;
  margin-top: 16px;
  padding-top: 16px;
}

.legal-doc h2 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.3;
  color: #0f172a;
}

.legal-doc p {
  margin: 0 0 10px;
}

.legal-doc ul {
  margin: 0;
  padding-left: 20px;
}

.legal-doc li + li {
  margin-top: 6px;
}

@media (max-width: 720px) {
  .legal-doc h2 {
    font-size: 18px;
  }

  .legal-card {
    border-radius: 12px;
  }
}

/* Upload indicator (global, para formulários com ficheiros) */
.upload-indicator {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1400;
  width: min(420px, calc(100vw - 24px));
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.upload-indicator.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.upload-indicator-card {
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 10px 32px rgba(15, 23, 42, 0.2);
  padding: 12px;
}

.upload-indicator-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.upload-indicator-title {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
}

.upload-indicator-cancel {
  font-size: 12px;
  padding: 6px 10px;
}

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

.upload-indicator-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8 0%, #2563eb 55%, #7c3aed 100%);
  transition: width 0.28s ease;
}

.upload-indicator-meta {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: #475569;
}

.upload-indicator.is-stopped .upload-indicator-fill {
  background: linear-gradient(90deg, #f59e0b 0%, #ef4444 100%);
}

/* ---- CENTRO DE RELATÓRIOS ---- */
.module-header--reports {
  align-items: center;
}

.module-header--reports .module-header-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.module-title--reports {
  margin-top: 2px;
}

.relatorios-modulos-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 0;
}

.relatorios-modulo-tab {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: var(--soft, #f1f5f9);
  color: var(--text, #1f2937);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}

.relatorios-modulo-tab:hover {
  background: var(--line, #e5e7eb);
}

.relatorios-modulo-tab.active {
  background: #1e3a5f;
  color: #fff;
  border-color: #1e3a5f;
}

.relatorios-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .relatorios-grid { grid-template-columns: 1fr; }
}

.relatorios-periodo-block {
  padding: 14px;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 8px;
}

.relatorios-periodo-desc {
  font-size: 12px;
  color: var(--muted, #6b7280);
  margin-top: 3px;
}

.outros-relatorios-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.outros-relatorio-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line, #f3f4f6);
  gap: 16px;
  flex-wrap: wrap;
}

.outros-relatorio-row:last-child { border-bottom: none; }

.outros-relatorio-nome {
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #111827);
}

.outros-relatorio-desc {
  font-size: 12px;
  color: var(--muted, #6b7280);
  margin-top: 2px;
}

html[data-theme="dark"] .relatorios-modulo-tab {
  background: #1e293b;
  color: #e2e8f0;
}
html[data-theme="dark"] .relatorios-modulo-tab:hover { background: #334155; }
html[data-theme="dark"] .relatorios-modulo-tab.active { background: #1e3a5f; color: #93c5fd; }
html[data-theme="dark"] .relatorios-periodo-block { border-color: #334155; }
html[data-theme="dark"] .outros-relatorio-row { border-bottom-color: #1e293b; }
html[data-theme="dark"] .outros-relatorio-nome { color: #f8fafc; }

/* ---------------------------------------------------------------------------
   Linha/cartão de registo clicável (marcado com .row-clickable pelo app.js):
   abre a ação principal do registo. Cursor em qualquer ecrã; realce ao passar
   o rato apenas no computador.
   --------------------------------------------------------------------------- */
.table-wrap-mobile tbody tr.row-clickable {
  cursor: pointer;
}
@media (min-width: 769px) {
  .table-wrap-mobile tbody tr.row-clickable:hover {
    background: #f1f6ff;
  }
  html[data-theme="dark"] .table-wrap-mobile tbody tr.row-clickable:hover {
    background: rgba(37, 99, 235, 0.14);
  }
}

/* Caixa de pesquisa da listagem de sensores ao vivo (/sensores/) */
.sensor-busca-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 14px;
  flex-wrap: wrap;
}
.sensor-busca {
  flex: 1 1 260px;
  max-width: 360px;
  padding: 9px 12px;
  border: 1px solid #d8dee9;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: #0f172a;
}
.sensor-busca:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.sensor-busca-vazio {
  font-size: 13px;
  color: #b45309;
}

/* Nome do equipamento em destaque; ícone à direita abre o painel técnico */
.sensor-equip-nome {
  font-weight: 700;
  font-size: 15px;
  color: #0f172a;
}
html[data-theme="dark"] .sensor-equip-nome {
  color: #f1f5f9;
}
/* Link para a ficha do equipamento (editar / inactivar) — sublinhado de propósito */
.sensor-equip-nome a.sensor-equip-link {
  color: inherit;
  font-weight: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.sensor-equip-nome a.sensor-equip-link:hover,
.sensor-equip-nome a.sensor-equip-link:focus {
  color: #2563eb;
  outline: none;
}
html[data-theme="dark"] .sensor-equip-nome a.sensor-equip-link:hover,
html[data-theme="dark"] .sensor-equip-nome a.sensor-equip-link:focus {
  color: #93c5fd;
}
.sensor-limites {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  color: #64748b;
}
html[data-theme="dark"] .sensor-limites {
  color: #94a3b8;
}
.sensor-detalhe-col {
  width: 2.5rem;
  white-space: nowrap;
}
.sensor-nome-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 4px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: #94a3b8;
  cursor: pointer;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
}
.sensor-nome-link:hover,
.sensor-nome-link:focus-visible {
  color: #64748b;
  background: #f1f5f9;
  outline: none;
}
.sensor-detalhe-icon {
  display: block;
  width: 16px;
  height: 16px;
}
html[data-theme="dark"] .sensor-nome-link {
  color: #64748b;
}
html[data-theme="dark"] .sensor-nome-link:hover,
html[data-theme="dark"] .sensor-nome-link:focus-visible {
  color: #94a3b8;
  background: #1e293b;
}

.sensor-detalhe-modal .sensor-detalhe-panel {
  max-width: min(520px, calc(100vw - 24px));
}
.sensor-detalhe-equipamento {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.35;
}
.sensor-detalhe-operacional {
  margin: 12px 0 4px;
}
.sensor-detalhe-estado-wrap {
  margin-bottom: 12px;
}
.sensor-detalhe-alerta {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}
html[data-theme="dark"] .sensor-detalhe-alerta {
  background: #431407;
  border-color: #9a3412;
  color: #fed7aa;
}
.sensor-detalhe-medicoes {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}
.sensor-detalhe-medicao-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 2px;
}
.sensor-detalhe-medicao-valor {
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}
.sensor-detalhe-medicao-meta {
  margin-top: 2px;
  font-size: 13px;
}
.sensor-detalhe-lista {
  display: grid;
  grid-template-columns: minmax(110px, 42%) 1fr;
  gap: 8px 14px;
  margin: 8px 0;
  padding: 0;
}
.sensor-detalhe-lista dt {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #64748b;
  line-height: 1.35;
}
.sensor-detalhe-lista dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.35;
  word-break: break-word;
}
.sensor-detalhe-tecnico {
  margin: 12px 0 4px;
  border-top: 1px solid var(--line, #e2e8f0);
  padding-top: 10px;
}
.sensor-detalhe-tecnico summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  list-style: none;
  user-select: none;
}
.sensor-detalhe-tecnico summary::-webkit-details-marker {
  display: none;
}
.sensor-detalhe-tecnico summary::before {
  content: "▸ ";
  color: #94a3b8;
}
.sensor-detalhe-tecnico[open] summary::before {
  content: "▾ ";
}
.sensor-detalhe-tecnico .sensor-detalhe-lista {
  margin-top: 10px;
}
html[data-theme="dark"] .sensor-detalhe-medicao-label,
html[data-theme="dark"] .sensor-detalhe-lista dt {
  color: #94a3b8;
}
html[data-theme="dark"] .sensor-detalhe-medicao-valor,
html[data-theme="dark"] .sensor-detalhe-lista dd {
  color: #e2e8f0;
}
html[data-theme="dark"] .sensor-detalhe-tecnico {
  border-top-color: #334155;
}
html[data-theme="dark"] .sensor-detalhe-tecnico summary {
  color: #cbd5e1;
}
.sensor-detalhe-ip-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.sensor-detalhe-abrir {
  font-size: 12px;
  font-weight: 700;
  color: #0369a1;
  text-decoration: none;
  white-space: nowrap;
}
.sensor-detalhe-abrir:hover,
.sensor-detalhe-abrir:focus-visible {
  text-decoration: underline;
  outline: none;
}
html[data-theme="dark"] .sensor-detalhe-abrir {
  color: #7dd3fc;
}

/* ── Ecrã canónico de bloqueio (plano expirado / funcionalidade acima do plano) ── */
.bloqueio-wrap { max-width: 560px; margin: 40px auto; }
.bloqueio-card { padding: 32px 28px; text-align: center; }
.bloqueio-icon {
  width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #1e3a5f, #14294a);
  box-shadow: 0 6px 18px rgba(20, 41, 74, .22);
}
.bloqueio-icon svg { width: 32px; height: 32px; }
.bloqueio-eyebrow {
  font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.bloqueio-titulo { font-size: 21px; font-weight: 800; margin: 0 0 8px; color: var(--text); line-height: 1.25; }
.bloqueio-texto { color: var(--muted); font-size: 14.5px; margin: 0 auto 20px; max-width: 440px; line-height: 1.55; }
.bloqueio-reassure {
  display: flex; gap: 10px; text-align: left; align-items: flex-start;
  background: var(--ok-bg); border: 1px solid var(--ok-border);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 20px;
}
.bloqueio-reassure svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.bloqueio-reassure p { margin: 0; font-size: 13.5px; color: var(--ok-text); line-height: 1.5; }
.bloqueio-reassure strong { display: block; margin-bottom: 2px; }
.bloqueio-lista { text-align: left; margin: 0 0 22px; padding: 0; list-style: none; }
.bloqueio-lista-titulo {
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); text-align: left; margin-bottom: 8px;
}
.bloqueio-lista li { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; color: var(--text); padding: 5px 0; }
.bloqueio-lista li::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: #94a3b8; flex-shrink: 0; margin-top: 7px;
}
.bloqueio-lista--desbloqueia li::before { background: #16a34a; }
.bloqueio-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.bloqueio-actions .btn { padding: 10px 18px; font-size: 13.5px; }
.bloqueio-nota { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); }
.bloqueio-rodape {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted);
}
.bloqueio-rodape a { color: #1d4ed8; font-weight: 600; text-decoration: none; }
html[data-theme="dark"] .bloqueio-rodape a { color: #93c5fd; }
/* "sair da conta" no rodapé é POST (logout não aceita GET) — botão com aspeto de link */
.bloqueio-inline-form { display: inline; }
.bloqueio-link-btn {
  background: none; border: none; padding: 0; margin: 0; cursor: pointer;
  font: inherit; color: #1d4ed8; font-weight: 600; text-decoration: none;
}
html[data-theme="dark"] .bloqueio-link-btn { color: #93c5fd; }

/* Em tema escuro o .btn primário (#111827) é igual ao --card: o CTA principal desaparecia
   dentro do cartão e o secundário (.btn.soft, #1f2937) ficava mais visível que ele. */
html[data-theme="dark"] .bloqueio-actions .btn:not(.soft) {
  background: #2563eb; border-color: #2563eb; color: #fff;
}

/* —— Arquivo mensal (detalhe): linhas de ficheiro —— */
.arquivo-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.arquivo-card-head .k { margin-bottom: 0; }
.arquivo-count {
  flex-shrink: 0;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.arquivo-manut-resumo { margin: 0 0 10px; font-size: 13px; }

.arquivo-ficheiros {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0 -4px;
}

.arquivo-ficheiro {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}
a.arquivo-ficheiro:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
}
a.arquivo-ficheiro:hover .arquivo-ficheiro-nome { color: #1d4ed8; }
a.arquivo-ficheiro:hover .arquivo-ficheiro-action { color: #1d4ed8; }

.arquivo-ficheiro--static {
  cursor: default;
}
.arquivo-ficheiro--static:hover {
  background: transparent;
  border-color: transparent;
}

.arquivo-ext {
  width: 48px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
  background: #e2e8f0;
  color: #334155;
}
.arquivo-ext--pdf { background: #fee2e2; color: #b91c1c; }
.arquivo-ext--xlsx,
.arquivo-ext--xls { background: #dcfce7; color: #15803d; }
.arquivo-ext--csv { background: #ffedd5; color: #c2410c; }
.arquivo-ext--doc,
.arquivo-ext--docx { background: #dbeafe; color: #1d4ed8; }
.arquivo-ext--png,
.arquivo-ext--jpg,
.arquivo-ext--jpeg,
.arquivo-ext--webp { background: #f3e8ff; color: #7e22ce; }
.arquivo-ext--link { background: #e0e7ff; color: #3730a3; }
.arquivo-ext--manut { background: #ecfeff; color: #0e7490; }
.arquivo-ext--file { background: #e2e8f0; color: #475569; }

.arquivo-ficheiro-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.arquivo-ficheiro-nome {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.arquivo-ficheiro-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.arquivo-ficheiro-size {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
  text-align: right;
  min-width: 4.5rem;
}
.arquivo-ficheiro-action {
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.arquivo-ficheiro-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  grid-column: 3 / -1;
}
.arquivo-mini-link {
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 6px;
  background: #eff6ff;
}
.arquivo-mini-link:hover { text-decoration: underline; background: #dbeafe; }

@media (max-width: 640px) {
  .arquivo-ficheiro {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px 8px;
  }
  .arquivo-ext { width: 44px; height: 34px; font-size: 9px; }
  .arquivo-ficheiro-action { display: none; }
  .arquivo-ficheiro-size { min-width: 0; font-size: 11px; }
  .arquivo-ficheiro-links { grid-column: 2 / -1; justify-content: flex-start; }
}

html[data-theme="dark"] .arquivo-count {
  background: #1e293b;
  color: #94a3b8;
}
html[data-theme="dark"] a.arquivo-ficheiro:hover {
  background: #0f172a;
  border-color: #334155;
}
html[data-theme="dark"] a.arquivo-ficheiro:hover .arquivo-ficheiro-nome,
html[data-theme="dark"] a.arquivo-ficheiro:hover .arquivo-ficheiro-action {
  color: #93c5fd;
}
html[data-theme="dark"] .arquivo-ext--pdf { background: #450a0a; color: #fca5a5; }
html[data-theme="dark"] .arquivo-ext--xlsx,
html[data-theme="dark"] .arquivo-ext--xls { background: #052e16; color: #86efac; }
html[data-theme="dark"] .arquivo-ext--csv { background: #431407; color: #fdba74; }
html[data-theme="dark"] .arquivo-ext--doc,
html[data-theme="dark"] .arquivo-ext--docx { background: #172554; color: #93c5fd; }
html[data-theme="dark"] .arquivo-ext--link { background: #1e1b4b; color: #a5b4fc; }
html[data-theme="dark"] .arquivo-ext--manut { background: #083344; color: #67e8f9; }
html[data-theme="dark"] .arquivo-ext--file { background: #1e293b; color: #94a3b8; }
html[data-theme="dark"] .arquivo-mini-link {
  background: #1e3a5f;
  color: #93c5fd;
}
html[data-theme="dark"] .arquivo-mini-link:hover { background: #1e40af; }

/* #218 — estado visual dos cartões «A app» e «Notificações push» */
.cc-device-status {
  display: block;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 600;
  min-height: 2.5em;
  max-width: 100%;
  box-sizing: border-box;
  word-break: break-word;
}
.cc-device-status--ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-text);
}
.cc-device-status--bad {
  background: var(--bad-bg);
  border-color: var(--bad-border);
  color: var(--bad-text);
}
.cc-device-status--warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}
.cc-device-status--neutral {
  background: var(--soft);
  border-color: var(--line);
  color: var(--muted);
  font-weight: 500;
}
.cc-device-status-meta {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

/* Caixa de entrada (#220/#221) — identidade teal (≠ vermelho crítico, ≠ azul IA) */
.caixa-entrada-home-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  box-sizing: border-box;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid #0d9488;
  background: linear-gradient(145deg, rgba(240, 253, 250, 0.98), rgba(248, 250, 252, 0.98));
  margin-bottom: 0;
  min-height: 64px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.caixa-entrada-home-card:hover {
  border-color: #0f766e;
  box-shadow: 0 2px 10px rgba(13, 148, 136, 0.18);
}
.caixa-entrada-home-card__main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.caixa-entrada-home-card__icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}
.caixa-entrada-home-card__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.caixa-entrada-home-card__title {
  font-size: 18px;
  font-weight: 800;
  color: #0f766e;
  line-height: 1.2;
}
.caixa-entrada-home-card__sub {
  font-size: 13px;
  font-weight: 600;
  color: #115e59;
  opacity: 0.85;
}
.caixa-entrada-home-card__pill {
  background: rgba(13, 148, 136, 0.16);
  color: #0f766e;
  font-weight: 800;
  flex-shrink: 0;
}
html[data-theme="dark"] .caixa-entrada-home-card {
  background: linear-gradient(145deg, rgba(19, 78, 74, 0.35), rgba(15, 23, 42, 0.9));
  border-color: #14b8a6;
}
html[data-theme="dark"] .caixa-entrada-home-card__title {
  color: #5eead4;
}
html[data-theme="dark"] .caixa-entrada-home-card__sub {
  color: #99f6e4;
}
html[data-theme="dark"] .caixa-entrada-home-card__pill {
  background: rgba(20, 184, 166, 0.22);
  color: #5eead4;
}

.caixa-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.caixa-tabs__tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  background: var(--soft);
}
.caixa-tabs__tab.is-active {
  background: #0f766e;
  color: #fff;
  border-color: #0f766e;
}
.caixa-tabs__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4em;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.22);
}
.caixa-tabs__tab:not(.is-active) .caixa-tabs__count {
  background: rgba(13, 148, 136, 0.14);
  color: #0f766e;
}

.caixa-empty {
  padding: 28px 20px;
  text-align: center;
}
.caixa-empty__title {
  font-weight: 800;
  margin: 0 0 6px;
}

.caixa-doc-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.caixa-doc-card {
  padding: 16px 18px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  border-left: 4px solid #0d9488;
}
.caixa-doc-card__header {
  margin-bottom: 12px;
}
.caixa-doc-card__title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.caixa-doc-card__filename {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
  word-break: break-word;
}
.caixa-doc-card__meta {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 0;
  align-items: baseline;
}
.caixa-doc-card__dot {
  margin: 0 4px;
  opacity: 0.6;
}
.caixa-doc-card__type {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(13, 148, 136, 0.12);
  color: #0f766e;
}
.caixa-doc-card__sugestao {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  padding: 10px 12px;
  margin-bottom: 14px;
  border-radius: 10px;
  background: rgba(13, 148, 136, 0.08);
  border: 1px solid rgba(13, 148, 136, 0.22);
}
.caixa-doc-card__sugestao-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #0f766e;
}
.caixa-doc-card__sugestao-text {
  font-size: 13px;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.caixa-enviar-form {
  margin: 0;
}
.caixa-enviar-form__legend {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Chips alinhados (substitui bolas/radio desalinhados) */
.caixa-destino-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.caixa-destino-chip {
  position: relative;
  margin: 0;
  cursor: pointer;
  display: block;
}
.caixa-destino-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.caixa-destino-chip__face {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--card, #fff);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  color: var(--text);
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.caixa-destino-chip:hover .caixa-destino-chip__face {
  border-color: #99f6e4;
  background: rgba(13, 148, 136, 0.06);
}
.caixa-destino-chip input:checked + .caixa-destino-chip__face,
.caixa-destino-chip:has(input:checked) .caixa-destino-chip__face {
  border-color: #0d9488;
  background: rgba(13, 148, 136, 0.14);
  box-shadow: inset 0 0 0 1px #0d9488;
  color: #0f766e;
}
.caixa-destino-chip input:focus-visible + .caixa-destino-chip__face {
  outline: 2px solid #0d9488;
  outline-offset: 2px;
}

.caixa-destino-panel {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--soft);
  border: 1px solid var(--line);
}
.caixa-destino-panel[hidden] {
  display: none !important;
}
.caixa-field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.caixa-hint {
  font-size: 12px;
  margin: 0;
}

.caixa-doc-card__cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
  margin-top: 14px;
}
.caixa-doc-card__cta-row > .btn,
.caixa-doc-card__cta-row .caixa-discard-form {
  flex: 1 1 140px;
  margin: 0;
}
.caixa-doc-card__cta-row > .btn,
.caixa-discard-form .btn {
  width: 100%;
  min-height: 44px;
}

/* Preview só sob pedido — evita o rectângulo vazio gigante */
.caixa-doc-preview-fold {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.caixa-doc-preview-fold > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #0f766e;
}
.caixa-doc-preview-fold > summary::-webkit-details-marker {
  display: none;
}
.caixa-doc-preview-fold__open {
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}
.caixa-doc-preview-fold__open:hover {
  color: #0f766e;
  text-decoration: underline;
}
.caixa-doc-preview-fold__body {
  margin-top: 10px;
}
.caixa-doc-preview__frame {
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
}
.caixa-doc-preview__img-link {
  display: block;
}
.caixa-doc-preview__img {
  max-width: 100%;
  max-height: 360px;
  border-radius: 10px;
  display: block;
}
.caixa-doc-card__excerto {
  margin-top: 10px;
}
.caixa-doc-card__excerto > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.caixa-doc-excerto {
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0 0;
}

.caixa-remetente-grupo__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.caixa-remetente-grupo__email {
  font-size: 15px;
}
.caixa-remetente-grupo .caixa-doc-list {
  gap: 12px;
}

/* #226 — emails sem docs / histórico: mesmos cartões teal que Por validar */
.caixa-emails-sem-docs {
  margin-bottom: 24px;
}
.caixa-emails-sem-docs__head {
  margin-bottom: 12px;
}
.caixa-section-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #0f766e;
}
.caixa-emails-sem-docs__hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}
.caixa-hist-docs-title {
  margin: 8px 0 12px;
}
.caixa-email-sem-doc .caixa-doc-card__header {
  margin-bottom: 0;
}
.caixa-email-sem-doc .caixa-doc-preview-fold {
  margin-top: 12px;
}
.caixa-email-excerto__body {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(13, 148, 136, 0.06);
  border: 1px solid rgba(13, 148, 136, 0.18);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow: auto;
}
.caixa-hist-doc .caixa-doc-card__header {
  margin-bottom: 0;
}

/* #226 — Definições: endereço + confirmação Gmail */
.caixa-endereco-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
  margin-top: 8px;
}
.caixa-endereco-row__code {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--soft, #f8fafc);
  font-size: 13px;
  line-height: 1.3;
  word-break: break-all;
}
.caixa-endereco-row .btn {
  align-self: center;
  flex-shrink: 0;
}
.caixa-gmail-forward {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(13, 148, 136, 0.28);
  border-left: 4px solid #0d9488;
  background: linear-gradient(145deg, rgba(240, 253, 250, 0.95), rgba(248, 250, 252, 0.98));
}
.caixa-gmail-forward__badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(13, 148, 136, 0.14);
  color: #0f766e;
  margin-bottom: 8px;
}
.caixa-gmail-forward__title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 800;
  color: #0f766e;
  line-height: 1.25;
}
.caixa-gmail-forward__meta {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.4;
}
.caixa-gmail-forward__excerto {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(13, 148, 136, 0.2);
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
}
.caixa-entrada-card__actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.caixa-entrada-card__rodar {
  display: inline;
  margin: 0;
}

html[data-theme="dark"] .caixa-section-title {
  color: #5eead4;
}
html[data-theme="dark"] .caixa-email-excerto__body {
  background: rgba(20, 184, 166, 0.12);
  border-color: rgba(20, 184, 166, 0.28);
}
html[data-theme="dark"] .caixa-endereco-row__code {
  background: rgba(15, 23, 42, 0.6);
}
html[data-theme="dark"] .caixa-gmail-forward {
  background: linear-gradient(145deg, rgba(19, 78, 74, 0.35), rgba(15, 23, 42, 0.9));
  border-color: rgba(20, 184, 166, 0.35);
  border-left-color: #14b8a6;
}
html[data-theme="dark"] .caixa-gmail-forward__badge {
  background: rgba(20, 184, 166, 0.22);
  color: #5eead4;
}
html[data-theme="dark"] .caixa-gmail-forward__title {
  color: #5eead4;
}
html[data-theme="dark"] .caixa-gmail-forward__excerto {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(20, 184, 166, 0.28);
}

@media (max-width: 820px) {
  .caixa-destino-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 520px) {
  .caixa-destino-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .caixa-doc-preview__frame {
    min-height: 220px;
  }
}

html[data-theme="dark"] .caixa-doc-card {
  border-left-color: #14b8a6;
}
html[data-theme="dark"] .caixa-doc-card__type {
  background: rgba(20, 184, 166, 0.2);
  color: #5eead4;
}
html[data-theme="dark"] .caixa-doc-card__sugestao {
  background: rgba(20, 184, 166, 0.12);
  border-color: rgba(20, 184, 166, 0.35);
}
html[data-theme="dark"] .caixa-doc-card__sugestao-label {
  color: #5eead4;
}
html[data-theme="dark"] .caixa-tabs__tab.is-active {
  background: #0d9488;
  border-color: #0d9488;
}
html[data-theme="dark"] .caixa-destino-chip__face {
  background: rgba(15, 23, 42, 0.55);
}
html[data-theme="dark"] .caixa-destino-chip input:checked + .caixa-destino-chip__face,
html[data-theme="dark"] .caixa-destino-chip:has(input:checked) .caixa-destino-chip__face {
  background: rgba(20, 184, 166, 0.2);
  border-color: #14b8a6;
  box-shadow: inset 0 0 0 1px #14b8a6;
  color: #5eead4;
}
html[data-theme="dark"] .caixa-doc-preview-fold > summary {
  color: #5eead4;
}

/* Caixa de entrada — enviar/descartar todos */
.caixa-bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.caixa-bulk__form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0;
}
.caixa-doc-card.is-escolhido {
  border-left: 4px solid var(--ok, #16a34a);
}

/* #234 — seletor de módulos */
/* Fixo no topo da sidebar: fica à vista quando o menu faz scroll (.sidebar-nav).
   Fundo opaco aproximado ao degradé da sidebar nesta altura, para o menu não
   aparecer por trás. */
.mod-seletor {
  position: sticky;
  top: 0;
  z-index: 31;
  margin: 0;
  padding: 0.3rem 0.65rem 0.5rem;
  background: color-mix(in srgb, var(--sidebar-grad-top) 65%, var(--sidebar-grad-mid));
}
.mod-seletor-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 38px;
  padding: 0.4rem 0.65rem;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--mod-accent, #0284c7) 45%, #cbd5e1);
  background: color-mix(in srgb, var(--mod-accent, #0284c7) 12%, #fff);
  color: inherit;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 650;
  cursor: pointer;
  text-align: left;
}
.mod-seletor-trigger[aria-disabled="true"] {
  cursor: default;
}
.mod-seletor-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--mod-accent, #0284c7);
  flex: 0 0 auto;
}
.mod-seletor-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mod-seletor-chevron {
  opacity: 0.7;
  display: inline-flex;
}
.mod-seletor-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0.35rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  z-index: 30;
  position: absolute;
  left: 0.65rem;
  right: 0.65rem;
}
.mod-seletor-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  font-weight: 550;
}
.mod-seletor-option:hover,
.mod-seletor-option:focus-visible {
  background: color-mix(in srgb, var(--mod-accent, #0284c7) 14%, #f8fafc);
  outline: none;
}
.mod-seletor-option.is-current {
  background: color-mix(in srgb, var(--mod-accent, #0284c7) 18%, #fff);
  font-weight: 700;
}
/* #311: sem traço extra em Sistema (Equipa no rodapé). */
.sidebar-section-sistema {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* ——— #311 Sidebar grupos distintos ——— */
.sidebar-nav-loose {
  padding: 2px 8px 4px;
}

.sidebar-nav-group {
  padding: 4px 8px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-nav-group:last-child {
  border-bottom: none;
}

.sidebar-nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  margin: 0;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.sidebar-nav-group-toggle:hover,
.sidebar-nav-group-toggle:focus-visible {
  background: var(--sidebar-hover);
  outline: none;
}

.sidebar-nav-group-icon {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
}

.sidebar-nav-group-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.sidebar-nav-group-title.sidebar-section-label {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: rgba(255, 255, 255, 0.88);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav-group-badge {
  flex-shrink: 0;
  min-width: 1.35rem;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  background: color-mix(in srgb, var(--mod-accent, #0284c7) 85%, #fff);
  color: #fff;
}

.sidebar-nav-group-chevron {
  flex-shrink: 0;
  display: inline-flex;
  opacity: 0.7;
  transition: transform 0.15s ease;
}

.sidebar-nav-group-toggle[aria-expanded="true"] .sidebar-nav-group-chevron {
  transform: rotate(180deg);
}

.sidebar-nav-group-items {
  margin: 2px 0 4px 13px;
  padding: 2px 0 2px 10px;
  border-left: 2px solid rgba(255, 255, 255, 0.14);
}

.sidebar-nav-group-items .nav-item {
  padding-left: 10px;
}

.sidebar-nav-group.is-active .sidebar-nav-group-icon {
  background: var(--mod-accent, #0284c7);
  color: #fff;
}

.sidebar-nav-group.is-active .sidebar-nav-group-items {
  border-left-color: var(--mod-accent, #0284c7);
}

.sidebar-nav-group.is-active .nav-item.active,
.sidebar-nav .nav-item.active {
  background: color-mix(in srgb, var(--mod-accent, #0284c7) 16%, transparent);
  color: #fff;
  font-weight: 600;
  box-shadow: none;
}

/* Colapso só com JS disponível — sem JS tudo fica aberto (#311). */
@media (scripting: enabled) {
  .sidebar-nav[data-nav-collapse="1"] .sidebar-nav-group:not(.is-open):not(:has(.nav-item.active)) > .sidebar-nav-group-items {
    display: none;
  }
}

.sidebar-nav-group:has(.nav-item.active) .sidebar-nav-group-icon {
  background: var(--mod-accent, #0284c7);
  color: #fff;
}

.sidebar-nav-group:has(.nav-item.active) .sidebar-nav-group-items {
  border-left-color: var(--mod-accent, #0284c7);
}
html[data-theme="dark"] .mod-seletor-trigger {
  background: color-mix(in srgb, var(--mod-accent, #0284c7) 32%, #1e293b);
  border-color: color-mix(in srgb, var(--mod-accent, #0284c7) 70%, #94a3b8);
  color: #f8fafc;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--mod-accent, #0284c7) 35%, transparent),
    0 6px 16px rgba(0, 0, 0, 0.35);
}
html[data-theme="dark"] .mod-seletor-label {
  color: #f8fafc;
}
html[data-theme="dark"] .mod-seletor-chevron {
  opacity: 0.9;
  color: #e2e8f0;
}
html[data-theme="dark"] .mod-seletor-list {
  background: #1e293b;
  border-color: #64748b;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.55);
}
html[data-theme="dark"] .mod-seletor-option {
  color: #f1f5f9;
}
html[data-theme="dark"] .mod-seletor-option:hover,
html[data-theme="dark"] .mod-seletor-option:focus-visible,
html[data-theme="dark"] .mod-seletor-option.is-current {
  background: color-mix(in srgb, var(--mod-accent, #0284c7) 36%, #0f172a);
  color: #ffffff;
}
/* Dashboard — alertas / inspeção sem branco fixo no escuro */
html[data-theme="dark"] .alert-panel,
html[data-theme="dark"] .alert-critical {
  background: var(--card);
  border-color: var(--line);
}
html[data-theme="dark"] .alert-panel-shell {
  background: rgba(127, 29, 29, 0.28);
  border-color: #ef4444;
}
html[data-theme="dark"] .alert-panel-title {
  color: #fca5a5;
}
html[data-theme="dark"] .alert-panel--info {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(148, 163, 184, 0.35);
}
html[data-theme="dark"] .alert-panel-info-inner {
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(148, 163, 184, 0.35);
}
html[data-theme="dark"] .alert-panel-drilldown--info > .alert-panel-title,
html[data-theme="dark"] .alert-panel--info .alert-item-main {
  color: #e2e8f0;
}
html[data-theme="dark"] .pill--info {
  background: rgba(148, 163, 184, 0.25);
  color: #e2e8f0;
}
html[data-theme="dark"] .alert-panel-kicker {
  color: #94a3b8;
}
html[data-theme="dark"] .dashboard-inspecao-semaforo {
  background: var(--soft);
  border-color: var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
html[data-theme="dark"] .kpi-detail,
html[data-theme="dark"] .kpi-period-tile .muted,
html[data-theme="dark"] .kpi-period-tile small {
  color: #cbd5e1;
}

/* ── Secções de definições (#296 ORGANIZAÇÃO 1/2) ─────────────────────
   Padrão alinhado a conforme-reservas `.definicoes-seccao` (e77ccb5).
   Só aspecto: títulos fortes, espaço entre cards, subsecções sem caixa. */
:root {
  --defs-cor: #14294a; /* navy Conforme — fallback sem módulo */
}

.defs-card {
  margin-top: 22px;
  padding: 18px 18px 20px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.07);
}

.row .defs-card {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}

.row.defs-card-row {
  gap: 22px; /* #296: ≥20px entre cards também na row */
  margin-top: 22px;
}

.defs-card__titulo {
  margin: 0 0 6px;
  padding-left: 10px;
  border-left: 4px solid var(--defs-cor, #14294a);
  color: #0f172a;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.25;
}

.defs-card__desc {
  margin: 0 0 10px 14px;
  max-width: 42rem;
  color: var(--muted, #64748b);
  font-size: 14px;
  line-height: 1.45;
}

.defs-sub {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line, #e2e8f0);
}

.defs-sub:first-of-type,
.func-sensores-settings > .defs-sub:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.defs-sub__titulo {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #334155;
}

.defs-sub-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
}

.defs-sub-row > .defs-sub {
  flex: 1;
  min-width: 260px;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  border-left: 1px solid var(--line, #e2e8f0);
  padding-left: 16px;
}

.defs-sub-row > .defs-sub:first-child {
  border-left: none;
  padding-left: 0;
}

html[data-theme="dark"] .defs-card {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

html[data-theme="dark"] .defs-card__titulo {
  color: #f1f5f9;
}

html[data-theme="dark"] .defs-card__desc {
  color: #94a3b8;
}

html[data-theme="dark"] .defs-sub {
  border-top-color: rgba(255, 255, 255, 0.1);
}

/* Avisos legais da carta (#347) — subsecção do cartão «Página do restaurante» */
.avisos-legais {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line, #e2e8f0);
}

.avisos-legais__langs {
  display: flex;
  gap: 6px;
  margin: 4px 0 8px;
}

.avisos-legais__langs .btn {
  min-width: 52px;
}

.avisos-legais__langs .btn.is-active {
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
}

.avisos-legais__nota {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted, #64748b);
}

.avisos-legais__painel .field {
  margin-bottom: 14px;
}

.avisos-legais__painel .field label {
  display: block;
  margin-bottom: 4px;
}

.avisos-legais__painel .btn.ghost {
  display: inline-block;
  margin-top: 4px;
  padding: 8px 0;
  min-height: 36px;
  background: none;
  border: none;
  box-shadow: none;
  color: var(--brand, #1d4ed8);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
}

.avisos-legais__langs .btn.is-erro::after {
  content: " •";
  color: #dc2626;
}

html[data-theme="dark"] .avisos-legais__langs .btn.is-active {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #e2e8f0;
}

html[data-theme="dark"] .avisos-legais__painel .btn.ghost {
  color: #93c5fd;
}

html[data-theme="dark"] .defs-sub__titulo {
  color: #cbd5e1;
}

html[data-theme="dark"] .defs-sub-row > .defs-sub {
  border-left-color: rgba(255, 255, 255, 0.1);
}

@media (max-width: 720px) {
  .defs-sub-row > .defs-sub {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--line, #e2e8f0);
    padding-top: 14px;
  }
  .defs-sub-row > .defs-sub:first-child {
    border-top: none;
    padding-top: 0;
  }
  html[data-theme="dark"] .defs-sub-row > .defs-sub {
    border-top-color: rgba(255, 255, 255, 0.1);
  }
}
