:root {
  --primary: #1e90ff;
  --primary-dark: #176fbe;
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --text-main: #222;
  --text-muted: #666;
  --border: #e0e0e0;
  --danger: #e53935;
  --success: #43a047;
  --warning: #ffb300;
  --radius: 8px;
  --shadow-soft: 0 4px 12px rgba(0,0,0,0.06);
  --transition-fast: 0.15s ease-in-out;
  --nav-height: 56px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #f0f7ff 0, #f6f7fb 45%, #ffffff 100%);
  color: var(--text-main);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden; /* impede scroll horizontal da página toda */
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* LAYOUT GERAL */
.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 0 16px 24px;
}

/* HEADER */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  background: linear-gradient(90deg, rgba(30,144,255,0.98), rgba(23,111,190,0.98));
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap; /* permite quebrar linha para o menu descer em telas menores */
}

.logo-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;   /* garante espaço mínimo para logo + título */
  flex-shrink: 0;      /* impede o bloco de encolher demais */
}

.logo-img {
  height: 44px;
  width: auto;
  max-width: 110px;
  object-fit: contain;
  background: rgba(255,255,255,0.95);
  border-radius: 8px;
  padding: 4px 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.16);
}

.site-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.site-title {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  color: #ffffff;
}

.etapa-info {
  font-size: 12px;
  opacity: 0.95;
  color: #e3f2fd;
}

/* NAV */
.nav-main {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* LINKS DO HEADER - TODOS BRANCOS (exceto botão especial já estilizado no PHP) */
.nav-link {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid transparent;
  white-space: nowrap;
  color: #ffffff !important;
}
.nav-link:hover {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.35);
  text-decoration: none;
  color: #ffffff !important;
}

/* BOTÃO DESTACADO (ex: Sair) */
.nav-link-primary {
  background: #fff;
  color: var(--primary-dark) !important;
  font-weight: 600;
}
.nav-link-primary:hover {
  background: #f5f8ff;
  color: var(--primary-dark) !important;
}

/* BADGE DE NOTIFICAÇÕES */
.notif-badge {
  background: #ff4136;
  color: #fff;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 11px;
  margin-left: 3px;
}

/* USER CHIP (NOME DO USUÁRIO) */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.18);
  border-radius: 999px;
  font-size: 12px;
  color: #ffffff;
}

.user-chip span {
  max-width: 120px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* TOGGLE MOBILE */
.nav-toggle {
  display: none;
  background: transparent;
  border: none;
  color: #fff;
  padding: 4px;
  cursor: pointer;
}

.nav-toggle-icon {
  width: 20px;
  height: 2px;
  background: #fff;
  position: relative;
  border-radius: 4px;
}
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 4px;
}
.nav-toggle-icon::before {
  top: -6px;
}
.nav-toggle-icon::after {
  top: 6px;
}

/* NAV MOBILE DROPDOWN (controlado pela classe .nav-open no body) */
.nav-main-mobile {
  display: none; /* só aparece quando .nav-open está no body */
  position: absolute; /* Fixa relativo ao header sticky */
  top: 100%; /* Logo abaixo do header */
  left: 0;
  width: 100%;
  z-index: 49;
}
.nav-main-mobile-inner {
  background: rgba(8,38,68,0.98); /* Fundo sólido/translucido (azul original) */
  border-radius: 0 0 12px 12px; /* Arredondado só embaixo */
  padding: 12px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25); /* Sombra para destacar */
}
.nav-main-mobile-inner a {
  display: block;
  padding: 8px 4px;
  font-size: 14px;
  color: #fdfdfd;
  border-radius: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.nav-main-mobile-inner a:last-child {
  border-bottom: none;
}
.nav-main-mobile-inner a:hover {
  background: rgba(255,255,255,0.08);
}

/* Correção para o 'summary' (texto Admin) dentro do menu mobile */
.nav-main-mobile-inner details summary {
    color: #fdfdfd; /* Branco igual aos links */
    font-size: 14px; /* Mesmo tamanho dos links */
    padding: 8px 4px; /* Mesmo espaçamento */
    font-weight: normal;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.nav-main-mobile-inner details[open] summary {
    border-bottom: none;
    font-weight: 600;
    margin-bottom: 4px;
}

/* MAIN */
main {
  flex: 1;
}

.page {
  margin-top: 18px;
  background: var(--card-bg);
  border-radius: 14px;
  padding: 18px 16px 20px;
  box-shadow: var(--shadow-soft);
  overflow-x: auto;   /* se algo passar um pouco, o scroll fica só dentro da área da página */
}

.page h2 {
  margin-top: 0;
  font-size: 20px;
}

.page h3 {
  margin-top: 18px;
  font-size: 16px;
}

/* FORMULÁRIOS */
form {
  background: #fafafa;
  border-radius: 12px;
  padding: 14px 14px 16px;
  border: 1px solid var(--border);
}

label {
  display: block;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-main);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 7px 9px;
  margin-top: 4px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
  font-family: inherit;
  background: #ffffff;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(30,144,255,0.18);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin-right: 4px;
}

.checkbox-inline,
.radio-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 14px;
  font-size: 13px;
}

