:root {
  --bg: #061218;
  --card: #0f2028;
  --line: #22424f;
  --text: #e6f4f1;
  --muted: #8db0bc;
  --ok: #39c685;
  --warn: #ffb347;
  --alert: #ef4444;
  --accent: #1c8fd1;
  --accent-soft: #7ec9f3;
  --gold: #f5b942;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(28, 143, 209, 0.24), transparent 28%),
    radial-gradient(circle at 85% 15%, rgba(245, 185, 66, 0.14), transparent 22%),
    linear-gradient(160deg, #040b10 0%, #09161d 46%, #061218 100%);
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  width: min(100vw - 24px, 1860px);
  max-width: none;
  margin: 12px auto;
  padding: 12px;
}

.portal {
  display: grid;
  grid-template-columns: clamp(220px, 18vw, 290px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.card {
  background: linear-gradient(180deg, #102730, #0c1e25);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.25);
}

.hidden { display: none !important; }

h1, h2 { margin: 0 0 8px; }
p { margin: 0 0 12px; color: var(--muted); }
label { font-size: 13px; color: var(--muted); margin-top: 10px; display: block; }
input, select, button {
  width: 100%;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid #2e515f;
  background: #0a1820;
  color: var(--text);
  padding: 11px;
}
input[readonly] {
  opacity: 0.92;
}
input[type="checkbox"] {
  width: auto;
  margin: 0 8px 0 0;
  padding: 0;
}
button {
  background: #1c8fd1;
  border: none;
  cursor: pointer;
  font-weight: 700;
}
button.secondary { background: #3d5763; }
button.danger { background: #8f2a2a; width: auto; padding: 10px 14px; }
button:hover { filter: brightness(1.08); }

.login-card {
  width: min(1120px, calc(100vw - 28px));
  min-height: min(760px, calc(100vh - 24px));
  margin: 8px auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(108, 175, 210, 0.22);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  background:
    linear-gradient(135deg, rgba(8, 19, 26, 0.96), rgba(10, 25, 33, 0.94)),
    linear-gradient(180deg, #102730, #0c1e25);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 420px);
  min-height: min(760px, calc(100vh - 24px));
}

.login-hero {
  position: relative;
  padding: 56px 52px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  background:
    radial-gradient(circle at top left, rgba(28, 143, 209, 0.2), transparent 32%),
    linear-gradient(180deg, rgba(10, 27, 36, 0.72), rgba(5, 15, 21, 0.9));
}

.login-hero::after {
  content: "";
  position: absolute;
  inset: 28px;
  border: 1px solid rgba(126, 201, 243, 0.11);
  border-radius: 28px;
  pointer-events: none;
}

.login-kicker {
  display: inline-flex;
  align-self: flex-start;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(245, 185, 66, 0.12);
  border: 1px solid rgba(245, 185, 66, 0.32);
  color: #ffd98a;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
}

.login-hero h1 {
  font-size: clamp(42px, 5vw, 68px);
  line-height: 0.94;
  letter-spacing: -0.04em;
  margin: 0;
}

.login-subtitle {
  max-width: 720px;
  font-size: 18px;
  line-height: 1.6;
  color: #b7d0d8;
  margin: 0;
}

.login-highlights {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 8px;
}

.login-highlight {
  padding: 18px;
  border-radius: 18px;
  background: rgba(8, 20, 27, 0.7);
  border: 1px solid rgba(126, 201, 243, 0.14);
  backdrop-filter: blur(4px);
}

.login-highlight strong {
  display: block;
  margin-bottom: 6px;
  color: #f2fbff;
  font-size: 14px;
}

.login-highlight span {
  display: block;
  font-size: 13px;
  line-height: 1.45;
  color: #93afbb;
}

.login-form-panel {
  padding: 42px 34px;
  background:
    linear-gradient(180deg, rgba(8, 19, 26, 0.94), rgba(6, 15, 20, 0.98));
  border-left: 1px solid rgba(126, 201, 243, 0.12);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-badge {
  width: fit-content;
  margin-bottom: 14px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(28, 143, 209, 0.14);
  border: 1px solid rgba(28, 143, 209, 0.34);
  color: var(--accent-soft);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.login-form-panel h2 {
  font-size: 32px;
  margin-bottom: 4px;
}

.login-form-copy {
  margin-bottom: 18px;
  color: #9db8c3;
  line-height: 1.5;
}

.login-form-panel input {
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(104, 149, 167, 0.42);
  background: linear-gradient(180deg, #09151b, #0b1a22);
  padding: 13px 14px;
}

.login-form-panel input:focus {
  outline: none;
  border-color: rgba(126, 201, 243, 0.72);
  box-shadow: 0 0 0 4px rgba(28, 143, 209, 0.16);
}

.login-form-panel button {
  margin-top: 16px;
  min-height: 50px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #0f6fa6);
  box-shadow: 0 14px 28px rgba(20, 97, 141, 0.25);
}

.login-footnote {
  display: block;
  margin-top: 12px;
  color: #7695a1;
  font-size: 12px;
}

.login-error {
  display: block;
  margin-top: 12px;
  min-height: 18px;
  color: #ff8d8d;
}

.sidebar {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 980px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-hero {
    padding: 38px 28px 24px;
  }

  .login-form-panel {
    padding: 28px;
    border-left: none;
    border-top: 1px solid rgba(126, 201, 243, 0.12);
  }

  .login-highlights {
    grid-template-columns: 1fr;
  }
}

.nav-btn {
  background: #1a3039;
  text-align: left;
}
.nav-btn.active {
  background: #1c8fd1;
}

.workspace {
  width: 100%;
  min-width: 0;
  min-height: 420px;
}
.panel-view {
  display: block;
}
.panel-view.hidden {
  display: none !important;
}

.panel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.user-summary {
  margin-top: 16px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}
.info-item {
  background: #0a1820;
  border: 1px solid #2e515f;
  border-radius: 12px;
  padding: 12px;
}
.info-item span {
  color: var(--muted);
  font-size: 12px;
  display: block;
  margin-bottom: 4px;
}
.user-form {
  margin-top: 10px;
}
.profile-actions {
  grid-template-columns: minmax(220px, 340px);
}
.reads-filters-grid {
  margin-top: 10px;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}
.plate-query-form {
  margin-top: 10px;
  grid-template-columns: minmax(260px, 1fr) minmax(240px, 320px);
  align-items: end;
}
.plate-query-export-actions {
  grid-template-columns: minmax(180px, 240px) minmax(180px, 240px);
  justify-content: start;
  margin-top: 10px;
}
.plate-query-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.reads-filter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-self: end;
}
.gps-chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(87, 184, 255, 0.2);
  color: #9ad9ff;
  font-size: 12px;
}
.small-muted {
  color: var(--muted);
  font-size: 12px;
}
.clickable-row {
  cursor: pointer;
}
.clickable-row:hover {
  background: rgba(47, 104, 125, 0.32);
}
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(3, 10, 14, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal-card {
  width: min(980px, 96vw);
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-content {
  margin-top: 10px;
  overflow: auto;
  padding-right: 6px;
}
#readDetailCloseBtn {
  width: auto;
  min-width: 100px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 10px;
}
.detail-item {
  background: #0a1820;
  border: 1px solid #2e515f;
  border-radius: 12px;
  padding: 10px 12px;
}
.detail-item .label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.detail-item .value {
  color: var(--text);
  font-size: 14px;
  word-break: break-word;
}
.detail-full {
  grid-column: 1 / -1;
}
.detail-map-link {
  color: #8fd2ff;
  text-decoration: none;
}
.detail-map-link:hover {
  text-decoration: underline;
}
.observation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.observation-item {
  background: #08151b;
  border: 1px solid #254958;
  border-radius: 10px;
  padding: 10px;
}
.observation-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}
.plate-query-result {
  margin-top: 12px;
  border: 1px solid #22424f;
  background: #0a1820;
  border-radius: 12px;
  padding: 12px;
}
.plate-query-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.plate-query-item {
  border: 1px solid #244350;
  border-radius: 10px;
  background: #0c1b23;
  padding: 10px 12px;
}
.plate-query-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.plate-query-meta {
  color: var(--muted);
  font-size: 12px;
}
.plate-query-address {
  color: #d6e8ef;
  font-size: 13px;
  margin-bottom: 6px;
  word-break: break-word;
}
.plate-query-note {
  margin-top: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(220px, 340px);
  gap: 12px;
}
.full-width { grid-column: 1 / -1; }
.actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.bulk-actions {
  grid-template-columns: 1fr;
}
.bulk-actions .danger {
  width: 100%;
}
.search-area { margin: 16px 0; }
.search-filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(220px, 320px);
  gap: 10px;
  align-items: end;
}
.search-filters input,
.search-filters select {
  margin-top: 0;
}

.table-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.table-stats {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}
.page-size-box {
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-size-box label {
  margin: 0;
  white-space: nowrap;
}
.page-size-box select {
  width: 120px;
  margin-top: 0;
}
.pagination-controls {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.pagination-controls button {
  width: 130px;
}
#pageInfo {
  color: var(--muted);
  font-size: 13px;
  min-width: 130px;
  text-align: center;
}
#readsPageInfo {
  color: var(--muted);
  font-size: 13px;
  min-width: 130px;
  text-align: center;
}

.import-card {
  margin-top: 16px;
  padding: 14px;
  background: linear-gradient(180deg, #0d212b, #0a1b23);
}
.import-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.import-card-header h3 {
  margin: 0;
}
.help-btn {
  width: 22px;
  height: 22px;
  min-width: unset;
  padding: 0;
  border-radius: 50%;
  font-size: 13px;
  font-weight: bold;
  line-height: 1;
  background: #1e5068;
  border: 1px solid #2e7a99;
  color: #9ad9ff;
  cursor: pointer;
  flex-shrink: 0;
}
.help-btn:hover {
  background: #2a6a85;
}
.help-popover {
  background: #081820;
  border: 1px solid #2e515f;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  font-size: 13px;
}
.help-popover p {
  margin: 6px 0 10px;
}
.help-popover strong {
  color: #9ad9ff;
  font-size: 14px;
}
.help-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
  font-size: 12px;
}
.help-table th,
.help-table td {
  border: 1px solid #2e515f;
  padding: 5px 8px;
  text-align: left;
}
.help-table th {
  background: #0d2a36;
  color: #9ad9ff;
}
.help-note {
  margin: 0 !important;
  color: #a0c8d8;
  font-size: 12px !important;
}
.import-card h3 {
  margin: 0 0 8px;
}
.import-card p {
  margin: 0 0 10px;
  font-size: 13px;
}
.import-card code {
  display: block;
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #2e515f;
  background: #08151b;
  color: #9ad9ff;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 12px;
}
.import-actions {
  margin-top: 10px;
}
#importMessage {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}
#authUsersImportMessage {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}
th, td {
  border-bottom: 1px solid #244350;
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}
tr:hover { background: rgba(30, 65, 79, 0.35); }
.security-row-suspicious {
  background: rgba(255, 179, 71, 0.08);
}
.security-row-suspicious:hover {
  background: rgba(255, 179, 71, 0.14);
}
.pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.pill.NORMAL { background: rgba(57, 198, 133, 0.2); color: var(--ok); }
.pill.FURTO { background: rgba(255, 179, 71, 0.2); color: var(--warn); }
.pill.ROUBO { background: rgba(239, 68, 68, 0.2); color: var(--alert); }
.pill.AVERIGUACAO { background: rgba(109, 177, 255, 0.25); color: #8fd2ff; }
.pill.ESTELIONATO { background: rgba(251, 191, 36, 0.2); color: #facc15; }
.pill.APROPRIACAO { background: rgba(129, 140, 248, 0.23); color: #b3bcff; }
.pill.VEICULO_ABORDADO { background: rgba(20, 184, 166, 0.2); color: #6ee7da; }
.pill.PROCURADO { background: rgba(244, 63, 94, 0.2); color: #ff8ba0; }
.pill.FALTA_DE_BAIXA { background: rgba(245, 158, 11, 0.2); color: #fdc26f; }
.pill.CLONADO { background: rgba(236, 72, 153, 0.2); color: #ffa3d4; }
.pill.ENTREGUE { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.pill.FURTADO { background: rgba(255, 206, 84, 0.24); color: #ffd979; }
.pill.PESSOA_PROCURADA { background: rgba(244, 63, 94, 0.27); color: #ff9fb3; }
.pill.PROPRIETARIO_PROCURADO { background: rgba(236, 72, 153, 0.27); color: #ffb0d9; }
.pill.OUTROS { background: rgba(148, 163, 184, 0.2); color: #d0dae6; }
.pill.ATIVO { background: rgba(57, 198, 133, 0.2); color: var(--ok); }
.pill.INATIVO { background: rgba(239, 68, 68, 0.2); color: var(--alert); }

.error { color: #ff9a9a; display: block; margin-top: 8px; }
#panelMessage { display: block; margin-top: 10px; color: var(--muted); }
#userPanelMessage { display: block; margin-top: 10px; color: var(--muted); }
#readsPanelMessage { display: block; margin-top: 10px; color: var(--muted); }
#userPanelMessage.message-state {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #2e515f;
  background: rgba(10, 24, 32, 0.92);
}
#userPanelMessage.message-info {
  color: var(--muted);
}
#userPanelMessage.message-success {
  color: #bff3dc;
  border-color: rgba(57, 198, 133, 0.42);
  background: rgba(57, 198, 133, 0.12);
}
#userPanelMessage.message-warning {
  color: #ffe1a6;
  border-color: rgba(255, 179, 71, 0.45);
  background: rgba(255, 179, 71, 0.12);
}
#userPanelMessage.message-error {
  color: #ffc1c1;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.12);
}

@media (max-width: 860px) {
  .portal {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .user-summary {
    grid-template-columns: 1fr;
  }
  .form-grid { grid-template-columns: 1fr; }
  .reads-filters-grid { grid-template-columns: 1fr; }
  .plate-query-form { grid-template-columns: 1fr; }
  .plate-query-export-actions { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .plate-query-header { flex-direction: column; align-items: flex-start; }
  .plate-query-actions { grid-template-columns: 1fr; }
  .reads-filter-actions {
    grid-template-columns: 1fr;
  }
  .search-filters { grid-template-columns: 1fr; }
  .actions { grid-template-columns: 1fr; }
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .page-size-box {
    justify-content: space-between;
  }
  .pagination-controls {
    justify-content: stretch;
  }
  .pagination-controls button {
    flex: 1;
    width: auto;
  }
}
