/* ==========================================================================
   CBSYNC PORTAL – Interface nova: sidebar, hub, identidade própria
   ========================================================================== */

:root {
  /* Alinhado à app CBSYNC BOMBEIROS: bombeiros (vermelho) + quartel (slate) – client/tailwind.config.js */
  --bombeiros-50: #fef2f2;
  --bombeiros-100: #fee2e2;
  --bombeiros-200: #fecaca;
  --bombeiros-500: #ef4444;
  --bombeiros-600: #dc2626;
  --bombeiros-700: #b91c1c;
  --bombeiros-800: #991b1b;
  --quartel-800: #1e293b;
  --quartel-900: #0f172a;
  --quartel-950: #020617;
  --bg-dark: #0f172a;
  --bg-dark-2: #1e293b;
  --bg-dark-3: #334155;
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --text-dark: #f1f5f9;
  --text-muted-dark: #94a3b8;
  --text: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent: #dc2626;
  --accent-hover: #b91c1c;
  --accent-soft: #fef2f2;
  --accent-muted: #fecaca;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --red-soft: #fef2f2;
  --red-text: #991b1b;
  --amber-soft: #fffbeb;
  --amber-text: #b45309;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 1.75rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --radius: 0.5rem;
  --radius-md: 0.625rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --touch: 44px;
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --header-h: 3.25rem;
  --nav-bottom-h: 5rem;
}

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

html {
  -webkit-text-size-adjust: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 0;
  width: 100%;
  overflow-x: hidden;
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

/* Ocultar scrollbar no smartphone para não interferir com cabeçalho/barra fixos */
@media (max-width: 767px) {
  html,
  body {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  html::-webkit-scrollbar,
  body::-webkit-scrollbar {
    display: none;
  }
}

img { max-width: 100%; height: auto; vertical-align: middle; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ========== LOGIN – Tema branco + vermelho, degradê suave ========== */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--bg-page);
  background-image: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-subtle) 30%, var(--bombeiros-50) 100%);
}

.login-page > .card.login-card {
  align-self: center;
  justify-self: center;
}

@media (min-width: 768px) {
  .login-page {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.login-page .login-visual {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  background: linear-gradient(160deg, var(--bg-subtle) 0%, var(--bombeiros-50) 50%, var(--bombeiros-100) 100%);
  padding: var(--space-10);
}

@media (min-width: 768px) {
  .login-page .login-visual {
    display: flex;
  }
}

.login-visual-logo {
  max-height: 4rem;
  width: auto;
  opacity: 0.95;
}

.login-page .login-form-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  padding-left: max(var(--space-6), env(safe-area-inset-left));
  padding-right: max(var(--space-6), env(safe-area-inset-right));
  padding-bottom: max(var(--space-6), env(safe-area-inset-bottom));
}

/* Logo no topo do formulário: só em mobile (em PC o logo está na coluna esquerda) */
.login-form-logo {
  display: block;
  max-height: 3rem;
  width: auto;
  margin: 0 auto var(--space-4);
}
@media (min-width: 768px) {
  .login-form-logo { display: none !important; }
}

.login-tagline {
  font-size: 1rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 var(--space-5);
  line-height: 1.45;
  max-width: 22rem;
}

.login-page .card.login-card {
  width: 100%;
  max-width: 22rem;
  padding: var(--space-10) var(--space-8);
  border-radius: var(--radius-xl);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
}

.login-page .logo {
  display: block;
  max-height: 3rem;
  width: auto;
  margin: 0 auto var(--space-5);
}

.login-page .sub {
  font-size: 0.9375rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 var(--space-6);
  line-height: 1.45;
}

.login-page label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.login-page input[type="text"],
.login-page input[type="password"] {
  width: 100%;
  min-height: var(--touch);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: var(--space-4);
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.login-page input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-page .btn-primary {
  width: 100%;
  min-height: var(--touch);
  margin-top: var(--space-2);
  padding: var(--space-4);
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius);
}

.login-page .erro {
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--red-soft);
  color: var(--red-text);
}

.login-page .hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  margin: var(--space-6) 0 0;
  line-height: 1.5;
}

.login-page .modal-buttons {
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-5);
}
.login-page .modal-buttons .btn { min-width: 0; flex: 1 1 auto; }

