:root {
  --fundo: #f2f5f9;
  --superficie: #ffffff;
  --tinta: #14213d;
  --suave: #52607a;
  --linha: #dde3ec;
  --marca: #1f3a5f;
  --marca-clara: #2d5486;
  --acento: #22a06b;
  --acento-suave: #e6f6ee;
  --alerta-amarelo: #b45309;
  --alerta-amarelo-fundo: #fff7e6;
  --perigo: #9f1239;
  --perigo-fundo: #fff1f2;
  --ok: #166534;
  --ok-fundo: #ecfdf3;
  --sombra: 0 12px 32px rgba(20, 33, 61, 0.12);
  --nav: 4.6rem;
  color-scheme: light;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--tinta);
  background: var(--fundo);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { min-height: 100vh; min-height: 100dvh; touch-action: manipulation; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { display: block; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background: radial-gradient(900px 420px at 50% -10%, var(--marca-clara), var(--marca));
}
.cartao {
  width: min(440px, 100%);
  background: var(--superficie);
  border-radius: 24px;
  padding: 28px 22px 22px;
  box-shadow: var(--sombra);
}
.login img { width: 96px; height: auto; margin: 0 auto 14px; }
.login h1 { font-size: 1.6rem; letter-spacing: -0.03em; text-align: center; }
.login-sub { margin: 8px 0 18px; color: var(--suave); line-height: 1.45; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
}
input, select, textarea {
  min-height: 48px;
  font-size: 16px;
  border: 1px solid var(--linha);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--tinta);
  width: 100%;
}
input[type="search"] { margin-bottom: 8px; }
.aba > input[type="search"] { margin-bottom: 12px; }
textarea { min-height: 88px; resize: vertical; }
label.check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
}
label.check input { width: 1.25rem; height: 1.25rem; min-height: 0; flex: none; }

button[type="submit"], .btn-secundario, .btn-principal {
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  padding: 0 16px;
  font-weight: 700;
}
button[type="submit"], .btn-principal {
  background: var(--marca);
  color: #fff;
}
.btn-principal { width: 100%; margin-bottom: 14px; }
#btn-entrar { width: 100%; margin-top: 4px; }
#btn-vistoria { width: 100%; min-height: 54px; font-size: 1.1rem; margin-top: 8px; }
button:disabled { opacity: 0.65; cursor: default; }
.btn-secundario {
  background: transparent;
  color: var(--marca);
  border: 1px solid var(--marca);
}
#btn-sair, #btn-instalar {
  background: transparent;
  color: var(--acento);
  border: 1px solid transparent;
  min-height: 44px;
  font-weight: 700;
  width: 100%;
  margin-top: 8px;
}
#btn-sair { width: auto; margin: 0; color: #fff; }
#btn-instalar { border-color: var(--acento); border-radius: 999px; }

.alerta, .aviso, .nota {
  border-radius: 12px;
  padding: 10px 12px;
  line-height: 1.4;
  margin: 0 0 12px;
}
.alerta { background: var(--perigo-fundo); color: var(--perigo); }
.alerta.ok { background: var(--ok-fundo); color: var(--ok); }
.aviso, .nota { background: var(--acento-suave); color: var(--marca); }

.cabecalho {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--marca);
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
}
.topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: min(860px, 100%); margin: 0 auto; }
.seletor { margin: 0; color: #d6e0ee; min-width: min(220px, 46vw); }
.seletor select { min-height: 40px; background: var(--marca-clara); color: #fff; border-color: #4a6fa0; }
.topo-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topo-id strong { font-size: 1.05rem; }
.topo-id span { color: #d6e0ee; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.marca-mobile { display: block; height: 36px; width: auto; margin: 0 auto 10px; }

.conteudo {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav) + 24px + env(safe-area-inset-bottom));
}
.aba-head { margin-bottom: 14px; }
.aba-head h2 { font-size: 1.35rem; letter-spacing: -0.02em; }
.sub { margin-top: 4px; color: var(--suave); line-height: 1.4; }
.aba form, .cartao-item {
  background: var(--superficie);
  border: 1px solid var(--linha);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
}
.aba:not(.ativa) { display: none; }
.aba form, .cartao-item, .alerta, label { scroll-margin-top: 150px; }
.grade { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 700px) {
  .grade { grid-template-columns: 1fr 1fr; }
}
.acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.acoes button { flex: 1; }

.filtros {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-bottom: 12px;
}
.filtros button { grid-column: 1 / -1; }
@media (min-width: 700px) {
  .filtros { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); align-items: end; }
  .filtros button { grid-column: auto; }
}

.lista { display: flex; flex-direction: column; gap: 10px; }
.vazio { color: var(--suave); padding: 8px 0 16px; }
.cartao-item h3 { font-size: 1.05rem; margin-bottom: 4px; }
.meta { color: var(--suave); font-size: 0.9rem; line-height: 1.4; }
.linha { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.selo {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--acento-suave);
  color: var(--marca);
  white-space: nowrap;
}
.selo.inativo { background: var(--perigo-fundo); color: var(--perigo); }
.selo.locacao { background: var(--alerta-amarelo-fundo); color: var(--alerta-amarelo); }
.cartao-item button {
  margin-top: 10px;
  margin-right: 6px;
  background: transparent;
  color: var(--marca);
  border: 1px solid var(--marca);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
}

