/* Agenda do Barco: preto e branco, no estilo dos apps da Apple */

:root {
  color-scheme: light;
  --preto: #000000;
  --branco: #ffffff;
  --fundo: #f2f2f7;          /* fundo agrupado */
  --rotulo-2: #6e6e73;       /* texto secundário */
  --rotulo-3: #aeaeb2;       /* texto terciário */
  --separador: #d1d1d6;
  --preenchimento: #e5e5ea;  /* controles e áreas cinza */
  --raio: 12px;
  --fonte: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { overflow-y: scroll; scrollbar-gutter: stable; }

body {
  background: var(--fundo);
  color: var(--preto);
  font-family: var(--fonte);
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
svg { display: block; }
[hidden] { display: none !important; }

/* ---------- Estrutura ---------- */

.app { max-width: 720px; margin: 0 auto; min-height: 100dvh; }
.conteudo { padding: 0 20px calc(100px + env(safe-area-inset-bottom)); }

/* Topo padrão de todas as telas: barra fixa de 44px + título grande */
.barra {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: calc(44px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 4px 0;
  margin: 0 -20px;
  background: rgb(242 242 247 / 0.88);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.barra-lado { display: flex; align-items: center; min-width: 0; }
.barra-botao {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  min-width: 44px; height: 44px; padding: 0 12px; font-size: 17px; color: var(--preto);
}
.barra-botao svg { width: 22px; height: 22px; flex-shrink: 0; }
.barra-botao[data-voltar] { padding-left: 8px; }
.barra-botao:active { opacity: 0.5; }

.titulo-bloco { padding-top: 2px; }
.titulo-linha { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.titulo-grande {
  font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.titulo-grande span { color: var(--rotulo-3); }
.subtitulo { font-size: 15px; line-height: 20px; font-weight: 400; letter-spacing: 0; color: var(--rotulo-2); }
.setas { display: flex; gap: 12px; flex-shrink: 0; }
.seta-botao { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--preenchimento); }
.seta-botao svg { width: 18px; height: 18px; }
.seta-botao:active { opacity: 0.6; }

/* Primeiro bloco depois do título: sempre o mesmo espaço */
.titulo-bloco + .secao, .titulo-bloco + form > .secao:first-child, .titulo-bloco + section { margin-top: 20px; }
.aviso-topo { margin-top: 16px; }
.aviso-topo + .secao { margin-top: 20px; }
.esperando { opacity: 0.55; transition: opacity 0.15s; }

/* Barra de abas inferior */
.abas-app {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  background: rgb(249 249 249 / 0.92);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separador);
  padding-bottom: env(safe-area-inset-bottom);
}
.abas-app-itens { max-width: 720px; margin: 0 auto; display: flex; }
.abas-app a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 50px; font-size: 10px; font-weight: 500; color: var(--rotulo-3);
}
.abas-app a svg { width: 26px; height: 26px; }
.abas-app a.ativo { color: var(--preto); }

/* ---------- Controle segmentado (Semana | Mês | Ano) ---------- */

.segmentado { display: flex; background: var(--preenchimento); border-radius: 9px; padding: 2px; margin-top: 16px; }
.segmentado a { flex: 1; text-align: center; padding: 8px 0; border-radius: 7px; font-size: 14px; font-weight: 500; }
.segmentado a.ativo { background: var(--branco); font-weight: 600; box-shadow: 0 3px 8px rgb(0 0 0 / 0.12), 0 0 1px rgb(0 0 0 / 0.04); }

/* ---------- Listas agrupadas ---------- */

.secao { margin-top: 32px; }
.secao-titulo { font-size: 13px; text-transform: uppercase; color: var(--rotulo-2); padding: 0 16px 6px; letter-spacing: 0; }
.secao-rodape { font-size: 13px; color: var(--rotulo-2); padding: 6px 16px 0; }
.grupo { background: var(--branco); border-radius: var(--raio); overflow: hidden; }
.linha {
  display: flex; align-items: center; gap: 14px; min-height: 50px; padding: 13px 16px;
  position: relative; width: 100%; text-align: left;
}
/* Separador fino entre linhas (recuado, como no iOS) */
.grupo .linha::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--separador);
}
.grupo > .linha:first-child::before,
.grupo > details:first-child > summary.linha::before,
.grupo > form:first-child > .linha:first-child::before,
details.grupo > summary.linha::before { display: none; }
.linha-texto { flex: 1; min-width: 0; }
.linha-texto b { display: block; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.linha-texto small { display: block; font-size: 15px; color: var(--rotulo-2); margin-top: 1px; }
.linha-valor { color: var(--rotulo-2); white-space: nowrap; }
.linha-chevron { color: var(--rotulo-3); flex-shrink: 0; }
.linha-chevron svg { width: 14px; height: 14px; }
.linha-acao { color: var(--preto); justify-content: center; font-weight: 400; }
.linha-acao.forte { font-weight: 600; }
.linha-acao svg { width: 20px; height: 20px; }
a.linha:active, button.linha:active { background: var(--preenchimento); }

/* ---------- Botões e campos ---------- */

.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 12px;
  font-size: 17px; font-weight: 600; transition: opacity 0.15s, transform 0.1s;
}
.botao:active { transform: scale(0.98); opacity: 0.8; }
.botao:disabled { opacity: 0.4; }
.botao-primario { background: var(--preto); color: var(--branco); }
.botao-secundario { background: var(--preenchimento); color: var(--preto); }
.botao-pequeno { min-height: 34px; padding: 0 14px; border-radius: 17px; font-size: 15px; }
.largura-total { width: 100%; }

.campo {
  width: 100%; border: 0; background: transparent; padding: 0; font: inherit; color: var(--preto); outline: none;
  -webkit-appearance: none; appearance: none; min-height: 22px;
}
.campo::placeholder { color: var(--rotulo-3); }
select.campo { text-align: right; text-align-last: right; direction: rtl; color: var(--rotulo-2); }
input[type="date"].campo { text-align: right; color: var(--rotulo-2); }
.linha-campo { display: flex; align-items: center; gap: 12px; }
.linha-campo > span { flex-shrink: 0; }
.linha-campo .campo { flex: 1; text-align: right; }
.linha-campo.empilhado { flex-direction: column; align-items: stretch; gap: 2px; }
.linha-campo.empilhado .campo { text-align: left; }
.linha-campo.empilhado > span { font-size: 13px; color: var(--rotulo-2); }

/* Interruptor estilo iOS */
.interruptor { position: relative; width: 51px; height: 31px; flex-shrink: 0; margin-left: auto; }
.interruptor input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.interruptor i { position: absolute; inset: 0; border-radius: 31px; background: var(--preenchimento); transition: background 0.2s; }
.interruptor i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: var(--branco); box-shadow: 0 3px 8px rgb(0 0 0 / 0.15), 0 1px 1px rgb(0 0 0 / 0.1); transition: transform 0.2s;
}
.interruptor input:checked + i { background: var(--preto); }
.interruptor input:checked + i::after { transform: translateX(20px); }

