@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Cor */
  --azul-800: #0a3a94;
  --azul-700: #0f4fc4;
  --azul-600: #1b6ef3;
  --azul-500: #3b82f6;
  --azul-100: #e6efff;
  --azul-50:  #f4f8ff;

  --tinta: #0f1728;
  --grafite: #4b5768;
  --grafite-suave: #7c8aa0;
  --linha: #e3e8f0;
  --linha-forte: #cbd5e1;
  --fundo: #eef2fa;
  --superficie: #ffffff;

  --verde-700: #15803d;
  --verde-100: #dcfce7;
  --ambar-700: #b45309;
  --ambar-100: #fef3c7;
  --vermelho-700: #b91c1c;
  --vermelho-100: #fee2e2;

  --raio-sm: 8px;
  --raio: 14px;
  --raio-lg: 22px;

  --sombra-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --sombra: 0 8px 24px -8px rgba(15, 61, 148, .18);
  --sombra-lg: 0 24px 48px -16px rgba(15, 61, 148, .28);

  --fonte: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

[data-tema="escuro"] {
  --tinta: #eef1f7;
  --grafite: #a8b3c7;
  --grafite-suave: #7c8aa0;
  --linha: #232f45;
  --linha-forte: #34415c;
  --fundo: #0b1220;
  --superficie: #121a2b;
  --azul-50: #16233d;
  --azul-100: #1b2c4d;
  --verde-100: #113322;
  --ambar-100: #3a2a0d;
  --vermelho-100: #3a1414;
}
[data-tema="escuro"] body {
  background-image:
    radial-gradient(1100px 480px at 100% -10%, rgba(27,110,243,.14), transparent 60%),
    radial-gradient(900px 420px at -10% 0%, rgba(27,110,243,.08), transparent 55%);
}
[data-tema="escuro"] .btn.secundario { color: var(--azul-500); }
[data-tema="escuro"] input, [data-tema="escuro"] select, [data-tema="escuro"] textarea { color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--fonte);
  background: var(--fundo);
  background-image:
    radial-gradient(1100px 480px at 100% -10%, rgba(27,110,243,.08), transparent 60%),
    radial-gradient(900px 420px at -10% 0%, rgba(27,110,243,.05), transparent 55%);
  background-attachment: fixed;
  color: var(--tinta);
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--azul-700); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--azul-100); color: var(--azul-800); }

:focus-visible {
  outline: 2.5px solid var(--azul-500);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ----------------------------- Topo / navegação ----------------------------- */

.topo {
  background: var(--superficie);
  color: var(--tinta);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--linha);
}

.topo .marca {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--tinta);
}
.topo .marca::before {
  content: '';
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--azul-600), var(--azul-800));
  flex-shrink: 0;
  box-shadow: 0 4px 10px -3px rgba(27,110,243,.5);
}
.topo .marca small { display: none; }

.chip-usuario {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  background: var(--fundo);
  font-size: .85rem;
  font-weight: 600;
  color: var(--tinta);
  margin-right: 4px;
}
.chip-usuario .avatar {
  width: 26px; height: 26px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--azul-600), var(--azul-800));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 800;
  flex-shrink: 0;
}

.topo nav {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.topo nav a, .topo nav button {
  color: var(--grafite);
  font-weight: 600;
  font-size: .87rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all .15s ease;
  white-space: nowrap;
}
.topo nav a:hover, .topo nav button:hover { background: var(--azul-50); color: var(--azul-700); text-decoration: none; }
.topo nav a.nav-ativo { background: var(--azul-50); color: var(--azul-700); }

#btnMenuMobile {
  display: none;
  background: var(--azul-50);
  border: none;
  color: var(--azul-700);
  width: 40px; height: 40px;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

@media (max-width: 860px) {
  .topo nav.nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding-top: 10px;
    order: 3;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
  }
  .topo nav.nav-links.aberto { display: flex; }
  .topo nav.nav-links a, .topo nav.nav-links button {
    text-align: left;
    padding: 11px 14px;
    border-radius: 10px;
    width: 100%;
  }
  #btnMenuMobile { display: flex; }
}

/* ------------------------- Layout com menu lateral (admin/master) ------------------------- */