/* Vistoria */
.bloco-titulo { font-size: 1.05rem; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.tipo-vistoria {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 1.05rem;
}
.tipo-vistoria.checkout { background: var(--alerta-amarelo-fundo); color: var(--alerta-amarelo); }
.tipo-vistoria.checkin { background: var(--ok-fundo); color: var(--ok); }
.secao-itens {
  border: 1px solid var(--linha);
  border-radius: 14px;
  padding: 4px 12px 8px;
  margin: 0 0 12px;
}
.secao-itens legend { font-weight: 700; padding: 0 6px; }
.secao-itens .secao-acoes { display: flex; justify-content: flex-end; }
.secao-itens .secao-acoes button {
  border: 0;
  background: transparent;
  color: var(--marca);
  font-weight: 700;
  min-height: 36px;
  padding: 0 4px;
}
.itens-grade { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 700px) {
  .itens-grade { grid-template-columns: 1fr 1fr; }
}
.item-check {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin: 0;
  padding: 4px 0;
  border-bottom: 1px solid var(--linha);
  font-size: 0.98rem;
  font-weight: 500;
}
.item-check input { width: 1.5rem; height: 1.5rem; min-height: 0; flex: none; accent-color: var(--acento); }
.item-check .selo { margin-left: auto; }

.fotos-grade {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
@media (min-width: 600px) { .fotos-grade { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .fotos-grade { grid-template-columns: repeat(4, 1fr); } }
.foto-slot {
  position: relative;
  margin: 0;
  aspect-ratio: 4 / 3;
  border: 2px dashed var(--linha);
  border-radius: 14px;
  background: var(--fundo);
  overflow: hidden;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--suave);
  cursor: pointer;
}
.foto-slot.preenchida { border-style: solid; border-color: var(--acento); }
.foto-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.foto-slot input { position: absolute; width: 1px; height: 1px; opacity: 0; min-height: 0; padding: 0; }
.foto-slot .foto-rotulo {
  position: relative;
  z-index: 1;
  font-size: 0.85rem;
  padding: 4px 8px;
}
.foto-slot.preenchida .foto-rotulo {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: rgba(20, 33, 61, 0.75);
  color: #fff;
  border-radius: 999px;
}
.foto-slot.processando { opacity: 0.6; }

.assinatura {
  border: 2px dashed var(--linha);
  border-radius: 14px;
  background: #fff;
  margin-bottom: 8px;
}
.assinatura canvas { display: block; width: 100%; height: 220px; touch-action: none; }

.progresso { height: 10px; background: var(--linha); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progresso span { display: block; height: 100%; width: 0; background: var(--acento); transition: width 0.2s; }

/* Histórico */
.detalhe-fotos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 12px; }
@media (min-width: 700px) { .detalhe-fotos { grid-template-columns: repeat(4, 1fr); } }
.detalhe-fotos a { display: block; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--fundo); }
.detalhe-fotos img { width: 100%; height: 100%; object-fit: cover; }
.detalhe-assinatura { max-width: 420px; width: 100%; border: 1px solid var(--linha); border-radius: 12px; background: #fff; }
.detalhe-itens { list-style: none; padding: 0; margin: 4px 0 12px; columns: 1; }
@media (min-width: 700px) { .detalhe-itens { columns: 2; } }
.detalhe-itens li { padding: 3px 0; break-inside: avoid; }
.detalhe-itens li.nao { color: var(--perigo); font-weight: 600; }

/* Catálogo */
.catalogo-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--linha); }
.catalogo-item.inativo span:first-child { text-decoration: line-through; color: var(--suave); }
.catalogo-item button {
  border: 1px solid var(--marca);
  background: transparent;
  color: var(--marca);
  border-radius: 999px;
  min-height: 34px;
  padding: 0 12px;
  font-weight: 700;
}

.abas {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  gap: 2px;
  background: var(--superficie);
  border-top: 1px solid var(--linha);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 3;
  overflow-x: auto;
}
.abas button {
  flex: 1 0 auto;
  min-width: 3.9rem;
  max-width: 7rem;
  border: 0;
  background: transparent;
  color: var(--suave);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  min-height: 48px;
}
.abas button[aria-selected="true"] { color: var(--acento); }
.abas svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.abas-marca { display: none; }

@media (min-width: 960px) {
  #tela-app {
    display: grid;
    grid-template-columns: 15rem minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    min-height: 100vh;
    min-height: 100dvh;
  }
  .cabecalho { grid-column: 2; grid-row: 1; }
  .conteudo {
    grid-column: 2;
    grid-row: 2;
    width: min(940px, 100%);
    margin: 0;
    padding-bottom: 32px;
  }
  .topo { width: min(940px, 100%); margin: 0; }
  .marca-mobile { display: none; }
  .abas {
    grid-column: 1;
    grid-row: 1 / span 2;
    position: sticky;
    top: 0;
    left: auto;
    right: auto;
    bottom: auto;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 4px;
    height: 100vh;
    height: 100dvh;
    background: var(--marca);
    border-top: 0;
    padding: 18px 12px;
  }
  .abas-marca {
    display: block;
    width: 72px;
    height: auto;
    margin: 0 auto 16px;
  }
  .abas button {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    max-width: none;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 12px;
    color: #d6e0ee;
    font-size: 0.95rem;
  }
  .abas button[aria-selected="true"] {
    color: var(--marca);
    background: #fff;
  }
}