/* ========== BOTÕES ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  font-family: inherit;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.1s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.98); }

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

.btn-outline {
  border: 1.5px solid var(--border);
  color: var(--text);
  background: var(--bg-card);
}
.btn-outline:hover {
  border-color: var(--text-muted);
  background: var(--bg-page);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }

.portal-body .btn-ghost { color: var(--text-secondary); }
.portal-body .btn-ghost:hover { background: var(--accent-soft); color: var(--accent); }

.btn-icon {
  min-width: var(--touch);
  min-height: var(--touch);
  padding: var(--space-2);
  border-radius: var(--radius);
}
.btn-icon svg { flex-shrink: 0; }

.btn-logout { font-weight: 500; }

/* ========== HEADER – Branco + vermelho (tema app), fixo no mobile ========== */
.portal-body .portal-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  color: var(--text);
  padding: var(--space-3) var(--space-4);
  padding-left: max(var(--space-4), env(safe-area-inset-left));
  padding-right: max(var(--space-4), env(safe-area-inset-right));
  padding-top: max(var(--space-3), env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.portal-body .portal-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}

.portal-header .logo {
  height: 1.75rem;
  width: auto;
  margin: 0;
  flex-shrink: 0;
  display: block;
  position: relative;
  z-index: 1;
}

@media (min-width: 480px) {
  .portal-header .logo { height: 2rem; }
}

.header-actions { display: flex; align-items: center; gap: var(--space-2); position: relative; z-index: 1; }

/* Ocultar botão Instalar quando a app já está instalada (aberta em standalone) */
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  #btn-instalar { display: none !important; }
}
.portal-body.portal-instalado #btn-instalar { display: none !important; }

/* Mobile: cabeçalho sempre fixo (estilo app) */
@media (max-width: 767px) {
  .portal-body .portal-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
  }
}

/* ========== LAYOUT APP – Sidebar (desktop) / Bottom nav (mobile), tema branco+vermelho ========== */
.app-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

@media (min-width: 768px) {
  .app-body {
    flex-direction: row;
    min-height: 100vh;
  }
}

/* Barra de navegação: fundo branco, vermelho no ativo (pormenores em azul escuro evitados) */
.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: var(--bg-card);
  color: var(--text);
  border-top: 1px solid var(--border);
  padding: var(--space-2);
  padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
  justify-content: center;
  order: 2;
  box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.04);
}

/* Mobile: barra inferior sempre fixa (estilo app) */
@media (max-width: 767px) {
  .app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    order: unset;
  }
}

@media (min-width: 768px) {
  .app-nav {
    position: relative;
    flex-direction: column;
    width: 12rem;
    min-width: 12rem;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: var(--space-4) var(--space-2);
    padding-bottom: var(--space-4);
    justify-content: flex-start;
    order: 0;
    align-items: stretch;
    box-shadow: none;
  }
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
  flex: 1;
  min-width: 0;
}

@media (min-width: 768px) {
  .nav-item {
    justify-content: flex-start;
    padding: var(--space-3) var(--space-4);
    font-size: 0.875rem;
    flex: none;
  }
}

.nav-item:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active .nav-icon { color: var(--accent); }

@media (min-width: 768px) {
  .nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 1.5rem;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
  }
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  color: currentColor;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

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

@media (max-width: 767px) {
  .nav-label { display: none; }
  .nav-item { flex-direction: column; gap: var(--space-1); }
  .nav-icon { width: 1.5rem; height: 1.5rem; }
}

.app-main {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
}

.app-content {
  padding: var(--space-4);
  padding-left: max(var(--space-4), env(safe-area-inset-left));
  padding-right: max(var(--space-4), env(safe-area-inset-right));
  padding-bottom: max(var(--space-8), env(safe-area-inset-bottom));
}

/* Mobile: espaço para cabeçalho e barra fixos (estilo app) */
@media (max-width: 767px) {
  .app-main {
    padding-top: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  }
  .app-content {
    padding-bottom: calc(var(--nav-bottom-h) + env(safe-area-inset-bottom, 0px));
  }
}

@media (min-width: 360px) {
  .app-content { padding-left: var(--space-5); padding-right: var(--space-5); }
}

@media (min-width: 768px) {
  .app-main { padding-top: 0; }
  .app-content {
    padding: var(--space-6);
    padding-bottom: var(--space-10);
    max-width: 56rem;
    margin: 0 auto;
  }
}

