* { box-sizing: border-box; }
body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #f7f8fa, #eef2f7);
  color: #1f2937;
  isolation: isolate;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("/assets/img/petrobras_logotype.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: min(62vw, 760px);
  opacity: 0.06;
  pointer-events: none;
  z-index: 0;
}
header {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  min-height: 96px;
  background: #0f766e;
  color: #ffffff;
}

.header-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.35vw, 14px);
  max-width: 100%;
}

.header-logo-icon {
  display: block;
  width: clamp(42px, 5.25vw, 65px);
  height: auto;
  flex: 0 0 auto;
}

.header-logo-text {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: clamp(1.24rem, 3.225vw, 2.82rem);
  font-weight: 800;
  font-style: italic;
  line-height: 1;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.session-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.session-user-label {
  font-weight: 700;
}

.auth-shell {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 96px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card,
.auth-modal-card {
  width: min(480px, 100%);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
  padding: 24px;
  backdrop-filter: blur(8px);
}

.auth-card h1,
.auth-modal-card h2 {
  margin: 0 0 8px;
}

.auth-copy {
  margin: 0 0 18px;
  color: #475569;
  line-height: 1.5;
}

.auth-field-label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 700;
  color: #0f172a;
}

.auth-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  font: inherit;
  color: #0f172a;
  background: #ffffff;
}

.auth-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.auth-actions button {
  flex: 1 1 140px;
}

.auth-status {
  min-height: 22px;
  margin: 14px 0 0;
  color: #334155;
  font-weight: 600;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  background: #0f766e;
  color: #ffffff;
}

.tabs {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
  padding: 12px 24px;
}

.tabs button.active {
  background: #134e4a;
}