.layout-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 258px;
  flex-shrink: 0;
  background: var(--superficie);
  border-right: 1px solid var(--linha);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
  transition: transform .2s ease;
}

.sidebar-marca {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px;
  font-weight: 800; font-size: .96rem; line-height: 1.25;
  border-bottom: 1px solid var(--linha);
  margin-bottom: 8px;
  color: var(--tinta);
}
.sidebar-marca .marca-icone {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--azul-600), var(--azul-800));
  box-shadow: 0 4px 10px -3px rgba(27,110,243,.5);
}

.sidebar-nav { flex: 1; padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px;
  color: var(--grafite); font-weight: 600; font-size: .87rem;
  transition: all .12s ease;
}
.sidebar-nav a:hover { background: var(--azul-50); color: var(--azul-700); text-decoration: none; }
.sidebar-nav a.nav-ativo { background: var(--azul-600); color: #fff; box-shadow: 0 4px 10px -4px rgba(27,110,243,.6); }
.sidebar-nav .icone-nav { width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-rodape { padding: 14px 16px 18px; border-top: 1px solid var(--linha); display: flex; flex-direction: column; gap: 10px; }
.sidebar-rodape .chip-usuario { width: 100%; background: var(--fundo); }
.sidebar-rodape .btn { width: 100%; }

.area-principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topo-fixo {
  position: sticky; top: 0; z-index: 40;
  background: var(--superficie);
  border-bottom: 1px solid var(--linha);
  padding: 14px 24px;
  display: flex; align-items: center; gap: 14px;
}
.topo-fixo .titulo-pagina { font-weight: 700; font-size: 1.02rem; flex: 1; color: var(--tinta); }

#btnMenuMobileSidebar, .botao-tema {
  background: var(--fundo);
  border: 1px solid var(--linha);
  color: var(--grafite);
  width: 38px; height: 38px;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.botao-tema:hover, #btnMenuMobileSidebar:hover { background: var(--azul-50); color: var(--azul-700); }
#btnMenuMobileSidebar { display: none; }

.sidebar-fundo-mobile { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 45; }

@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--sombra-lg); }
  .sidebar.aberto { transform: translateX(0); }
  #btnMenuMobileSidebar { display: flex; }
  .sidebar-fundo-mobile.aberto { display: block; }
}

/* -------------------------------- Layout base -------------------------------- */

.container { max-width: 1120px; margin: 0 auto; padding: 32px 20px 64px; }
.container.estreito { max-width: 460px; }

.card {
  background: var(--superficie);
  border: 1px solid var(--linha);
  border-radius: var(--raio-lg);
  box-shadow: var(--sombra-sm);
  padding: 26px 28px;
  margin-bottom: 20px;
}

h1 { font-size: 1.6rem; margin: 0 0 6px; letter-spacing: -.015em; font-weight: 800; }
h2 { font-size: 1.2rem; margin: 0 0 14px; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 1.02rem; margin: 0 0 10px; font-weight: 700; }
.subtitulo { color: var(--grafite); margin: 0 0 22px; font-size: .95rem; }

/* ---------------------------------- Formulários --------------------------------- */

label { display: block; font-weight: 600; font-size: .83rem; margin: 16px 0 6px; color: var(--tinta); }
label:first-child { margin-top: 0; }