.card:not(.login-card) {
  padding: 0;
  border-radius: var(--radius-xl);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

/* ========== PERFIL – Header com nome, info e fotografia ========== */
.profile-hero {
  padding: var(--space-6) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

@media (min-width: 480px) {
  .profile-hero { padding: var(--space-7) var(--space-6); }
}

.profile {
  display: flex;
  gap: var(--space-5);
  align-items: center;
}

.avatar {
  width: 4rem;
  height: 4rem;
  min-width: 4rem;
  min-height: 4rem;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  font-weight: 600;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--border);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

@media (min-width: 480px) {
  .avatar {
    width: 5.25rem;
    height: 5.25rem;
    min-width: 5.25rem;
    min-height: 5.25rem;
    font-size: 1.375rem;
  }
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }

.profile-avatar-divisa {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.portal-divisa {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.portal-divisa .portal-divisa-svg { display: block; vertical-align: middle; }

.profile-info { min-width: 0; flex: 1; }

.profile-info .profile-nome,
.profile-info h1.profile-nome {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
  line-height: 1.3;
  word-break: break-word;
}

@media (min-width: 480px) {
  .profile-info .profile-nome,
  .profile-info h1.profile-nome { font-size: 1.375rem; }
}

.profile-meta-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
}

.profile-info .meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
}

/* Badge do quadro (Ativo/Inativo) – integrado, discreto */
.badge-quadro.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.125rem var(--space-2);
  border-radius: var(--radius);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0;
  flex-shrink: 0;
}

.badge-quadro.badge::before {
  content: '';
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-quadro.badge-ativo {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border: 1px solid var(--accent-muted);
}

.badge-quadro.badge-ativo::before {
  background: var(--accent);
}

.badge-quadro.badge-inativo {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-quadro.badge-inativo::before {
  background: var(--text-muted);
}

/* Outros badges (fardamento, etc.) mantêm estilo anterior */
.badge:not(.badge-quadro) {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: var(--space-3);
}

.badge-ativo:not(.badge-quadro) {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border: 1px solid var(--accent-muted);
}

.badge-inativo:not(.badge-quadro) {
  background: var(--bg-page);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-amber {
  background: var(--amber-soft);
  color: var(--amber-text);
  border: 1px solid #fde68a;
}

.badge-info {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
}

.badge-danger {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.badge-success {
  background: #d1fae5;
  color: #047857;
  border: 1px solid #6ee7b7;
}

/* Tabela no portal (ex.: histórico pedidos troca fardamento) */
.tabela-portal {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.tabela-portal th,
.tabela-portal td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.tabela-portal th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tabela-portal tbody tr:hover {
  background: var(--bg-page);
}

/* Botão e modal do histórico de pedidos (fardamento) */
.farda-acao-historico {
  margin-bottom: var(--space-5);
}

.farda-acao-historico .btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.farda-acao-historico .btn-icon {
  flex-shrink: 0;
}

.farda-acao-historico .historico-count {
  margin-left: var(--space-1);
}

/* Modal histórico de pedidos: mais largo e com área scrollável */
.modal-historico-pedidos.modal-card {
  max-width: 42rem;
  max-height: min(90vh, 90dvh);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.modal-historico-pedidos .modal-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5) 0;
  flex-shrink: 0;
}

.modal-historico-pedidos .modal-titulo {
  margin: 0;
}

.modal-historico-pedidos .modal-fechar {
  flex-shrink: 0;
  padding: var(--space-1);
  margin: calc(-1 * var(--space-1));
  border-radius: var(--radius);
  color: var(--text-muted);
}

.modal-historico-pedidos .modal-fechar:hover {
  background: var(--bg-page);
  color: var(--text);
}

.modal-historico-pedidos .modal-desc {
  padding: 0 var(--space-5);
  margin: var(--space-2) 0 var(--space-4);
}

.modal-historico-pedidos .historico-empty {
  padding: var(--space-6) var(--space-5);
}

.modal-historico-pedidos .historico-pedidos-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 var(--space-5) var(--space-5);
  -webkit-overflow-scrolling: touch;
}

.modal-historico-pedidos .historico-pedidos-tabela {
  padding-bottom: var(--space-2);
}

.modal-historico-pedidos .tabela-portal th,
.modal-historico-pedidos .tabela-portal td {
  padding: var(--space-2) var(--space-3);
}

/* Lista em cards (visível só em ecrãs pequenos) */
.historico-pedidos-lista {
  display: none;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: var(--space-3);
}

.historico-pedido-card {
  padding: var(--space-4);
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.historico-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.historico-card-data {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.historico-card-peca {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text);
  margin: 0 0 var(--space-2);
}

.historico-card-motivo {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.45;
}

@media (max-width: 560px) {
  .historico-pedidos-tabela {
    display: none !important;
  }

  .historico-pedidos-lista {
    display: flex;
    flex-direction: column;
  }
}

/* Em ecrãs muito pequenos, garantir que o modal não fica cortado */
@media (max-width: 380px) {
  .modal-historico-pedidos.modal-card {
    max-height: 85vh;
    max-height: 85dvh;
  }
}

.mt-6 { margin-top: var(--space-6); }

/* ========== HUB – Ecrã inicial com 4 cartões ========== */
.hub {
  padding: var(--space-8) var(--space-5);
}

.hub-intro {
  font-size: 0.9375rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 var(--space-6);
  line-height: 1.5;
}

.hub-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

@media (min-width: 360px) {
  .hub-grid { gap: var(--space-4); }
}

@media (min-width: 480px) {
  .hub-grid { gap: var(--space-5); }
}

.hub-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-6) var(--space-4);
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
  min-height: var(--touch);
}

.hub-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.12);
  transform: translateY(-2px);
}

.hub-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-bottom: var(--space-3);
  color: var(--accent);
}

