:root {
  --primary: #c8102e;
  --primary-hover: #a00c24;
  --primary-light: #fef2f2;
  --dark: #111827;
  --gray-900: #111827;
  --gray-700: #374151;
  --gray-500: #6b7280;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50: #f9fafb;
  --white: #ffffff;
  --green: #10b981;
  --green-light: #ecfdf5;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-container {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-img {
  height: 34px;
  width: auto;
  object-fit: contain;
}

.logo-badge {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.82rem;
  background: var(--primary-light);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(200, 16, 46, 0.15);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--gray-700);
}

.logout-btn {
  background: none;
  border: 1px solid var(--gray-200);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--gray-500);
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: var(--gray-100);
  color: var(--dark);
}

main {
  flex: 1;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 8px;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 12px;
}

p.subtitle {
  color: var(--gray-500);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

input[type="email"],
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="email"]:focus,
input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.15);
}

/* Følgeseddel / Utleveranse boks */
.delivery-box {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.delivery-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.delivery-box-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 6px;
}

.delivery-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.delivery-input-group input {
  flex: 1;
  font-family: monospace, Courier, sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.btn-scan {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--dark);
  color: var(--white);
  padding: 0 16px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  height: 48px;
  transition: background 0.2s, transform 0.1s;
}

.btn-scan:active {
  transform: scale(0.98);
}

.btn-scan svg {
  width: 20px;
  height: 20px;
}

.delivery-helper {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 8px;
}

.delivery-detected-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
  margin-top: 6px;
}

.otp-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 20px 0;
}

.otp-input {
  width: 48px;
  height: 58px;
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  outline: none;
  font-family: monospace;
}

.otp-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--white);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--gray-100);
  color: var(--gray-700);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--gray-200);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.camera-action-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 480px) {
  .camera-action-group {
    grid-template-columns: 1fr;
  }
}

.btn-camera {
  background: var(--dark);
  color: var(--white);
  padding: 16px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: transform 0.1s, opacity 0.2s;
}

.btn-camera:active {
  transform: scale(0.98);
}

.btn-camera svg {
  width: 28px;
  height: 28px;
}

.btn-camera.alt {
  background: var(--white);
  color: var(--dark);
  border: 2px dashed var(--gray-200);
}

.btn-camera.alt:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.dropzone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  background: var(--white);
  margin-bottom: 20px;
  transition: all 0.2s;
  cursor: pointer;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.dropzone svg {
  width: 36px;
  height: 36px;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.preview-item {
  position: relative;
  background: var(--gray-100);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--gray-200);
  aspect-ratio: 1;
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: white;
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
}

.preview-number {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.hidden {
  display: none !important;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================
   Fullskjerm / Modal Kamera Scanner
   ========================================== */
.scanner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
}

.scanner-header {
  width: 100%;
  max-width: 500px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
}

.scanner-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.scanner-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.scanner-viewfinder-container {
  position: relative;
  width: 100%;
  max-width: 380px;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 20px;
  background: #000;
}

.scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-viewfinder-box {
  position: absolute;
  top: 15%;
  left: 15%;
  right: 15%;
  bottom: 15%;
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.scanner-viewfinder-box.detected {
  border-color: #10b981;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5), 0 0 20px #10b981;
}

.scanner-laser {
  position: absolute;
  left: 5%;
  right: 5%;
  height: 3px;
  background: #c8102e;
  box-shadow: 0 0 8px #c8102e;
  animation: scanLaser 2s infinite ease-in-out;
}

@keyframes scanLaser {
  0%, 100% { top: 5%; }
  50% { top: 95%; }
}

.scanner-footer {
  width: 100%;
  max-width: 500px;
  text-align: center;
  color: #d1d5db;
  font-size: 0.9rem;
}

/* ==========================================
   Installer som app (PWA)
   ========================================== */
.install-banner {
  max-width: 680px;
  margin: 12px auto 0;
  width: calc(100% - 40px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.install-banner.hidden {
  display: none;
}

.install-banner-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.install-banner-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--gray-700);
}

.install-banner-text strong {
  color: var(--dark);
  font-size: 0.9rem;
}

.install-btn {
  background: var(--primary);
  color: var(--white);
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.install-btn:hover {
  background: var(--primary-hover);
}

.install-btn.hidden {
  display: none;
}

.install-dismiss {
  background: none;
  border: none;
  color: var(--gray-500);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}