/* Escolha de período */
.periodos-opcoes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.periodo-opcao {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 4px; border-radius: var(--raio); background: var(--branco); cursor: pointer; text-align: center;
  border: 2px solid transparent;
}
.periodo-opcao input { position: absolute; opacity: 0; pointer-events: none; }
.periodo-opcao svg { width: 26px; height: 26px; }
.periodo-opcao b { font-size: 15px; font-weight: 600; }
.periodo-opcao small { font-size: 12px; color: var(--rotulo-2); }
.periodo-opcao.ativo { border-color: var(--preto); }

/* ---------- Avisos ---------- */

.aviso { border-radius: var(--raio); padding: 12px 16px; font-size: 15px; background: var(--branco); }
.aviso-ok { background: var(--preto); color: var(--branco); }
.aviso-erro { background: var(--branco); color: var(--preto); box-shadow: inset 0 0 0 1.5px var(--preto); font-weight: 500; }
.aviso-senha { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 22px; font-weight: 600; letter-spacing: 0.04em; margin-top: 4px; user-select: all; }
.dica { font-size: 13px; color: var(--rotulo-2); }
.carregando { text-align: center; color: var(--rotulo-2); padding: 64px 0; }
.pilha > * + * { margin-top: 16px; }

/* ---------- Login / instalação ---------- */

.tela-login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; background: var(--branco); padding: 40px 24px; }
.login-caixa { width: 100%; max-width: 360px; }
.login-topo { margin-bottom: 28px; }
.login-topo h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.login-topo p { color: var(--rotulo-2); margin-top: 8px; font-size: 15px; }
.tela-login .grupo { background: var(--fundo); }
.login-link { display: block; width: 100%; text-align: center; color: var(--preto); font-size: 15px; padding: 14px 0; margin-top: 8px; }
.linha-perigo { font-weight: 600; }
.login-rodape { text-align: center; color: var(--rotulo-2); font-size: 13px; margin-top: 24px; }
.cartao { background: var(--fundo); border-radius: var(--raio); padding: 16px; }
.campo-rotulo { display: block; font-size: 13px; color: var(--rotulo-2); }
.campo-rotulo .campo { display: block; margin-top: 4px; background: var(--branco); border-radius: 10px; padding: 12px; font-size: 17px; color: var(--preto); }
.lista-verificacao { padding-left: 0; list-style: none; line-height: 2; }