.hub-card-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.hub-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  display: block;
  margin-bottom: var(--space-1);
}

.hub-card-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* ========== FICHA – Conteúdo das secções ========== */
.back-link {
  display: inline-block;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: var(--space-5);
  transition: color 0.2s var(--ease);
}

.back-link:hover { color: var(--accent); }

.ficha-content {
  padding: var(--space-5);
}

@media (min-width: 360px) {
  .ficha-content { padding: var(--space-5) var(--space-6); }
}

@media (min-width: 600px) {
  .ficha-content { padding: var(--space-6); }
}

.dados-secao {
  margin-bottom: var(--space-6);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.dados-secao:last-child { margin-bottom: 0; }

.secao-titulo {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.secao-titulo::before {
  content: '';
  width: 3px;
  height: 0.875rem;
  border-radius: 2px;
  background: var(--accent);
}

.dados-secao dl {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
  margin: 0;
}

@media (min-width: 480px) {
  .dados-secao dl { grid-template-columns: repeat(2, 1fr); }
}

.dado-row { display: flex; flex-direction: column; gap: var(--space-1); }

.dado-row dt {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin: 0;
}

.dado-row dd {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
  line-height: 1.45;
}

.observacoes-texto {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.texto-secundario { color: var(--text-muted); font-size: 0.9375rem; }
.mb-4 { margin-bottom: var(--space-4); }
.full-width { width: 100%; box-sizing: border-box; }

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-4);
  opacity: 0.5;
  display: block;
}

/* ========== DOCUMENTOS – Lista profissional e responsiva ========== */
.doc-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

@media (min-width: 600px) {
  .doc-list { gap: var(--space-2); }
}

.doc-item:not(.farda-item) {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: var(--space-3) var(--space-4);
  align-items: center;
  padding: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  min-height: var(--touch);
}

.doc-item:not(.farda-item):hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.doc-item:not(.farda-item) > div {
  grid-column: 1;
  min-width: 0;
}

.doc-item:not(.farda-item) .doc-tipo {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--bg-subtle);
  border-radius: var(--radius);
  width: fit-content;
}

.doc-item:not(.farda-item) .doc-nome {
  margin: 0;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: break-word;
}

.doc-item:not(.farda-item) .btn {
  grid-column: 2;
  grid-row: 1 / -1;
  align-self: center;
  min-height: var(--touch);
  min-width: 7rem;
  padding: var(--space-2) var(--space-4);
  font-size: 0.875rem;
}

.doc-item:not(.farda-item) .btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent-muted);
  color: var(--accent-hover);
}

/* Documentos: mobile – botão em linha própria, toque fácil */
@media (max-width: 599px) {
  .doc-item:not(.farda-item) {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: var(--space-3);
    padding: var(--space-4);
  }

  .doc-item:not(.farda-item) .btn {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
    justify-self: stretch;
  }
}

.curso-list { display: flex; flex-direction: column; gap: var(--space-3); }

/* ========== FARDAMENTO – Cartões claros e responsivos ========== */
.farda-secao .secao-titulo {
  margin-bottom: var(--space-4);
}

/* Agrupamento por tipo de uniforme (Uniforme nº 1, nº 2, EPI, Outros) */
.farda-grupo {
  margin-bottom: var(--space-6);
}
.farda-grupo:last-child {
  margin-bottom: 0;
}

