:root {
  --bg-top: #f4f7fb;
  --bg-bottom: #dbe7f3;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --surface-soft: #f7faff;
  --border: rgba(108, 128, 163, 0.18);
  --border-strong: rgba(47, 111, 237, 0.18);
  --text: #162033;
  --muted: hsl(218, 17%, 44%);
  --accent: #FFA500;
  --accent-strong: #FFA500;
  --accent-soft: #dce8ff;
  --success: #14825e;
  --warning: #c27a00;
  --danger: #d4544a;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.14);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

img.login-logo {
    max-width: 250px;
    justify-content: center;
    display: flex;
    margin: 0 auto;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg-top);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(47, 111, 237, 0.16), transparent 28%),
    radial-gradient(circle at bottom right, rgba(20, 130, 94, 0.12), transparent 24%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.36), transparent 35%),
    linear-gradient(315deg, rgba(255, 255, 255, 0.2), transparent 40%);
  pointer-events: none;
}

body.is-standalone {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  position: relative;
  z-index: 1;
  background: linear-gradient(135deg, #FFA500, #FFA500);
}

.page-card {
  width: min(100%, 480px);
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: clamp(1.35rem, 3vw, 2rem);
  border-radius: 20px;
}

.scanner-page .page-card {
  width: min(100%, 560px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(108, 128, 163, 0.16);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--success));
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.12);
}