/* BOTÕES */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary-dark);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.btn:hover {
  background: #f5f8ff;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  color: #fff;
}

.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover {
  background: rgba(229,57,53,0.08);
}

/* MENSAGENS */
.msg {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.msg-erro {
  background: #ffebee;
  color: #c62828;
  border: 1px solid #ffcdd2;
}

.msg-ok {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}

/* TABELAS */
table {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
  font-size: 13px;
  max-width: 100%;   /* impede passar da largura do container */
}

th, td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: center;
}

th {
  background: #f1f3f7;
  font-weight: 600;
}

.table-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* AVATAR E STATUS */
.foto-perfil {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.avatar-wrapper {
  position: relative;
  display: inline-block;
}

.avatar-wrapper .status-icon {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-sizing: border-box;
}

.avatar-wrapper.cond-pronto .status-icon { background: var(--success); }
.avatar-wrapper.cond-viagem .status-icon { background: var(--warning); }
.avatar-wrapper.cond-lesionado .status-icon { background: var(--danger); }

/* BANNER DA ETAPA */
.etapa-banner-img {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}
.etapa-banner-img img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.16);
}

/* FOOTER */
.site-footer {
  margin-top: auto;
  text-align: center;
  padding: 10px 16px 14px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.9);
}

.site-footer-extra {
  margin-top: 4px;
  white-space: pre-wrap;
}

/* DETAILS */
details summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--primary-dark);
}
details[open] summary {
  margin-bottom: 6px;
}

/* RESPONSIVIDADE */
@media (max-width: 768px) {
  .site-header-inner {
    padding: 8px 12px;
  }
  .nav-links {
    display: none; /* esconde links horizontais no mobile */
  }
  .nav-toggle {
    display: inline-flex; /* mostra o botão hambúrguer */
  }
  .nav-open .nav-main-mobile {
    display: block; /* exibe o menu mobile apenas quando body tiver nav-open */
  }
  .page {
    margin-top: 12px;
    padding: 14px 12px 16px;
  }
  form {
    padding: 12px 10px 14px;
  }
  .table-wrapper table {
    min-width: 100% !important;
  }
  table {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .site-title {
    font-size: 16px;
  }
  .logo-img {
    height: 38px;
  }
  .user-chip {
    display: none;
  }
}
.nav-admin-dropdown {
    position: relative;
    list-style: none; 
    list-style-type: none
}

.nav-admin-dropdown .admin-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background: #0f172a; /* mesma pegada escura do header */
    border-radius: 0 0 10px 10px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.35);
    padding: 6px 0;
    z-index: 50;
    list-style: none; 
    list-style-type: none
}

.nav-admin-dropdown.open .admin-dropdown-menu {
    display: block;
    list-style: none; 
    list-style-type: none
}

.nav-admin-dropdown .admin-dropdown-menu li {
    list-style: none;
    list-style-type: none
}

.nav-admin-dropdown .admin-dropdown-menu a {
    display: block;
    padding: 8px 14px;
    font-size: 0.9rem;
    text-decoration: none;
    color: #e5e7eb; /* texto claro */
    list-style: none; 
    list-style-type: none
}

.nav-admin-dropdown .admin-dropdown-menu a:hover {
    background: rgba(15, 118, 110, 0.25); /* um hover sutil */
    list-style: none; 
    list-style-type: none
}
/* ==========================
   DIFERENCIAÇÃO VISUAL DO ADMIN
   ========================== */
body.admin-logado .site-header {
  background: linear-gradient(90deg, #b91c1c, #7f1d1d);
}

/* Menu Mobile também fica vermelho se for Admin */
body.admin-logado .nav-main-mobile-inner {
    background: rgba(127, 29, 29, 0.98); /* Vermelho escuro */
}

body.admin-logado .site-footer {
  background: rgba(185, 28, 28, 0.96);
  color: #fee2e2;
  border-top-color: rgba(248, 113, 113, 0.7);
}