* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #111827;
  color: #f9fafb;
}

.app-shell {
  max-width: 1300px;
  margin: 0 auto;
  padding: 20px;
}

.app-header {
  margin-bottom: 20px;
}

.app-header h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.app-header p {
  margin: 0;
  color: #cbd5e1;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.card h2,
.card h3 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.2rem;
}

.card h3 {
  font-size: 1rem;
  color: #cbd5e1;
}

.field {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}

.field label {
  margin-bottom: 6px;
  font-weight: bold;
  color: #d1d5db;
}

.field input,
.field select,
.field textarea,
button,
.upload-btn {
  border-radius: 10px;
  border: 1px solid #4b5563;
  padding: 10px 12px;
  font-size: 1rem;
}

.field input,
.field select,
.field textarea {
  background: #0f172a;
  color: #f9fafb;
}

.field textarea {
  resize: vertical;
  min-height: 160px;
}

.button-row,
.scan-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

button,
.upload-btn {
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  border: none;
  transition: 0.2s ease;
  text-align: center;
}

button:hover,
.upload-btn:hover {
  background: #1d4ed8;
}

.preview-card {
  min-height: 420px;
}

.svg-preview {
  width: 100%;
  min-height: 340px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
  padding: 16px;
}

.svg-preview svg {
  max-width: 100%;
  height: auto;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.info-box {
  background: #0f172a;
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 78px;
}

.info-label {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-bottom: 6px;
  font-weight: bold;
}

.info-value {
  font-size: 1rem;
  color: #f8fafc;
  word-break: break-word;
}

.search-card,
.scan-card {
  grid-column: 1 / -1;
}

.search-input-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input-row input {
  flex: 1;
  min-width: 220px;
}

.search-meta,
.scan-status {
  margin-top: 6px;
  color: #94a3b8;
  font-size: 0.95rem;
}

.search-results {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.search-result-item {
  background: #0f172a;
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: 0.2s ease;
}

.search-result-item:hover {
  border-color: #60a5fa;
  background: #13203a;
}

.search-result-title {
  font-weight: bold;
  color: #f8fafc;
  margin-bottom: 6px;
}

.search-result-meta {
  font-size: 0.92rem;
  color: #cbd5e1;
}

.search-empty {
  color: #94a3b8;
  font-size: 0.95rem;
}

.scan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.scan-panel {
  background: #0f172a;
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 12px;
}

#cameraPreview,
#sourceCanvas,
#processedCanvas {
  width: 100%;
  max-width: 100%;
  background: #000;
  border-radius: 10px;
  border: 1px solid #374151;
  display: block;
}

#cameraPreview {
  min-height: 220px;
  object-fit: cover;
}

#sourceCanvas,
#processedCanvas {
  min-height: 220px;
}

@media (max-width: 600px) {
  .app-shell {
    padding: 14px;
  }

  .search-input-row,
  .scan-controls,
  .button-row {
    flex-direction: column;
  }

  .search-input-row input {
    min-width: 100%;
  }
}