main {
  position: relative;
  z-index: 1;
  padding: 10px 24px 24px;
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.events-wrap {
  padding-bottom: 8px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  background: #ffffff;
}
th, td {
  border: 1px solid #d1d5db;
  text-align: left;
  padding: 8px;
  font-size: 14px;
}

.inactive-users-section {
  margin-top: 24px;
}

.locations-actions-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.inactive-user-row td {
  color: #b91c1c;
}

.inactive-user-row .user-table-actions {
  color: inherit;
}

th { background: #f3f4f6; }
.events-table {
  min-width: 1680px;
  table-layout: fixed;
}
.events-table th,
.events-table td {
  vertical-align: top;
  text-align: center;
}
.events-table th:nth-child(1),
.events-table td:nth-child(1) {
  width: 64px;
}
.events-table th:nth-child(2),
.events-table td:nth-child(2) {
  width: 150px;
}
.events-table th:nth-child(3),
.events-table td:nth-child(3) {
  width: 88px;
}
.events-table th:nth-child(4),
.events-table td:nth-child(4) {
  width: 88px;
}
.events-table th:nth-child(5),
.events-table td:nth-child(5) {
  width: 96px;
}
.events-table th:nth-child(6),
.events-table td:nth-child(6) {
  width: 116px;
}
.events-table th:nth-child(7),
.events-table td:nth-child(7) {
  width: 136px;
}
.events-table th:nth-child(8),
.events-table td:nth-child(8) {
  width: 108px;
}
.events-table th:nth-child(9),
.events-table td:nth-child(9) {
  width: 84px;
}
.events-table th:nth-child(10),
.events-table td:nth-child(10) {
  width: 72px;
}
.events-table th:nth-child(11),
.events-table td:nth-child(11) {
  width: 116px;
}
.events-table th:nth-child(12),
.events-table td:nth-child(12) {
  width: 88px;
}
.events-table th:nth-child(13),
.events-table td:nth-child(13) {
  width: 220px;
}
.events-table th:nth-child(14),
.events-table td:nth-child(14) {
  width: 254px;
}
.event-cell {
  display: -webkit-box;
  overflow: hidden;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
  max-height: calc(1.35em * 2);
  word-break: break-word;
}
.event-details-button {
  min-width: 92px;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}
.modal-backdrop.hidden {
  display: none;
}
.modal-card {
  width: min(760px, 100%);
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
  padding: 18px;
}
.archive-modal-card {
  width: min(920px, 100%);
}
.archive-title-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.archive-storage-summary {
  margin: 0;
  color: #475569;
  font-weight: 600;
}
.modal-header {
  margin-bottom: 12px;
}
.event-details-text {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 12px;
  font: inherit;
  line-height: 1.45;
  color: #0f172a;
  background: #f8fafc;
}
.archive-list-wrap {
  max-height: 52vh;
  overflow: auto;
}
.archive-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.archive-filter-input {
  flex: 1;
  min-width: 240px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
}
.archive-summary,
.archive-page-info {
  color: #475569;
  font-weight: 600;
}
.archive-table {
  margin-top: 0;
}
.archive-table th,
.archive-table td {
  vertical-align: middle;
}
.archive-table th:nth-child(2),
.archive-table td:nth-child(2) {
  width: 110px;
  text-align: center;
}
.archive-table th:nth-child(3),
.archive-table td:nth-child(3) {
  width: 120px;
  text-align: center;
}
.archive-table th:last-child,
.archive-table td:last-child {
  width: 228px;
  text-align: center;
}
.archive-period {
  font-weight: 600;
  color: #0f172a;
}
.archive-record-count {
  font-weight: 600;
  color: #0f766e;
}
.archive-size {
  font-weight: 600;
  color: #1d4ed8;
}
.archive-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.archive-download-button,
.secondary-button {
  background: #1f2937;
}
.archive-delete-button {
  background: #b91c1c;
}
.archive-empty {
  margin: 14px 0 0;
  color: #475569;
}
.archive-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.hidden {
  display: none;
}
.status-ok { color: #065f46; }
.status-err { color: #991b1b; }
input.inline, select.inline {
  width: 100%;
  padding: 4px;
}
.pending-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.admin-password-editor {
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.admin-password-editor.active {
  display: flex;
}

.admin-password-label {
  font-weight: 700;
  color: #0f172a;
}

.admin-password-input {
  min-width: 180px;
  flex: 1 1 180px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
}

.pending-actions button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
@media (max-width: 800px) {
  body::before {
    background-size: min(78vw, 420px);
    background-position: center 46%;
    opacity: 0.05;
  }
  header {
    padding: 14px 12px;
    align-items: center;
    flex-direction: column;
    gap: 10px;
  }
  .header-brand {
    width: 100%;
    margin: 0 auto;
    gap: 10px;
    justify-content: center;
  }
  .tabs { flex-wrap: wrap; }
  .session-bar {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
  .auth-shell {
    padding: 16px 12px;
    min-height: calc(100vh - 126px);
  }
  .auth-card,
  .auth-modal-card {
    padding: 18px;
  }
  .auth-actions button {
    width: 100%;
  }
  main {
    padding: 8px 12px 16px;
  }
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .section-header button {
    width: 100%;
  }
  .locations-actions-bar {
    justify-content: stretch;
  }
  .locations-actions-bar button {
    width: 100%;
  }

  .responsive-table {
    border: 0;
    background: transparent;
  }
  .responsive-table thead {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
  }
  .responsive-table tr {
    display: block;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #ffffff;
    margin-top: 10px;
    overflow: hidden;
  }
  .responsive-table td {
    display: block;
    border: 0;
    border-bottom: 1px solid #e5e7eb;
    text-align: right;
    padding: 10px 12px 10px 44%;
    min-height: 38px;
    position: relative;
    word-break: break-word;
  }
  .responsive-table td:last-child {
    border-bottom: 0;
  }
  .responsive-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 12px;
    top: 10px;
    width: 38%;
    font-weight: 600;
    text-align: left;
    color: #374151;
  }
  .responsive-table td input.inline,
  .responsive-table td select.inline,
  .responsive-table td button {
    width: 100%;
  }
  .events-table {
    min-width: 2140px;
    table-layout: fixed;
  }
  .events-wrap {
    overflow-x: auto;
  }
  .events-table th:nth-child(1),
  .events-table td:nth-child(1) {
    width: 72px;
  }
  .events-table th:nth-child(2),
  .events-table td:nth-child(2) {
    width: 172px;
  }
  .events-table th:nth-child(3),
  .events-table td:nth-child(3) {
    width: 104px;
  }
  .events-table th:nth-child(4),
  .events-table td:nth-child(4) {
    width: 104px;
  }
  .events-table th:nth-child(5),
  .events-table td:nth-child(5) {
    width: 112px;
  }
  .events-table th:nth-child(6),
  .events-table td:nth-child(6) {
    width: 144px;
  }
  .events-table th:nth-child(7),
  .events-table td:nth-child(7) {
    width: 164px;
  }
  .events-table th:nth-child(8),
  .events-table td:nth-child(8) {
    width: 128px;
  }
  .events-table th:nth-child(9),
  .events-table td:nth-child(9) {
    width: 104px;
  }
  .events-table th:nth-child(10),
  .events-table td:nth-child(10) {
    width: 88px;
  }
  .events-table th:nth-child(11),
  .events-table td:nth-child(11) {
    width: 180px;
  }
  .events-table th:nth-child(12),
  .events-table td:nth-child(12) {
    width: 100px;
  }
  .events-table th:nth-child(13),
  .events-table td:nth-child(13) {
    width: 320px;
  }
  .events-table th:nth-child(14),
  .events-table td:nth-child(14) {
    width: 348px;
  }
  .events-table thead {
    clip: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    padding: 0;
    position: static;
    width: auto;
  }
  .events-table tr {
    display: table-row;
    border: 0;
    border-radius: 0;
    margin-top: 0;
    overflow: visible;
  }
  .events-table th,
  .events-table td {
    display: table-cell;
    text-align: center;
    padding: 8px;
    min-height: 0;
    position: static;
    border: 1px solid #d1d5db;
  }
  .events-table td::before {
    content: none;
  }
  .events-table .event-cell {
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .events-table .event-details-button {
    width: 100%;
    min-width: 112px;
  }
  .header-logo-icon {
    width: clamp(48px, 16vw, 66px);
  }
  .header-logo-text {
    font-size: clamp(1.35rem, 7vw, 2rem);
  }
  .modal-backdrop {
    padding: 12px;
  }
  .modal-card {
    padding: 14px;
  }
  .archive-table th:last-child,
  .archive-table td:last-child {
    width: 240px;
  }
  .archive-actions {
    flex-direction: column;
  }
  .archive-title-block {
    width: 100%;
  }
  .archive-toolbar,
  .archive-pagination,
  .modal-footer {
    flex-direction: column;
  }
  .archive-filter-input {
    min-width: 0;
    width: 100%;
  }
  .archive-pagination button,
  .modal-footer button {
    width: 100%;
  }
  .event-details-text {
    min-height: 220px;
  }
  .pending-actions {
    flex-direction: column;
  }
}