.app-title {
  margin: 1rem 0 0.45rem;
  font-size: clamp(1.8rem, 4vw, 2.3rem);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.app-subtitle {
  margin: 0 0 1.6rem;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.section-title {
  margin: 0 0 0.85rem;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-stack {
  display: grid;
  gap: 1rem;
}

.app-panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(247, 250, 255, 0.9) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.detail-panel {
  display: grid;
  gap: 0.8rem;
}

.detail-row {
  display: grid;
  gap: 0.2rem;
}

.detail-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-value {
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  word-break: break-word;
}

.form-label {
  color: var(--text);
  font-weight: 700;
  margin-bottom: 0.45rem;
}

.form-control {
  border-radius: var(--radius-md);
  border: 1px solid rgba(108, 128, 163, 0.28);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  min-height: 52px;
  padding: 0.85rem 1rem;
}

.form-control::placeholder {
  color: #7e8aa2;
}

.form-control:focus {
  border-color: rgba(47, 111, 237, 0.52);
  box-shadow: 0 0 0 0.2rem rgba(47, 111, 237, 0.12);
  background: #ffffff;
  color: var(--text);
}

.input-group-text {
  background: rgba(220, 232, 255, 0.76);
  color: var(--accent-strong);
  border: 1px solid rgba(47, 111, 237, 0.18);
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
}

.btn-app-primary,
.btn-app-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-app-primary {
  color: #ffffff;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 14px 24px rgba(47, 111, 237, 0.18);
}

.btn-app-primary:hover,
.btn-app-primary:focus {
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-app-secondary {
  color: var(--accent-strong);
  border: 1px solid rgba(47, 111, 237, 0.2);
  background: rgba(255, 255, 255, 0.92);
}

.btn-app-secondary:hover,
.btn-app-secondary:focus {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.btn-icon-toggle {
  border-color: rgba(47, 111, 237, 0.18);
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.94);
}

.btn-icon-toggle:hover,
.btn-icon-toggle:focus {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.alert {
  border-radius: var(--radius-md);
  border: 1px solid transparent;
}

.alert-danger {
  color: #7d2b25;
  background: rgba(244, 213, 210, 0.96);
  border-color: rgba(212, 84, 74, 0.24);
}

.alert-warning {
  color: #7b5600;
  background: rgba(251, 237, 193, 0.96);
  border-color: rgba(194, 122, 0, 0.24);
}

.scanner-heading {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.3rem, 3vw, 1.6rem);
  font-weight: 800;
  text-align: center;
}

.scanner-copy {
  margin: 0.35rem 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.95rem;
}

#reader {
  width: 100%;
  min-height: 320px;
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(180deg, rgba(247, 250, 255, 0.96) 0%, rgba(225, 235, 248, 0.92) 100%);
  border: 1px solid var(--border-strong);
}

.scanner-overlay {
  position: absolute;
  inset: 18px;
  border: 3px dashed rgba(47, 111, 237, 0.4);
  border-radius: 18px;
  pointer-events: none;
}

.ultimo-codigo {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(232, 240, 252, 0.92) 100%);
  border: 1px solid rgba(47, 111, 237, 0.18);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.ultimo-codigo small {
  display: block;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.codigo-texto {
  color: var(--accent-strong);
  font-size: clamp(1rem, 3vw, 1.3rem);
  font-weight: 800;
  word-break: break-all;
}

.manual-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
}

.manual-submit {
  min-width: 56px;
}

.alerta-area {
  min-height: 76px;
  display: flex;
  align-items: stretch;
}

.alerta-custom {
  width: 100%;
  border-radius: 18px;
  padding: 1rem;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.alerta-verde {
  background: linear-gradient(135deg, #18a06e, #0f7f58);
}

.alerta-amarelo {
  background: linear-gradient(135deg, #d99b15, #b77900);
}

.alerta-vermelho {
  background: linear-gradient(135deg, #dd5b4a, #bc3f31);
}

.scanner-actions {
  display: grid;
  gap: 0.85rem;
}

.network-indicator {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.95rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(108, 128, 163, 0.18);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.1);
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 700;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.network-indicator::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(20, 130, 94, 0.12);
}

body.is-offline .network-indicator {
  opacity: 1;
  transform: translateY(0);
  color: #7d2b25;
  background: rgba(255, 244, 243, 0.94);
  border-color: rgba(212, 84, 74, 0.2);
}

body.is-offline .network-indicator::before {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(212, 84, 74, 0.12);
}

.pwa-install-bar {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 25;
  width: min(calc(100% - 24px), 560px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 24px;
  background: rgba(10, 18, 34, 0.9);
  color: #ffffff;
  box-shadow: 0 16px 40px rgba(10, 18, 34, 0.28);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.pwa-install-bar.is-hidden {
  display: none;
}

.pwa-install-copy {
  display: grid;
  gap: 0.2rem;
}

.pwa-install-title {
  font-size: 0.94rem;
  font-weight: 800;
}

.pwa-install-text {
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.86rem;
  line-height: 1.4;
}

.pwa-install-actions {
  display: flex;
  gap: 0.6rem;
  flex-shrink: 0;
}

.pwa-install-btn,
.pwa-dismiss-btn {
  border: none;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 800;
  min-height: 44px;
  padding: 0.75rem 1rem;
}

.pwa-install-btn {
  color: #0f172a;
  background: #ffffff;
}

.pwa-dismiss-btn {
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.12);
}

.pwa-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(10, 18, 34, 0.62);
}

.pwa-modal.is-visible {
  display: flex;
}

.pwa-modal-card {
  width: min(100%, 420px);
  background: #ffffff;
  border-radius: 26px;
  padding: 1.5rem;
  box-shadow: 0 24px 56px rgba(15, 23, 42, 0.26);
}

.pwa-modal-card h2 {
  margin: 0 0 0.6rem;
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 800;
}

.pwa-modal-card p {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.55;
}

.pwa-steps {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text);
  line-height: 1.6;
}

.pwa-steps li + li {
  margin-top: 0.45rem;
}

.pwa-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.offline-page .page-card {
  width: min(100%, 520px);
  text-align: left;
}

.offline-hero {
  display: grid;
  gap: 1rem;
}

.offline-badge {
  width: fit-content;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: rgba(212, 84, 74, 0.1);
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.offline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.offline-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

div#qr-shaded-region {
  position: absolute;
  border-width: 18px !important;
  border-style: solid;
  border-color: rgba(15, 23, 42, 0.42);
  box-sizing: border-box;
  inset: 0;
}

@media (max-width: 575.98px) {
  .app-shell {
    padding: 18px 12px 24px;
    align-items: flex-start;
  }

  .page-card {
    border-radius: 24px;
    padding: 1.15rem;
  }

  .app-title {
    font-size: 1.65rem;
  }

  #reader {
    min-height: 268px;
  }

  .manual-form {
    grid-template-columns: 1fr;
  }

  .manual-submit,
  .pwa-install-actions,
  .offline-actions {
    width: 100%;
  }

  .pwa-install-bar {
    width: calc(100% - 16px);
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    padding: 0.95rem;
    border-radius: 22px;
  }

  .pwa-install-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .network-indicator {
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
  }
}



