* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: #f4f6f9;
  color: #1f2937;
  overflow-x: hidden;
}

.topo {
  background: #0f172a;
  color: white;
  padding: 14px 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 1;
  min-width: 0;
}

.logo {
  width: 78px;
  height: auto;
  object-fit: contain;
  display: block;
}

.header-texto {
  min-width: 0;
}

.header-texto h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  color: #ffffff;
}

.header-texto p {
  margin: 6px 0 0;
  font-size: 13px;
  color: #cbd5e1;
}

.menu-area {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: flex-end;
  flex-shrink: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.menu {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.menu a {
  color: white;
  text-decoration: none;
  font-weight: bold;
  padding: 8px 14px;
  border-radius: 8px;
  transition: 0.2s ease;
  white-space: nowrap;
}

.menu a:hover {
  background: rgba(255, 255, 255, 0.12);
}

.menu a.ativo {
  background: #2563eb;
}

.session-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: #cbd5e1;
  font-size: 14px;
  justify-content: flex-end;
}

.container {
  max-width: 1200px;
  margin: 28px auto;
  padding: 0 20px;
}

.page-header {
  margin-bottom: 20px;
}

.page-header h2 {
  margin: 0;
  font-size: 22px;
  color: #0f172a;
}

.page-header p {
  margin: 6px 0 0;
  color: #64748b;
  font-size: 14px;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-backup {
  background: #0f766e;
  color: white;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  transition: 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
}

.card img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  object-position: center;
}

.card-content {
  padding: 16px;
}

.card h3 {
  margin: 0 0 10px;
  color: #0f172a;
  font-size: 20px;
}

.card p {
  margin: 6px 0;
  font-size: 14px;
  color: #334155;
}

.status {
  display: inline-block;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: bold;
  margin-top: 10px;
  margin-bottom: 10px;
}

.status.disponivel {
  background: #dcfce7;
  color: #166534;
}

.status.em-uso {
  background: #fee2e2;
  color: #991b1b;
}

button {
  padding: 12px 14px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: 0.2s ease;
}

button:hover {
  opacity: 0.95;
}

button:focus-visible,
.menu a:focus-visible {
  outline: 3px solid #60a5fa;
  outline-offset: 3px;
}

.btn-retirar {
  background: #16a34a;
  color: white;
  margin-top: 12px;
  width: 100%;
}

.btn-devolver {
  background: #dc2626;
  color: white;
  margin-top: 12px;
  width: 100%;
}

.btn-secundario {
  background: #64748b;
  color: white;
}

.form-box,
.list-box {
  background: white;
  padding: 22px;
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  margin-bottom: 22px;
}

.form-box h2,
.list-box h2 {
  margin-top: 0;
  margin-bottom: 18px;
  color: #0f172a;
  font-size: 22px;
}

form {
  display: grid;
  gap: 12px;
}

.campo-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #334155;
}

.campo-check input {
  width: auto;
  min-height: auto;
}

.campo-ajuda {
  margin: 0;
  font-size: 13px;
  color: #64748b;
}

input,
select,
textarea,
button {
  font-family: inherit;
}

form input,
form select,
form textarea,
.campo input,
.campo select,
.campo textarea,
.filtro-item input,
.filtro-item select {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 15px;
  background: #fff;
  min-height: 46px;
}

form input:focus,
form select:focus,
form textarea:focus,
.campo input:focus,
.campo select:focus,
.campo textarea:focus,
.filtro-item input:focus,
.filtro-item select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

form button,
.filtro-botao button:not(.btn-secundario),
#btnConfirmarModal {
  background: #2563eb;
  color: white;
}

#listaVeiculos,
#listaMotoristas,
#listaHistorico {
  display: grid;
  gap: 12px;
}

.item-lista {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  overflow-wrap: anywhere;
}

.item-lista strong {
  color: #0f172a;
}

.item-lista-status {
  margin: 8px 0 0;
  color: #475569;
  font-size: 14px;
}

.status-feedback {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
}