/* ---------- Calendário: mês ---------- */

.mes { background: var(--branco); border-radius: 16px; margin-top: 20px; padding: 4px 8px 10px; }
.semana-cab {
  display: grid; grid-template-columns: repeat(7, 1fr); text-align: center;
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: var(--rotulo-2);
  padding: 14px 0 6px;
}
.grade-mes { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px 4px; }

.dia {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: 62px; padding: 6px 0 4px; border-radius: 10px; overflow: hidden;
}
.dia:active { background: var(--preenchimento); }
.dia-num { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 17px; font-weight: 400; }
.dia.hoje .dia-num { background: var(--preto); color: var(--branco); font-weight: 600; }
.dia.fora { visibility: hidden; }
.dia.passado { opacity: 0.35; }
.dia-feriado { width: 4px; height: 4px; border-radius: 50%; background: var(--rotulo-3); }
.dia-barras { display: flex; gap: 2px; width: 70%; max-width: 34px; }
.dia-barras i { flex: 1; height: 4px; border-radius: 2px; background: transparent; }
.dia-barras i.on { background: var(--preto); }
.dia-barras i.off { background: var(--preenchimento); }
.dia-nome { font-size: 10px; font-weight: 600; line-height: 1.15; max-width: 100%; padding: 0; letter-spacing: -0.03em; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Dia sem nenhum horário livre */
.dia.cheio { background: var(--preto); color: var(--branco); }
.dia.cheio .dia-num { color: var(--branco); }
.dia.cheio.hoje .dia-num { background: var(--branco); color: var(--preto); }
.dia.cheio .dia-feriado { background: var(--rotulo-2); }
.dia.cheio .dia-barras { display: none; }

@media (min-width: 600px) {
  .dia { min-height: 80px; }
  .dia-nome { font-size: 12px; }
}

.legenda { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 24px; font-size: 13px; color: var(--rotulo-2); padding: 24px 8px 0; }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.legenda i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; }
.legenda .l-cheio { background: var(--preto); }
.legenda .l-meio { width: 14px; height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--preto) 50%, var(--preenchimento) 50%); }
.legenda .l-livre { background: var(--branco); box-shadow: inset 0 0 0 1px var(--separador); }

/* ---------- Calendário: semana ---------- */

.semana-lista { margin-top: 20px; }
.linha-dia { align-items: stretch; gap: 14px; }
.linha-dia-data { width: 40px; flex-shrink: 0; text-align: center; padding-top: 2px; }
.linha-dia-data small { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--rotulo-2); }
.linha-dia-data b { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; font-size: 20px; font-weight: 500; }
.linha-dia.hoje .linha-dia-data b { background: var(--preto); color: var(--branco); }
.linha-dia.passado { opacity: 0.4; }
.linha-dia-periodos { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.slot { display: flex; align-items: center; gap: 8px; font-size: 15px; min-width: 0; }
.slot-rotulo { width: 52px; flex-shrink: 0; font-size: 13px; color: var(--rotulo-2); }
.slot-marca { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 1.5px var(--rotulo-3); }
.slot.ocupado .slot-marca { background: var(--preto); box-shadow: none; }
.slot-nome { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--rotulo-2); }
.slot.ocupado .slot-nome { color: var(--preto); font-weight: 600; }
.feriado-nome { font-size: 12px; color: var(--rotulo-2); }

/* ---------- Calendário: ano ---------- */

.grade-ano { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 20px; }
@media (min-width: 600px) { .grade-ano { grid-template-columns: repeat(3, 1fr); } }
.mini-mes { background: var(--branco); border-radius: var(--raio); padding: 10px 8px; }
.mini-mes h3 { font-size: 15px; font-weight: 600; margin: 0 0 6px 4px; }
.mini-grade { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; text-align: center; }
.mini-grade > span { font-size: 9px; color: var(--rotulo-3); }
.mini-dia { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 10px; }
.mini-dia.cheio { background: var(--preto); color: var(--branco); font-weight: 600; }
.mini-dia.meio { box-shadow: inset 0 0 0 1.5px var(--preto); font-weight: 600; }
.mini-dia.hoje { text-decoration: underline; font-weight: 700; }
.mini-dia.passado { opacity: 0.35; }

/* ---------- Detalhe do dia ---------- */

.periodo-marca { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 1.5px var(--rotulo-3); }
.periodo-marca.on { background: var(--preto); box-shadow: none; }
.periodo-icone { width: 22px; height: 22px; flex-shrink: 0; }
.selo { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--preenchimento); color: var(--preto); flex-shrink: 0; }
.selo-escuro { background: var(--preto); color: var(--branco); }

