:root {
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-light: #ccfbf1;
  --bg-dark: #0f172a;
  --bg-card: #ffffff;
  --bg-page: #f8fafc;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #cbd5e1;
  --success: #15803d;
  --success-bg: #dcfce7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --radius: 8px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 15px;
}

header {
  background-color: #1e293b;
  color: #ffffff;
  padding: 0.75rem 1rem;
  border-bottom: 3px solid var(--primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.brand-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.demo-pill {
  display: inline-block;
  background-color: #ef4444;
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  background-color: #334155;
  color: #e2e8f0;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid #475569;
}

.offline-badge.ready {
  background-color: #14532d;
  color: #bbf7d0;
  border-color: #16a34a;
}

.offline-badge.offline {
  background-color: #713f12;
  color: #fef08a;
  border-color: #ca8a04;
}

.nav-tabs {
  display: flex;
  background-color: #0f172a;
  padding: 3px;
  border-radius: 8px;
  gap: 3px;
  width: 100%;
}

.nav-tab {
  flex: 1;
  text-align: center;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.25rem;
  border-radius: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-tab:hover {
  color: #ffffff;
}

.nav-tab.active {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

main {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1rem;
  min-width: 0;
  box-sizing: border-box;
}

.container-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem;
  width: 100%;
  min-width: 0;
}

.container-grid > * {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 1024px) {
  .container-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

pre, code {
  white-space: pre-wrap !important;
  word-break: break-all !important;
  overflow-wrap: anywhere !important;
  max-width: 100% !important;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr !important;
  }
  input, select, textarea {
    font-size: 16px !important; /* Prevents mobile browser auto-zoom on focus */
  }
}

.form-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.form-section h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
}

input, select, textarea {
  padding: 0.5rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
  color: #1e293b;
  background-color: #ffffff;
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #e2e8f0;
  color: #1e293b;
}

.btn-secondary:hover {
  background-color: #cbd5e1;
}

.btn-danger {
  background-color: #ef4444;
  color: white;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.alert-danger {
  background-color: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
}

.alert-success {
  background-color: var(--success-bg);
  color: var(--success);
  border: 1px solid #bbf7d0;
}

.alert-warning {
  background-color: var(--warning-bg);
  color: var(--warning);
  border: 1px solid #fde68a;
}

.preview-container {
  width: 100%;
  max-width: 100%;
  height: 520px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background-color: #525659;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
}

.preview-container iframe {
  width: 100%;
  max-width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.placeholder-text {
  color: #94a3b8;
  font-size: 0.95rem;
  text-align: center;
}

/* Scanner Styles */
.scanner-viewport {
  position: relative;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  aspect-ratio: 4/3;
  background-color: #000000;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#scanner-canvas {
  display: none;
}

.scanner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reticle-box {
  width: 220px;
  height: 220px;
  border: 3px solid #34d399;
  border-radius: 12px;
  box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.45);
  animation: pulse-reticle 2s infinite;
}

@keyframes pulse-reticle {
  0% { border-color: #34d399; }
  50% { border-color: #5eead4; }
  100% { border-color: #34d399; }
}

.upload-dropzone {
  border: 2px dashed #94a3b8;
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  background-color: #f8fafc;
  transition: all 0.15s ease;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-valid {
  background-color: var(--success-bg);
  color: var(--success);
  border: 1px solid #86efac;
}

.badge-invalid {
  background-color: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fca5a5;
}

.badge-warning {
  background-color: var(--warning-bg);
  color: var(--warning);
  border: 1px solid #fcd34d;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.88rem;
}

.detail-table th, .detail-table td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
}

.detail-table th {
  color: #475569;
  font-weight: 600;
  width: 35%;
  background-color: #f8fafc;
}

.detail-table td {
  color: #0f172a;
  font-weight: 500;
}

.disclaimer-box {
  background-color: #fffbeb;
  border: 1px solid #fef08a;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 0.8rem;
  color: #713f12;
  margin-top: 1rem;
}

.disclaimer-box ul {
  margin-left: 1.2rem;
  margin-top: 0.35rem;
}
