:root {
  font-family: Arial, Helvetica, sans-serif;
  color: #303944;
  background: #fff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --red: #ef0010;
  --ink: #38414a;
  --line: #d9dde0;
  --green: #21653d;
  --card-ink: #111;
  --card-bar: #454c53;
}

* { box-sizing: border-box; }
body { margin: 0; }

.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid #e3e3e3;
  color: #B5121B;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(calc((100vw - 1180px) / 2), 28px);
  position: relative;
}
.brand { display: flex; align-items: center; flex: 0 0 112px; }
.brand img {
  width: 108px;
  height: auto;
  object-fit: contain;
}
.topbar > span { width: 112px; flex: 0 0 112px; }
.topbar strong {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(66vw, 720px);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .4px;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

main { max-width: 1180px; margin: 26px auto 0; padding: 0 14px; }
.toolbar {
  border-block: 1px solid var(--line);
  padding: 15px 0 12px;
  position: relative;
}
.toolbar label, .eyebrow {
  font-size: 9px;
  letter-spacing: 1.4px;
  color: #46515d;
  font-weight: 700;
}
.toolbar > label { display: block; }
.searchline { display: flex; gap: 8px; margin-top: 7px; }
.searchline input {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 13px;
  font-size: 14px;
  flex: 1;
  min-width: 0;
  color: #27313a;
}
.searchline input:focus { outline: 2px solid #f6a0a5; outline-offset: 1px; }
.primary, .outline, .sync, .upload {
  height: 36px;
  border-radius: 4px;
  border: 1px solid var(--red);
  background: var(--red);
  color: #fff;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.primary:disabled { opacity: .5; cursor: default; }
.searchline .sync {
  width: 36px;
  flex: 0 0 36px;
  font-size: 17px;
  padding: 0;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.visually-hidden[data-state="error"] {
  position: static !important;
  width: auto;
  height: auto;
  margin: 6px 0 0;
  overflow: visible;
  clip: auto;
  color: #bd0010;
  font-size: 11px;
  white-space: normal;
}

.result { padding-top: 20px; }
.personline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 18px;
}
.personline h1 { font-size: 20px; line-height: 1.2; margin: 3px 0; }
.personline p { font-size: 13px; margin: 3px 0; color: #606a73; }
.actions { display: flex; align-items: center; gap: 8px; }
.outline { background: #fff; color: #3d4148; border-color: #c4c7cb; }
.upload {
  height: 36px;
  display: flex;
  align-items: center;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.cards { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; align-items: flex-start; padding-inline: 8px; }
.badge {
  width: min(45%, 290px);
  aspect-ratio: 2 / 3;
  flex: 0 1 290px;
  border: 1px solid #303030;
  background: #fff;
  overflow: hidden;
  color: var(--card-ink);
  font-family: Calibri, Arial, Helvetica, sans-serif;
  position: relative;
}

.front-panel {
  width: 100%;
  height: 100%;
  padding: 5px 6px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.front-head {
  height: 59px;
  flex: 0 0 59px;
  position: relative;
  display: flex;
  align-items: center;
}
.front-head .enaex-logo {
  width: 96px;
  height: 38px;
  object-fit: contain;
  object-position: left center;
}
.credential {
  position: absolute;
  top: 0;
  right: 5px;
  width: 45px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.seal { width: 38px; height: 38px; margin-top: 3px; object-fit: contain; flex: 0 0 38px; }
.badge-register {
  width: 44px;
  height: 25px;
  margin-top: 8px;
  border: 1px solid #222;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  line-height: 1.1;
}
.badge-register b { font-size: 6.8px; }
.badge-register span { font-size: 8.5px; }
.version { position: absolute; top: 0; right: 0; font-size: 6px; }
.portrait-row {
  height: 95px;
  flex: 0 0 95px;
  display: grid;
  grid-template-columns: 29% 1fr;
  gap: 14px;
  align-items: center;
}
.portrait {
  width: 100%;
  height: 94px;
  object-fit: cover;
  border: 1px solid #555;
  background: #e5e8e9;
}
.photo-empty {
  display: grid;
  place-items: center;
  color: #858b90;
  font-size: 8px;
  letter-spacing: 1px;
}
.portrait.photo-failed { visibility: hidden; }
.identity-fields { display: flex; flex-direction: column; gap: 5px; min-width: 0; align-self: end; }
.identity-fields .field { height: 38px; padding-block: 2px; }
.identity-fields .field span { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; text-overflow: clip; line-height: 1.12; }
.field {
  min-width: 0;
  height: 32px;
  padding: 3px 4px;
  border: 1px solid #222;
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.15;
  overflow: hidden;
}
.field b { font-size: 6px; letter-spacing: .2px; }
.field span {
  font-size: 7.8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.microgrid { display: grid; grid-template-columns: 2.2fr 1fr; height: 28px; flex: 0 0 28px; margin-top: 8px; }
.microgrid .field { height: 28px; }
.microgrid .field + .field { border-left: 0; }

.restricted {
  min-height: 62px;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 2.2fr 1fr;
  border: 1px solid #333;
  overflow: hidden;
  margin-top: 7px;
}
.restricted-areas, .validity-column { min-width: 0; padding: 2px 3px; }
.validity-column { border-left: 1px solid #555; }
.restricted-heading {
  min-height: 12px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 2px;
  border-bottom: 1px solid #666;
  font-size: 5.8px;
  line-height: 1.1;
  white-space: nowrap;
}
.validity-column .restricted-heading { justify-content: center; }
.restricted ul, .training-group ul { list-style: none; padding: 0; margin: 2px 0 0; }
.restricted li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2px;
  font-size: 6.5px;
  line-height: 1.25;
  white-space: nowrap;
}
.restricted-areas ul { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; height: auto; margin-top: 3px; }
.restricted-areas li { justify-content: flex-start; }
.area-status {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  display: inline-block;
  border: 1px solid #111;
  background: #fff;
  margin-right: 4px;
}
.area-status.is-active {
  background: #111;
}
.area-name { flex: 1 1 auto; }
.restricted li span { overflow: hidden; text-overflow: ellipsis; }
.restricted li b { font-weight: 700; }
.validity-column ul { display: grid; grid-template-rows: repeat(5, 1fr); height: calc(100% - 14px); margin-top: 1px; }
.validity-column li { justify-content: center; flex-direction: column; text-align: center; border-bottom: 1px solid #666; font-size: 5.8px; }
.validity-column li:last-child { border-bottom: 0; }
.validity-column li b { font-size: 5.3px; }
.validity {
  height: 41px;
  flex: 0 0 41px;
  background: var(--green);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .05px;
  text-align: center;
  display: grid;
  place-content: center;
  gap: 2px;
  padding: 3px;
}

.back-panel { width: 100%; height: 100%; display: flex; flex-direction: column; }
.permissions { flex: 1 1 auto; min-height: 0; padding: 5px 5px 0; overflow: hidden; }
.training-group { margin-bottom: 4px; }
.back-head {
  min-height: 15px;
  background: var(--card-bar);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 3px;
  padding: 2px 4px;
  font-size: 7px;
  font-weight: 700;
  line-height: 1.1;
}
.training-group ul { margin: 2px 3px 0; }
.training-group li {
  display: flex;
  justify-content: space-between;
  gap: 3px;
  font-size: 7.1px;
  line-height: 1.4;
  white-space: nowrap;
}
.training-group li span:first-child { overflow: hidden; text-overflow: ellipsis; }
.training-group li b { flex: 0 0 auto; font-weight: 400; }
.permission-empty { color: #666; font-size: 7px; }
.authorization { flex: 0 0 auto; margin: auto 5px 5px; }
.authorization > .back-head { min-height: 16px; }
.license {
  height: 43px;
  border: 1px solid #333;
  border-top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 3px;
  gap: 2px;
  font-size: 6px;
}
.license span { width: 58%; border-top: 1px solid #333; }
.license b { font-size: 6px; font-weight: 400; }
.signature {
  height: 40px;
  border: 1px solid #333;
  border-top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 3px;
  gap: 2px;
}
.signature span { width: 58%; border-top: 1px solid #333; }
.signature b { font-size: 5.8px; font-weight: 400; }

.sides {
  max-width: 594px;
  margin: 8px auto 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  text-align: center;
  font-size: 10px;
  color: #737d85;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.empty, .error { padding: 28px 0; font-size: 13px; color: #707a83; }
.error { color: #bd0010; }
.outline:disabled { opacity: .45; cursor: default; }
.sheet-dialog {
  width: min(1180px, 94vw);
  max-width: none;
  max-height: 84vh;
  padding: 18px;
  border: 1px solid #cfd4d8;
  color: #303944;
  background: #fff;
}
.sheet-auth-dialog {
  width: min(390px, 92vw);
  max-width: none;
  padding: 18px;
  border: 1px solid #cfd4d8;
  color: #303944;
  background: #fff;
}
.pdf-dialog {
  width: min(620px, 94vw);
  max-width: none;
  max-height: 86vh;
  padding: 18px;
  border: 1px solid #cfd4d8;
  color: #303944;
  background: #fff;
}
.pdf-dialog::backdrop { background: rgb(21 29 36 / 48%); }
.pdf-hint { margin: 9px 0 12px; color: #68727b; font-size: 12px; }
#pdf-search { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 3px; font: inherit; }
.pdf-selection-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.pdf-selection-actions .outline { height: 32px; font-size: 11px; }
#pdf-selection-count { margin-left: auto; color: #65707a; font-size: 11px; }
.pdf-staff-list { max-height: 48vh; overflow: auto; border: 1px solid var(--line); }
.pdf-staff-option { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 7px 10px; border-bottom: 1px solid #e6e8ea; cursor: pointer; }
.pdf-staff-option:last-child { border-bottom: 0; }
.pdf-staff-option:hover { background: #fff6f6; }
.pdf-staff-option input { accent-color: var(--red); width: 16px; height: 16px; }
.pdf-staff-option span { display: grid; gap: 3px; }
.pdf-staff-option b { font-size: 12px; }
.pdf-staff-option small { color: #6d7780; font-size: 10px; }
.sheet-auth-dialog::backdrop { background: rgb(21 29 36 / 48%); }
#sheet-auth-form { display: grid; gap: 12px; }
.sheet-auth-label { font-size: 12px; font-weight: 700; }
.sheet-auth-input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font: inherit;
}
.sheet-auth-input:focus { outline: 2px solid #f6a0a5; outline-offset: 1px; }
.sheet-auth-error { margin: -4px 0 0; color: #bd0010; font-size: 12px; }
.sheet-auth-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.sheet-dialog::backdrop { background: rgb(21 29 36 / 48%); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.close-sheet {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  color: #3b444d;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.sheet-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 10px;
}
.sheet-tabs { display: flex; gap: 3px; }
.sheet-tab {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: #fff;
  color: #59636c;
  font-size: 13px;
  cursor: pointer;
}
.sheet-tab[aria-selected="true"] { border-color: var(--red); color: var(--ink); font-weight: 700; }
#sheet-filter {
  height: 36px;
  min-width: 130px;
  max-width: 280px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font: inherit;
  font-size: 12px;
  flex: 1;
}
#sheet-count { color: #67727b; font-size: 11px; white-space: nowrap; }
.sheet-content {
  max-height: 64vh;
  overflow: auto;
  border: 1px solid var(--line);
}
.sheet-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 11px; }
.sheet-table th, .sheet-table td {
  min-width: 112px;
  max-width: 280px;
  padding: 7px 9px;
  border-right: 1px solid #e3e6e8;
  border-bottom: 1px solid #e3e6e8;
  text-align: left;
  white-space: nowrap;
}
.sheet-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  color: #38414a;
  font-size: 10px;
  font-weight: 700;
  border-bottom: 2px solid #ead0d2;
}
.sheet-table th { vertical-align: top; }
.column-filter {
  display: block;
  width: 100%;
  min-width: 84px;
  height: 25px;
  margin-top: 6px;
  padding: 0 6px;
  border: 1px solid #d2d8dd;
  border-radius: 3px;
  background: #fff;
  color: #283039;
  font: inherit;
  font-size: 10px;
}
.column-filter:focus { outline: 2px solid #f6a0a5; outline-offset: 1px; }
.sheet-table th:first-child, .sheet-table td:first-child {
  position: sticky;
  left: 0;
}
.sheet-table th:first-child { z-index: 3; }
.sheet-table td:first-child { z-index: 1; background: #f6f7f8; font-weight: 700; }
.sheet-table tr:hover td { background: #fff6f6; }
.sheet-table tr:hover td:first-child { background: #fff0f1; }
.sheet-table td.cell-attention, .sheet-table tr:hover td.cell-attention {
  background: #fff0b8;
  color: #775000;
  font-weight: 700;
}
.sheet-table td.cell-expired, .sheet-table tr:hover td.cell-expired {
  background: #ffd9dc;
  color: #a10012;
  font-weight: 700;
}
.status-days { margin-left: 8px; color: #775000; font-size: 10px; font-weight: 600; }
.status-tooltip { position: relative; cursor: help; text-decoration: underline dotted; text-underline-offset: 2px; }
.cell-expired .status-tooltip .status-days { color: #a10012; }
.status-tooltip .status-days { display: none; position: absolute; z-index: 5; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); margin: 0; padding: 7px 9px; border-radius: 4px; background: #303944; color: #fff; white-space: nowrap; box-shadow: 0 2px 8px rgb(0 0 0 / 20%); }
.status-tooltip:hover .status-days, .status-tooltip:focus .status-days { display: block; }
.sheet-empty { padding: 22px; color: #707a83; font-size: 13px; }
footer {
  max-width: 1180px;
  margin: 28px auto 0;
  border-top: 1px solid #3d4148;
  padding: 12px 14px 22px;
  color: #8a8f96;
  font-size: 9px;
  letter-spacing: 1.4px;
  text-align: right;
  text-transform: uppercase;
}
footer i {
  display: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  margin-right: 8px;
}

@media (max-width: 700px) {
  main { margin-top: 16px; }
  .topbar { padding: 0 14px; }
  .brand { flex-basis: 98px; }
  .brand img { width: 96px; height: auto; }
  .topbar strong { position: static; width: auto; min-width: 0; flex: 1; margin-left: 12px; transform: none; font-size: clamp(11px, 1.8vw, 14px); text-align: right; white-space: normal; }
  .topbar > span { display: none; }
  .toolbar { padding-bottom: 12px; }
  .cards { gap: 14px; padding-inline: 0; }
  .badge { width: min(47%, 290px); flex-basis: min(47%, 290px); }
  .personline { align-items: flex-start; gap: 12px; flex-direction: column; }
  .actions { flex-wrap: wrap; }
  .searchline { flex-wrap: wrap; }
  .searchline input { flex: 1 1 100%; }
}

@media (max-width: 640px) {
  .cards { flex-direction: column; align-items: center; }
  .badge { width: min(100%, 290px); flex: 0 1 290px; }
  .sides { display: none; }
  .personline h1 { font-size: 18px; }
  .searchline { gap: 6px; }
  .searchline input { padding: 0 9px; font-size: 13px; }
  .primary, .outline { padding: 0 12px; }
  .sheet-dialog { width: 96vw; max-height: 90vh; padding: 12px; }
  .sheet-auth-dialog { padding: 14px; }
  .pdf-dialog { padding: 14px; }
  .sheet-controls { align-items: stretch; flex-direction: column; gap: 6px; }
  .sheet-tabs { width: 100%; }
  .sheet-tab { flex: 1; padding: 0 5px; }
  #sheet-filter { max-width: none; }
  .sheet-content { max-height: 66vh; }
}

@media (max-width: 360px) {
  .topbar { padding-inline: 10px; }
  .brand { flex-basis: 92px; }
  .brand img { width: 90px; height: auto; }
  .topbar strong { font-size: 11px; margin-left: 8px; }
  .actions { gap: 6px; }
  .upload, .primary, .outline, .sync { font-size: 11px; padding-inline: 8px; }
  .searchline .sync { padding: 0; }
}

@media print {
  @page { size: 54mm 81mm; margin: 0; }
  body { margin: 0; }
  .topbar, main > .toolbar, .personline, .sides, footer, .empty, .error { display: none !important; }
  main { margin: 0; padding: 0; max-width: none; }
  .result { padding: 0; }
  .cards { display: block; }
  .badge {
    width: 54mm;
    height: 81mm;
    aspect-ratio: auto;
    outline-offset: -1mm;
    box-shadow: none;
    break-after: page;
  }
  .badge * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---- Faixa superior Enaex (ferramenta, não hub): grafite, filete vermelho, logo, título e unidade ---- */
.enaex-band { width: 100vw; margin-left: calc(50% - 50vw); position: sticky; top: 0; z-index: 50; display: grid; grid-template-columns: 1fr minmax(0, auto) 1fr; align-items: center; gap: 16px; box-sizing: border-box; height: 50px; padding: 0 35px 0 45px; background: #3a434b; border-bottom: 3px solid #E20613; color: #fff; }
.enaex-band__logo { justify-self: start; min-width: 0; }
.enaex-band__logo img { display: block; width: 90px; height: auto; }
.enaex-band__title { min-width: 0; font: 700 20px/1 Arial, Helvetica, sans-serif; color: #fff; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.enaex-band__unit { justify-self: end; font: 500 10.5px/1 Arial, Helvetica, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: #c4c7cb; white-space: nowrap; }
@media (max-width: 640px) { .enaex-band { gap: 10px; grid-template-columns: auto minmax(0, 1fr) auto; padding: 0 16px; } .enaex-band__logo img { width: 64px; } .enaex-band__title { font-size: 15px; } .enaex-band__unit { font-size: 9px; letter-spacing: .08em; } }