/* ---------- Admin / conta ---------- */

.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--preto); color: var(--branco); display: inline-flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; flex-shrink: 0; }
.avatar.grande { width: 60px; height: 60px; font-size: 22px; }
.avatar.inativo { background: var(--preenchimento); color: var(--rotulo-2); }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.linha-chevron { transition: transform 0.2s; }
details[open] > summary .linha-chevron { transform: rotate(90deg); }
.foto-barco { width: 100%; height: 180px; object-fit: cover; display: block; filter: grayscale(1); }
.endereco-agenda { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; word-break: break-all; color: var(--rotulo-2); user-select: all; }
input[type="file"].campo { font-size: 15px; color: var(--rotulo-2); direction: ltr; text-align: left; }

/* ---------- Banner de instalação ---------- */

.app:not(.tela-inicial) #banner-instalar { display: none; }
#banner-instalar {
  position: fixed; z-index: 25; left: 0; right: 0; bottom: calc(50px + env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto; padding: 0 12px 10px;
}
.app.tela-inicial.com-banner .conteudo { padding-bottom: calc(180px + env(safe-area-inset-bottom)); }
.banner { display: flex; align-items: center; gap: 12px; background: var(--branco); border-radius: 16px; padding: 12px 10px 12px 14px; box-shadow: 0 4px 24px rgb(0 0 0 / 0.12), 0 0 0 0.5px rgb(0 0 0 / 0.06); }
.banner-icone { width: 40px; height: 40px; border-radius: 10px; background: var(--preto); color: var(--branco); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.banner-icone svg { width: 22px; height: 22px; }
.banner-texto { flex: 1; min-width: 0; }
.banner-texto b { display: block; font-size: 15px; font-weight: 600; }
.banner-texto small { display: block; font-size: 13px; color: var(--rotulo-2); }
.banner-fechar { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; color: var(--rotulo-3); flex-shrink: 0; }
.banner-fechar svg { width: 16px; height: 16px; }

/* Folha (passo a passo de instalação) */
.folha-fundo { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / 0.4); display: flex; align-items: flex-end; justify-content: center; animation: aparecer 0.2s ease-out; }
.folha { width: 100%; max-width: 520px; background: var(--branco); border-radius: 20px 20px 0 0; padding: 24px 20px calc(20px + env(safe-area-inset-bottom)); animation: subir 0.25s ease-out; }
.folha h2 { font-size: 22px; font-weight: 700; margin-bottom: 16px; }
.passos { list-style: none; padding: 0; margin: 0 0 24px; }
.passos li { display: flex; align-items: center; gap: 14px; padding: 12px 0; font-size: 16px; }
.passos li + li { border-top: 0.5px solid var(--separador); }
.passo-icone { width: 36px; height: 36px; border-radius: 10px; background: var(--fundo); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 20px; font-weight: 700; }
.passo-icone svg { width: 20px; height: 20px; }
@keyframes aparecer { from { opacity: 0; } }
@keyframes subir { from { transform: translateY(100%); } }

/* Logos (Google / Apple) nas linhas da conta */
.marca { width: 22px; height: 22px; flex-shrink: 0; }
.marca svg { width: 22px; height: 22px; }

/* Campo de arquivo (foto do barco) */
.arquivo-oculto { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.valor-arquivo { margin-left: auto; color: var(--rotulo-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }

/* Área de aviso vazia não ocupa espaço */
[data-aviso]:empty { display: none; }

.log-texto { white-space: normal !important; font-size: 14px; word-break: break-word; }

/* ---------- Veículos ---------- */

/* Nome do veículo abaixo do título (vira botão quando há mais de um) */
.seletor-veiculo { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; line-height: 20px; color: var(--preto); font-weight: 600; padding: 0; }
.seletor-veiculo svg { width: 14px; height: 14px; }
.seletor-veiculo:active { opacity: 0.5; }
.folha-lista { margin-bottom: 16px; background: var(--fundo); }
.folha-lista .linha { min-height: 52px; }
.marca-check { width: 20px; height: 20px; flex-shrink: 0; }
.marca-check svg { width: 20px; height: 20px; }
.linha-subtitulo { min-height: 36px; padding-top: 16px; padding-bottom: 6px; font-size: 13px; text-transform: uppercase; color: var(--rotulo-2); }
.linha-nota { font-size: 13px; color: var(--rotulo-2); }
.avatar-quadrado { border-radius: 10px; }

.aviso-veiculo .linha-texto b { font-weight: 600; }
