:root {
  --bg: #f2f4f8;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #6f7583;
  --blue: #3f87ff;
  --red: #f21b1b;
  --orange: #ff7a11;
  --yellow: #e8b90d;
  --green: #198a3c;
  --border: #e4e8f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  min-height: 100vh;
  background: #f7f9fc;
  display: flex;
  flex-direction: column;
}

.top-bar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #eaf1ff;
}

.brand-wrap h1 {
  font-size: 1.75rem;
  line-height: 1;
  margin: 0;
}

.brand-wrap p {
  margin: 4px 0 0;
  color: var(--muted);
}

.scan-btn {
  border: none;
  border-radius: 14px;
  padding: 12px 24px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.scan-btn.secondary {
  background: #eef4ff;
  color: #2f66c8;
  border: 1px solid #d3e1ff;
}

.content {
  padding: 16px;
  padding-bottom: 94px;
}

.section-title {
  margin: 6px 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #515866;
  font-size: 1.12rem;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(90px, 1fr));
  gap: 10px;
}

.status-card {
  color: #fff;
  border-radius: 14px;
  padding: 14px 12px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.status-card span {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1;
}

.status-card small {
  margin-top: 6px;
  font-size: 1.35rem;
}

.critico { background: var(--red); }
.atencao { background: var(--orange); }
.alerta { background: var(--yellow); color: #232323; }
.ok { background: var(--green); }

.level-card {
  margin: 18px 0;
  background: #ecf2ff;
  border: 1px solid #d9e5ff;
  border-radius: 16px;
  padding: 16px;
}

.level-card h3 {
  font-size: 2rem;
  margin: 0;
}

.level-card h3 small {
  color: var(--muted);
  font-size: 1.45rem;
  font-weight: 500;
}

.level-card p {
  margin: 10px 0;
  color: #4f5c74;
}

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

.level-grid > div {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
}

.level-grid strong {
  font-size: 2rem;
}

.section-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.section-row span {
  color: var(--muted);
  font-size: 1.25rem;
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.filter {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  min-width: 110px;
  padding: 10px;
  font-weight: 700;
  color: #4c5567;
  cursor: pointer;
}

.filter.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.list-header {
  margin-top: 6px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.lot-list {
  margin-top: 8px;
  min-height: 180px;
}

.lot-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 6px solid #c7cedf;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lot-item.critico { border-left-color: var(--red); }
.lot-item.atencao { border-left-color: var(--orange); }
.lot-item.alerta { border-left-color: var(--yellow); }
.lot-item.ok { border-left-color: var(--green); }

.empty {
  color: #788094;
  text-align: center;
  margin-top: 56px;
  font-size: 1.1rem;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 16px;
  background: var(--card);
  border-top: 1px solid var(--border);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  max-height: min(92vh, 760px);
  overflow-y: auto;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
}

.modal-head strong {
  display: block;
  font-size: 1.2rem;
}

.modal-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.wizard-steps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.wizard-step {
  border: 1px solid #dbe3f0;
  background: #f8fbff;
  color: #6b7688;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  text-align: center;
}

.wizard-step.active {
  background: #e9f1ff;
  color: #1d5ed8;
  border-color: #b8cffb;
}

.close-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
}

.field {
  margin: 10px 0;
}

.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

.field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 1rem;
}

.step {
  display: grid;
  gap: 12px;
}

.step-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.file-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
}

.camera-box {
  position: relative;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0f1220;
  aspect-ratio: 4 / 3;
}

.camera-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #dbe8ff;
  background: linear-gradient(135deg, #1d2438, #0f1220);
  text-align: center;
  padding: 12px;
  font-weight: 600;
}

.camera-box.live .camera-placeholder {
  display: none;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.camera-overlay::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 36%;
  height: 28%;
  border: 2px solid rgba(70, 150, 255, 0.92);
  border-radius: 12px;
  box-shadow: 0 0 0 999px rgba(3, 6, 14, 0.22);
}

.camera-status {
  margin: 0;
  color: #4f5f7d;
  font-weight: 600;
}

.upload-card {
  border: 1px dashed #cad5eb;
  background: #f8fbff;
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.primary-btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

.hidden {
  display: none !important;
}

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

.nav-item {
  border: none;
  background: transparent;
  color: #535f78;
  font-size: 1rem;
  padding: 8px 0;
}

.nav-item.active {
  color: var(--blue);
  font-weight: 700;
}

@media (min-width: 768px) {
  .top-bar {
    padding: 16px 24px;
  }

  .content {
    padding: 24px;
    padding-bottom: 90px;
  }

  .brand-wrap h1 {
    font-size: 2rem;
  }

  .bottom-nav {
    max-width: 980px;
    margin: 0 auto;
  }
}