.status-feedback.sucesso {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.status-feedback.erro {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.item-lista-acoes,
.historico-acoes {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: stretch;
}

.item-lista button,
.historico-acoes button {
  width: auto;
  padding: 10px 14px;
}

.item-lista button:first-child,
.historico-acoes button {
  background: #2563eb;
  color: white;
}

.historico-acoes .btn-secundario {
  background: #64748b;
  color: white;
}

.item-lista button:last-child {
  background: #dc2626;
  color: white;
}

.filtros-grid {
  display: grid;
  gap: 14px;
  align-items: end;
}

.filtros-grid-historico {
  grid-template-columns: 2fr 1fr 1fr 1fr auto auto;
}

.historico-abas {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.historico-aba {
  background: #e2e8f0;
  color: #334155;
  min-width: 180px;
}

.historico-aba.ativo {
  background: #2563eb;
  color: white;
}

.filtro-item {
  display: flex;
  flex-direction: column;
}

.filtro-item label {
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: bold;
  color: #334155;
}

.filtro-texto {
  min-width: 0;
}

.filtro-botao {
  justify-content: flex-end;
}

.filtro-botao button {
  height: 46px;
  min-width: 130px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: end;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 999;
}

.hidden {
  display: none;
}

.anexo-resumo {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid #dbe2ea;
  border-radius: 10px;
  background: #f8fafc;
  color: #334155;
  font-size: 14px;
}

.anexo-preview {
  display: block;
  margin-top: 12px;
  max-width: 100%;
  max-height: 260px;
  border-radius: 12px;
  border: 1px solid #dbe2ea;
  object-fit: contain;
  background: #fff;
}

.anexo-preview.hidden {
  display: none;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 650px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.modal-header {
  background: #0f172a;
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.btn-fechar {
  background: transparent;
  color: white;
  font-size: 26px;
  padding: 0;
  width: auto;
}

.campo {
  margin-bottom: 16px;
}

.campo label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
}

.campo-ajuda {
  display: block;
  margin-top: 8px;
  color: #64748b;
  font-size: 12px;
}

.fotos-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 10px;
}

.foto-slot {
  border: 1px solid #d9e2ec;
  border-radius: 16px;
  padding: 12px;
  background: linear-gradient(180deg, #fbfdff 0%, #f4f8fc 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.foto-slot:hover {
  border-color: #bfdbfe;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.foto-slot.preenchido {
  border-color: #93c5fd;
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.12);
}

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

.foto-card-botao {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
}

.foto-card-botao:hover,
.foto-card-botao:focus-visible {
  opacity: 1;
}

.foto-card-botao:focus-visible .foto-preview-wrap {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.18);
}

.foto-slot-topo {
  display: block;
}

.foto-slot-titulo {
  display: block;
}

.foto-slot-titulo strong {
  color: #0f172a;
  font-size: 14px;
  display: block;
  margin-bottom: 8px;
}

.btn-foto-limpar {
  padding: 7px 11px;
  font-size: 12px;
  min-height: auto;
  box-shadow: none;
}

.foto-slot-acoes {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-foto-galeria {
  background: #475569;
  color: white;
  flex: 1 1 180px;
  min-height: 44px;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.btn-foto-galeria:active {
  background: #334155;
}

.foto-slot input[type="file"] {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: 1px dashed #cbd5e1;
  background: #ffffff;
}

.foto-preview-wrap {
  min-height: 240px;
  border-radius: 18px;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  position: relative;
}

.foto-slot.preenchido .foto-preview-wrap {
  border: 2px solid #93c5fd;
  background: #ffffff;
}

.foto-preview {
  width: 100%;
  height: 240px;
  object-fit: cover;
  border-radius: 14px;
  display: block;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
}

.foto-preview.hidden {
  display: none;
}

.foto-preview-placeholder {
  color: #475569;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  max-width: 170px;
  line-height: 1.4;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.foto-slot.preenchido .foto-preview-placeholder {
  display: none;
}

.foto-slot:not(.preenchido) .foto-slot-acoes .btn-foto-limpar {
  display: none;
}

.checklist-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid #e5e7eb;
}

.checklist-vazio {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  color: #475569;
  font-size: 14px;
}

.checklist-item:last-child {
  border-bottom: none;
}

.checklist-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.checklist-item-nome {
  font-weight: bold;
  font-size: 14px;
  color: #0f172a;
  flex: 1;
}

.checklist-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#usuarioAtual {
  overflow-wrap: anywhere;
}

.btn-checklist-ok,
.btn-checklist-defeito {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  border: 2px solid transparent;
}

.btn-checklist-ok {
  background: #dcfce7;
  color: #166534;
}

.btn-checklist-ok.ativo {
  background: #16a34a;
  color: white;
  border-color: #16a34a;
}

.btn-checklist-defeito {
  background: #fee2e2;
  color: #dc2626;
}

.btn-checklist-defeito.ativo {
  background: #dc2626;
  color: white;
  border-color: #dc2626;
}

.checklist-obs {
  width: 100%;
  margin-top: 6px;
  display: none;
}

.checklist-obs.visivel {
  display: block;
}

#assinaturaCanvas {
  width: 100%;
  height: min(180px, 40vh);
  max-width: 100%;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  background: #fff;
  touch-action: none;
  display: block;
}

.assinatura-acoes {
  margin-top: 10px;
}

.modal-footer {
  margin-top: 18px;
}

#btnConfirmarModal {
  width: 100%;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f172a, #1d4ed8);
}

.login-shell {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: white;
  border-radius: 18px;
  padding: 32px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
}

.login-logo {
  width: 120px;
  display: block;
  margin: 0 auto 18px;
}

.login-card h1 {
  margin: 0 0 8px;
  text-align: center;
  color: #0f172a;
}

.login-card p {
  margin: 0 0 18px;
  text-align: center;
  color: #64748b;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  font-size: 14px;
  font-weight: bold;
  color: #334155;
}

.login-message {
  min-height: 22px;
  margin-top: 14px;
  color: #b91c1c;
  font-weight: bold;
}

@media (max-width: 1100px) {
  .filtros-grid-historico {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 900px) {
  .filtros-grid-historico {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .topo {
    padding: 12px 14px;
  }

  .header-content,
  .header-left,
  .menu-area {
    width: 100%;
  }

  .header-content,
  .menu-area {
    flex-direction: column;
    align-items: stretch;
  }

  .header-left {
    justify-content: flex-start;
  }

  .logo {
    width: 50px;
  }

  .header-texto h1 {
    font-size: 18px;
  }

  .menu {
    gap: 6px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .menu a {
    padding: 6px 10px;
    text-align: center;
  }

  .container {
    margin: 20px auto;
    padding: 0 14px;
  }

  .cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .filtros-grid-historico {
    grid-template-columns: 1fr 1fr;
  }

  .card img {
    height: 180px;
  }

  .modal-content {
    max-width: 100%;
  }

  .item-lista-acoes,
  .historico-acoes,
  .top-actions,
  .session-box {
    flex-direction: column;
    align-items: stretch;
  }

  .item-lista button,
  .historico-acoes button,
  .top-actions button,
  .filtro-botao button,
  .session-box button {
    width: 100%;
  }

  .historico-aba {
    width: 100%;
  }

  .login-card {
    padding: 24px;
  }
}

@media (max-width: 480px) {
  .topo {
    padding: 10px 12px;
  }

  .header-content {
    gap: 12px;
  }

  .header-left {
    gap: 12px;
    align-items: flex-start;
  }

  .logo {
    width: 40px;
  }

  .header-texto h1 {
    font-size: 16px;
  }

  .header-texto p {
    font-size: 11px;
  }

  .menu {
    gap: 8px;
    grid-template-columns: 1fr;
  }

  .menu a {
    padding: 8px 10px;
  }

  .container {
    margin: 16px auto;
    padding: 0 12px;
  }

  .page-header {
    margin-bottom: 14px;
  }

  .page-header h2 {
    font-size: 18px;
  }

  .page-header p {
    font-size: 12px;
  }

  .top-actions {
    margin-bottom: 14px;
  }

  .cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card img {
    height: 150px;
  }

  .card-content {
    padding: 12px;
  }

  .card h3 {
    font-size: 16px;
  }

  .card p {
    font-size: 12px;
  }

  button {
    min-height: 44px;
    padding: 10px 12px;
  }

  .form-box,
  .list-box {
    padding: 16px;
    margin-bottom: 16px;
  }

  .form-box h2,
  .list-box h2 {
    font-size: 18px;
  }

  form {
    gap: 10px;
  }

  form input,
  form select,
  form textarea,
  .campo input,
  .campo select,
  .campo textarea,
  .filtro-item input,
  .filtro-item select {
    padding: 10px;
  }

  .item-lista {
    padding: 12px;
  }

  .item-lista strong {
    font-size: 13px;
  }

  .item-lista button,
  .historico-acoes button {
    padding: 8px 10px;
  }

  .filtros-grid-historico {
    grid-template-columns: 1fr;
  }

  .filtro-botao button {
    min-width: 100%;
  }

  .modal {
    padding: 12px;
  }

  .modal-content {
    max-width: 95vw;
  }

  .modal-header {
    padding: 12px 16px;
  }

  .modal-body {
    padding: 14px;
  }

  .campo {
    margin-bottom: 12px;
  }

  .campo label {
    font-size: 13px;
  }

  .fotos-grid {
    grid-template-columns: 1fr;
  }

  .foto-slot-topo {
    flex-direction: column;
    align-items: stretch;
  }

  .foto-slot-acoes {
    flex-direction: column;
  }

  .btn-foto-galeria,
  .btn-foto-limpar {
    width: 100%;
    flex: none;
  }


  .checklist-item {
    padding: 8px 0;
  }

  .checklist-item-header,
  .checklist-toggle {
    width: 100%;
  }

  .checklist-toggle button {
    flex: 1 1 100%;
  }

  .checklist-item-nome {
    font-size: 12px;
  }

  .btn-checklist-ok,
  .btn-checklist-defeito {
    padding: 5px 10px;
  }

  .checklist-obs {
    min-height: calc(2 * 1.4em + 22px);
  }
}