.farda-grupo-titulo {
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--accent-muted);
  letter-spacing: 0.02em;
  margin: 0 0 var(--space-3) 0;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.farda-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

@media (min-width: 480px) {
  .farda-list { gap: var(--space-2); }
}

.farda-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  padding: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  min-height: var(--touch);
}

.farda-item:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.farda-item > div,
.farda-item .farda-item-info {
  grid-column: 1;
  min-width: 0;
}

.farda-item .farda-item-info .doc-nome,
.farda-item .farda-item-info .curso-meta {
  display: block;
}

.farda-item .doc-nome {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: break-word;
  margin: 0;
}

.farda-item .curso-meta {
  font-size: 0.8125rem;
  margin-top: var(--space-1);
  line-height: 1.4;
  color: var(--text-muted);
  word-break: break-word;
}

.farda-item .btn-pedir-troca,
.farda-item .badge {
  grid-column: 2;
  grid-row: 1 / -1;
  align-self: center;
  justify-self: end;
}

.farda-item .btn-pedir-troca {
  min-height: var(--touch);
  padding: var(--space-2) var(--space-4);
  font-size: 0.875rem;
  flex-shrink: 0;
}

.farda-item .badge {
  padding: var(--space-1) var(--space-3);
  font-size: 0.6875rem;
}

/* Fardamento: em ecrãs muito pequenos, botão abaixo do texto */
@media (max-width: 479px) {
  .farda-item {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: var(--space-2);
    padding: var(--space-4);
  }

  .farda-item .doc-nome { font-size: 0.875rem; }

  .farda-item .curso-meta { font-size: 0.75rem; }

  .farda-item .btn-pedir-troca,
  .farda-item .badge {
    grid-column: 1;
    grid-row: 3;
    justify-self: stretch;
    width: 100%;
  }

  .farda-item .btn-pedir-troca {
    min-height: var(--touch);
  }
}

/* ========== CURSOS ========== */
.curso-item {
  padding: var(--space-5);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.curso-item:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.curso-item .curso-nome {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  line-height: 1.35;
}

.curso-item .curso-meta,
.curso-item .curso-datas {
  margin: var(--space-2) 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.curso-item .curso-datas { font-size: 0.75rem; }

.curso-item .curso-observacoes {
  margin: var(--space-2) 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ========== MODAIS ========== */
/* Bloquear scroll da página quando um modal está aberto */
body.modal-open {
  overflow: hidden !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
  z-index: 1000;
  overflow-y: auto;
}

.modal-overlay[hidden] { display: none !important; }

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  padding: var(--space-6);
  width: 100%;
  max-width: 24rem;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  margin: auto;
}

.modal-titulo {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 var(--space-2);
}

.modal-desc {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin: 0 0 var(--space-5);
  line-height: 1.5;
}

.modal-instalar-instrucoes {
  margin: 0 0 var(--space-5);
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
}
.modal-instalar-instrucoes p {
  margin: 0 0 var(--space-3);
}
.modal-instalar-instrucoes p:last-child {
  margin-bottom: 0;
}

.modal-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}

.modal-form label:first-of-type { margin-top: 0; }

.modal-form input,
.modal-form textarea {
  width: 100%;
  min-height: var(--touch);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: var(--space-2);
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.modal-form textarea {
  min-height: 5rem;
  resize: vertical;
}

.modal-form input:focus,
.modal-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-6);
  justify-content: flex-end;
}

.modal-buttons .btn { min-width: 6rem; }

@media (max-width: 479px) {
  .modal-buttons { flex-direction: column; }
  .modal-buttons .btn { width: 100%; min-width: 0; }
}

.erro {
  background: var(--red-soft);
  border: 1px solid #fecaca;
  color: var(--red-text);
  padding: var(--space-4);
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: var(--space-4);
}

.hint { font-size: 0.8125rem; color: var(--text-muted); line-height: 1.5; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========== App instalada no Android (PWA): interface um pouco mais pequena ========== */
html.portal-android-standalone {
  font-size: 93.75%;
}
html.portal-android-standalone .portal-header .logo {
  height: 1.5rem;
}
@media (min-width: 480px) {
  html.portal-android-standalone .portal-header .logo {
    height: 1.75rem;
  }
}
html.portal-android-standalone .nav-icon {
  width: 1.25rem;
  height: 1.25rem;
}
html.portal-android-standalone .hub-card-icon {
  width: 2.25rem;
  height: 2.25rem;
}
