:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1e21;
  --muted: #6b7280;
  --border: #e2e4e9;
  --primary: #b11e23;      /* vermelho Motolab */
  --primary-dark: #8a161a;
  --accent: #c8102e;
  --graphite: #23262b;
  --ok: #1f8a4c;
  --warn: #a06a1f;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

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

.topbar {
  background: linear-gradient(180deg, #b11e23 0%, #8a161a 100%);
  border-bottom: 3px solid #23262b;
  color: #fff;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: 0.3px; }
.topbar .brand-logo { background: #fff; border-radius: 9px; padding: 5px 11px; display: inline-flex; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,0.18); }
.topbar .brand-logo img { height: 38px; width: auto; display: block; }
.topbar .brand-text { font-weight: 700; }
@media (max-width: 620px) { .topbar .brand-text { display: none; } }
.app-license { text-align: center; color: #9aa1ab; font-size: 11.5px; margin: 26px 0 18px; letter-spacing: 0.2px; }
.app-license-login { text-align: center; color: #9aa1ab; font-size: 11px; margin: 14px 0 0; }
.login-logo { text-align: center; margin: 0 0 10px; }
.login-logo img { width: 190px; max-width: 80%; height: auto; }
.topbar a { color: #fff; }
.topbar nav { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.topbar nav a { opacity: 0.9; }
.topbar nav a.active { opacity: 1; font-weight: 600; border-bottom: 2px solid #fff; }
.topbar .user-info { font-size: 13px; opacity: 0.85; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; color: var(--graphite); }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1000px) { .grid-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-6 { grid-template-columns: repeat(2, 1fr); }
}

/* Pedidos vindos do site */
.tag-site { display: inline-block; padding: 1px 7px; border-radius: 5px; background: #6d28d9; color: #fff;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; vertical-align: middle; }
.nav-pendentes .nav-contador { display: inline-block; min-width: 19px; padding: 1px 6px; margin-left: 5px;
  border-radius: 10px; background: #fff; color: var(--primary-dark); font-size: 11.5px; font-weight: 800; text-align: center; }
.aviso-pedido { border-left: 4px solid #6d28d9; background: #f6f2ff; }
.aviso-pedido h2 { color: #5b21b6; }
.pedido-dados { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 18px; margin: 10px 0 16px; }
.pedido-dados div span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.pedido-dados div strong { font-size: 15px; }

/* Painel de estados no início — cada cartão herda a cor do seu estado */
.estado-card { display: block; text-align: center; text-decoration: none; color: inherit;
  border-top: 3px solid var(--estado); transition: transform .12s ease, box-shadow .12s ease; }
.estado-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.10); }
.estado-card .estado-numero { font-size: 28px; font-weight: 700; color: var(--estado); line-height: 1.15; }
.estado-card.destaque { background: color-mix(in srgb, var(--estado) 8%, #fff); border-top-width: 4px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field { margin-bottom: 12px; }
input[type=text], input[type=number], input[type=date], input[type=time],
input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.checklist { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 16px; }
@media (max-width: 700px) { .checklist { grid-template-columns: 1fr 1fr; } }
.checklist label { display: flex; align-items: center; gap: 6px; font-weight: 400; color: var(--text); font-size: 14px; }
.checklist input { width: auto; }

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn.secondary:hover { background: #f0f3f8; }
.btn.danger { background: var(--accent); }
.btn.small { padding: 5px 10px; font-size: 12px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: #fafbfc; }
.table-wrap { overflow-x: auto; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash.success { background: #e6f4ea; color: #1f8a4c; }
.flash.error { background: #fbe7e9; color: #a01f2a; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
}
.login-box {
  background: #fff;
  padding: 32px;
  border-radius: var(--radius);
  width: 100%;
  max-width: 340px;
}
.login-box h1 { text-align: center; color: var(--primary-dark); }
.login-wrap { background: linear-gradient(160deg, #23262b 0%, #3a1114 60%, #6d1418 100%); }

.moto-diagram-wrap { position: relative; border: 1px solid var(--border); border-radius: 8px; background: #f9fafb; }
.moto-diagram-wrap svg { width: 100%; height: auto; display: block; cursor: crosshair; }
.damage-pin {
  position: absolute;
  width: 18px; height: 18px;
  margin-left: -9px; margin-top: -9px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.damage-list { list-style: none; padding: 0; margin: 10px 0 0; font-size: 13px; }
.damage-list li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--border); }

.legal-box {
  border: 1px solid var(--border);
  background: #fafbfc;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 12.5px;
  color: #333;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.5;
}

.parts-row { display: grid; grid-template-columns: 3fr 1fr 1fr auto; gap: 8px; margin-bottom: 6px; align-items: center; }

/* Impressão */
@page { size: A4; margin: 0; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .container { max-width: 100%; padding: 7mm 9mm 6mm; }
  .card { border: none; box-shadow: none; padding: 0; }
}
.print-sheet { font-family: Arial, Helvetica, sans-serif; color: #000; }
.print-sheet h1 { font-size: 20px; text-align: center; margin-bottom: 2px; }
.print-sheet .subtitle { text-align: center; color: #444; margin-bottom: 16px; font-size: 13px; }
.print-sheet table.info td { border: none; padding: 3px 4px; font-size: 13px; }
.print-sheet .section-title { background: #eee; padding: 4px 8px; font-weight: bold; font-size: 12px; text-transform: uppercase; margin-top: 14px; border: 1px solid #ccc; }
.print-sheet .box { border: 1px solid #ccc; padding: 8px; min-height: 40px; font-size: 13px; white-space: pre-wrap; }
.print-sheet .sig-line { margin-top: 40px; display: flex; justify-content: space-between; gap: 40px; }
.print-sheet .sig-line div { flex: 1; text-align: center; border-top: 1px solid #000; padding-top: 4px; font-size: 12px; }

/* Cabeçalho das folhas impressas (logo + identificação) */
.print-head { display: flex; align-items: center; gap: 20px; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 14px; }
.print-head .print-logo { width: 165px; height: auto; }
.print-head .print-logo.logo-boost { filter: contrast(2.1) brightness(0.5) saturate(1.5); }
.print-head .print-logo-text { font-size: 22px; font-weight: bold; letter-spacing: 1px; }
.print-head .print-head-text { flex: 1; text-align: right; }
.print-head .print-doc-title { font-size: 16px; font-weight: bold; text-transform: uppercase; letter-spacing: 0.4px; }
.print-head .print-oficina { font-size: 11px; color: #444; margin-top: 3px; }
.print-sheet .check-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px 12px; font-size: 12.5px; padding: 6px 4px; }
.print-sheet .check-line { font-size: 12.5px; padding: 6px 4px; }
.print-sheet .sig-line.single { justify-content: flex-start; }
.print-sheet .sig-line.single div { max-width: 64%; }
.print-sheet .legal-text { font-size: 11px; line-height: 1.45; }
.print-sheet .legal-text p { margin: 6px 0; }
.print-sheet .assinatura-print { max-height: 52px; max-width: 240px; display: block; margin: 2px 0 -2px; }
.print-sheet .sig-line.com-assinatura { margin-top: 14px; display: block; }
.print-sheet .sig-line.com-assinatura div { max-width: 64%; border-top: 1px solid #000; }
.print-sheet .col-2 p { margin: 0 0 4px; }
.print-sheet .col-2 { column-count: 2; column-gap: 20px; }
.print-sheet .consent-box { border: 1px solid #ccc; padding: 8px 10px; font-size: 12px; margin-top: 10px; }
@media print {
  .print-head { break-inside: avoid; }
  /* garantir que os pinos de dano e os separadores saem impressos a cores */
  .damage-pin, .section-title, .print-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .moto-diagram-wrap { break-inside: avoid; max-width: 100% !important; }
  .danos-wrap { break-inside: avoid; }
  /* compactar para a ficha caber numa folha A4 */
  .print-sheet { font-size: 11.5px; }
  .print-head { padding-bottom: 6px; margin-bottom: 8px; }
  .print-head .print-logo { width: 130px; }
  .print-sheet .section-title { margin-top: 6px; padding: 3px 6px; }
  .print-sheet .box { min-height: 18px; padding: 3px 6px; }
  .print-sheet table.info td { padding: 2px 4px; }
  .print-sheet .check-grid, .print-sheet .check-line { padding: 3px 4px; }
  .print-sheet .sig-line { margin-top: 8px; }
  .print-sheet .legal-text { font-size: 8.6px; line-height: 1.3; }
  .print-sheet .legal-text p { margin: 4px 0; }
  .print-sheet .sig-line.com-assinatura { margin-top: 4px; }
  .print-sheet .assinatura-print { max-height: 34px; max-width: 180px; margin: 0 0 -2px; }
  .print-sheet .sig-line.com-assinatura div { font-size: 9.5px; padding-top: 3px; }
  .print-sheet .nota-rodape { margin-top: 4px !important; padding-top: 3px !important; font-size: 8px !important; }
  .print-sheet .danos-wrap { margin-top: 2px; }
  .print-sheet .danos-lista .linha-vazia { height: 15px; margin-bottom: 2px; }
  .print-sheet .danos-moto { max-width: 56%; }
  .print-sheet .legal-text { font-size: 8.2px; }
}

/* Assinatura digital (tablet/telemóvel) */
.assinatura-wrap { border: 1px dashed var(--border); border-radius: 8px; padding: 8px; background: #fff; }
.assinatura-pad { width: 100%; height: 170px; touch-action: none; display: block; border-bottom: 1px solid var(--border); cursor: crosshair; }
.assinatura-acoes { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 10px; }
.assinatura-guardada { max-width: 320px; width: 100%; border: 1px solid var(--border); border-radius: 6px; background: #fff; display: block; margin: 6px 0 10px; }
.dados-extra { margin: 4px 0 6px; }
.dados-extra summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 10px; }

/* Danos: lista à esquerda, esquema da moto à direita */
.danos-wrap { display: flex; gap: 14px; align-items: flex-start; }
.danos-wrap .danos-lista { flex: 0 0 38%; font-size: 12px; }
.danos-wrap .danos-moto { flex: 1; }
.danos-wrap .danos-lista ol { margin: 2px 0 4px 18px; padding: 0; }
.danos-wrap .danos-lista ol li { margin-bottom: 3px; }
.danos-wrap .danos-lista .linha-vazia { border-bottom: 1px dotted #aaa; height: 17px; margin-bottom: 4px; color: #999; font-size: 11px; }