input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--linha);
  border-radius: var(--raio-sm);
  font-family: inherit;
  font-size: .95rem;
  background: var(--superficie);
  color: var(--tinta);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--linha-forte); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--azul-600); box-shadow: 0 0 0 4px var(--azul-100);
}
input[type=checkbox] { width: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: 999px;
  border: none;
  font-weight: 700;
  font-size: .89rem;
  cursor: pointer;
  font-family: inherit;
  background: linear-gradient(135deg, var(--azul-600), var(--azul-700));
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(27,110,243,.55);
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 20px -6px rgba(27,110,243,.6); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.secundario { background: var(--superficie); color: var(--azul-700); border: 1.5px solid var(--linha-forte); box-shadow: none; }
.btn.secundario:hover { background: var(--azul-50); border-color: var(--azul-600); }
.btn.perigo { background: linear-gradient(135deg, #ef4444, var(--vermelho-700)); box-shadow: 0 6px 16px -6px rgba(220,38,38,.5); }
.btn.pequeno { padding: 7px 14px; font-size: .8rem; }
.btn.bloco { width: 100%; margin-top: 18px; }

/* ----------------------------------- Diversos ---------------------------------- */

.grade-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 560px) { .grade-2 { grid-template-columns: 1fr; } }

.alerta {
  padding: 13px 16px; border-radius: var(--raio-sm); font-size: .88rem; margin-bottom: 16px;
  border: 1px solid transparent; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.alerta.erro { background: var(--vermelho-100); color: var(--vermelho-700); border-color: #fecaca; }
.alerta.sucesso { background: var(--verde-100); color: var(--verde-700); border-color: #bbf7d0; }
.alerta.info { background: var(--azul-100); color: var(--azul-800); border-color: #bfdbfe; }

.tabela-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--linha); }
th {
  color: var(--grafite-suave); font-weight: 700; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .05em; position: sticky; top: 0; background: var(--superficie);
}
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--azul-50); }
tr:last-child td { border-bottom: none; }

.selo {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 999px;
  font-size: .74rem; font-weight: 700;
}
.selo::before { content: ''; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.selo.confirmado { background: var(--azul-100); color: var(--azul-800); }
.selo.realizado { background: var(--verde-100); color: var(--verde-700); }
.selo.cancelado { background: var(--vermelho-100); color: var(--vermelho-700); }

.grade-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card-metrica {
  background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio);
  padding: 18px; box-shadow: var(--sombra-sm);
  display: flex; align-items: center; gap: 14px;
}
.card-metrica .icone {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}
.card-metrica .icone.azul { background: var(--azul-100); color: var(--azul-700); }
.card-metrica .icone.verde { background: var(--verde-100); color: var(--verde-700); }
.card-metrica .icone.ambar { background: var(--ambar-100); color: var(--ambar-700); }
.card-metrica .icone.vermelho { background: var(--vermelho-100); color: var(--vermelho-700); }
.card-metrica .conteudo { min-width: 0; }
.card-metrica .valor { font-size: 1.5rem; font-weight: 800; color: var(--tinta); letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.card-metrica .rotulo { color: var(--grafite); font-size: .8rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.grafico-card { background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio-lg); box-shadow: var(--sombra-sm); padding: 22px; margin-bottom: 20px; }
.grafico-card h3 { margin-bottom: 4px; }
.grafico-card canvas { max-height: 260px; }

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 14px 0; }
.slot {
  border: 1.5px solid var(--linha); border-radius: var(--raio-sm); padding: 11px 8px; text-align: center;
  cursor: pointer; background: var(--superficie); font-size: .87rem; font-weight: 700;
  font-variant-numeric: tabular-nums; transition: all .12s ease;
}
.slot:hover { border-color: var(--azul-600); transform: translateY(-1px); box-shadow: var(--sombra-sm); }
.slot.selecionado { background: linear-gradient(135deg, var(--azul-600), var(--azul-700)); color: #fff; border-color: transparent; box-shadow: 0 6px 16px -6px rgba(27,110,243,.55); }
.slot.esgotado { background: #f8fafc; color: #b0b8c5; cursor: not-allowed; text-decoration: line-through; border-style: dashed; }
.slot .vagas { display: block; font-weight: 500; font-size: .72rem; opacity: .8; margin-top: 3px; }

.rodape-form { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; font-size: .87rem; }

.tabs { display: flex; gap: 2px; border-bottom: 1.5px solid var(--linha); margin-bottom: 20px; overflow-x: auto; }
.tabs button {
  background: none; border: none; padding: 11px 16px; font-family: inherit; font-weight: 700;
  font-size: .87rem; color: var(--grafite); cursor: pointer; border-bottom: 2.5px solid transparent;
  white-space: nowrap; transition: color .12s ease;
}
.tabs button:hover { color: var(--azul-700); }
.tabs button.ativo { color: var(--azul-700); border-color: var(--azul-600); }

.filtros { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 20px; }
.filtros > div { min-width: 150px; }

.vazio { text-align: center; color: var(--grafite-suave); padding: 34px 10px; font-size: .9rem; }

/* --------------------------- Cartão-passe (visitas) -------------------------- */
/* Elemento de assinatura: a visita agendada tem cara de passe/ticket — canhoto  */
/* com data/hora grandes, corpo com os detalhes, "picotado" no meio.            */

.lista-passes { display: flex; flex-direction: column; gap: 14px; }

.passe {
  display: flex;
  background: var(--superficie);
  border: 1px solid var(--linha);
  border-radius: var(--raio-lg);
  box-shadow: var(--sombra-sm);
  overflow: hidden;
  position: relative;
}

.passe-canhoto {
  background: linear-gradient(160deg, var(--azul-600), var(--azul-800));
  color: #fff;
  padding: 18px 16px;
  min-width: 108px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
}
.passe-canhoto .dia { font-size: 1.7rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.passe-canhoto .mes { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .85; margin-top: 3px; }
.passe-canhoto .hora { font-size: .78rem; font-weight: 600; margin-top: 10px; opacity: .92; font-variant-numeric: tabular-nums; }

.passe-picote {
  width: 0;
  border-left: 2px dashed rgba(15, 23, 42, .16);
  position: relative;
  margin: 14px 0;
}
.passe-picote::before, .passe-picote::after {
  content: ''; position: absolute; left: 50%; transform: translateX(-50%);
  width: 18px; height: 18px; background: var(--fundo); border-radius: 999px;
}
.passe-picote::before { top: -9px; }
.passe-picote::after { bottom: -9px; }

.passe-corpo {
  flex: 1;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.passe-corpo .info-principal .interno { font-weight: 700; font-size: 1rem; }
.passe-corpo .info-principal .prontuario { color: var(--grafite-suave); font-size: .8rem; margin-top: 2px; }
.passe-corpo .acoes { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

@media (max-width: 560px) {
  .passe { flex-direction: column; }
  .passe-canhoto { flex-direction: row; justify-content: center; gap: 10px; padding: 12px; min-width: unset; }
  .passe-canhoto .mes { margin-top: 0; }
  .passe-canhoto .hora { margin-top: 0; padding-left: 10px; border-left: 1px solid rgba(255,255,255,.3); }
  .passe-picote { width: 100%; height: 0; border-left: none; border-top: 2px dashed rgba(15,23,42,.14); margin: 0; }
  .passe-picote::before, .passe-picote::after { top: 50%; transform: translateY(-50%); }
  .passe-picote::before { left: -9px; }
  .passe-picote::after { left: unset; right: -9px; }
  .passe-corpo { padding: 14px 16px; }
}

@media print {
  .topo, .tabs, .filtros, .btn, button, .card form, #btnFiltrar, #btnExportar, #btnMenuMobile { display: none !important; }
  .container { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: none; padding: 0; margin-bottom: 24px; }
  body { background: #fff; }
  table { font-size: .82rem; }
}

/* ------------------------------- Modal / popup ------------------------------- */

.modal-fundo {
  position: fixed; inset: 0; background: rgba(15, 23, 40, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-fundo[hidden] { display: none; }

.modal-caixa {
  background: var(--superficie); border-radius: var(--raio-lg);
  box-shadow: var(--sombra-lg); max-width: 480px; width: 100%;
  padding: 28px; max-height: 85vh; overflow-y: auto;
}
.modal-caixa h2 { display: flex; align-items: center; gap: 8px; }
.modal-caixa .corpo-texto { color: var(--grafite); font-size: .92rem; line-height: 1.6; white-space: pre-line; }
.modal-caixa .corpo-texto + .corpo-texto { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--linha); }

/* ---------------------------- Card de info da unidade ------------------------- */

.card-unidade {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio-lg);
  box-shadow: var(--sombra-sm); padding: 16px; margin-bottom: 20px;
}
.card-unidade img {
  width: 84px; height: 84px; object-fit: cover; border-radius: var(--raio);
  flex-shrink: 0; background: var(--azul-50);
}
.card-unidade .detalhes { flex: 1; min-width: 180px; }
.card-unidade .nome-unidade { font-weight: 800; font-size: 1.02rem; }
.card-unidade .endereco-unidade { color: var(--grafite); font-size: .85rem; margin-top: 3px; }
.card-unidade a.link-mapa { font-size: .82rem; font-weight: 700; }
