:root {
  --bg: #ffffff;
  --card: #111827;
  --card-light: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  touch-action: manipulation;
}

html {
  background: linear-gradient(180deg, #020617 0%, var(--bg) 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #020617 0%, var(--bg) 100%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
}

body.modal-open {
  overflow: hidden;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}

.app__header h1 {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.app__header p {
  margin: 0;
  color: var(--muted);
}

.card {
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid #334155;
  border-radius: var(--radius);
  padding: 14px;
}

.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 1px solid #374151;
}

#videoPreview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  touch-action: none;
}

.scan-overlay {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  transition: border-color 0.2s ease;
}

.scan-overlay.detected {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 3px rgba(34, 197, 94, 0.45);
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.manual-search {
  margin-top: 12px;
}

.manual-search__label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.manual-search__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.input {
  width: 100%;
  border: 1px solid #475569;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  background: #0b1220;
  color: var(--text);
}

.input:focus {
  outline: none;
  border-color: var(--info);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--card-light);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--primary);
  color: #052e16;
  font-weight: bold;
}

.status {
  margin-top: 12px;
  padding: 10px;
  border-radius: 10px;
  font-size: 0.95rem;
}

.status--info {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.45);
}

.status--ok {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.45);
}

.status--warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.status--error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.result-card h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.loader {
  font-size: 0.95rem;
  color: var(--warning);
}

.result-empty {
  color: var(--muted);
}

.result-data p {
  margin: 0 0 8px;
}

.result-main {
  display: grid;
  gap: 10px;
}

.result-field {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.75);
}

.result-field--primary {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(22, 101, 52, 0.16);
}

.result-field--description {
  background: rgba(30, 41, 59, 0.62);
}

.result-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.result-value {
  font-size: 1rem;
  color: var(--text);
  font-weight: 600;
  word-break: break-word;
}

.result-value--strong {
  font-size: 1.15rem;
  color: #bbf7d0;
}

.result-value--description {
  line-height: 1.4;
  color: #f1f5f9;
}

.location-block {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.72);
}

.location-title {
  margin: 0;
}

.location-note {
  margin: 6px 0 0;
  font-size: 0.83rem;
  color: var(--muted);
}

.location-list {
  margin: 10px 0 0;
  padding-left: 0;
  list-style: none;
}

.location-list li {
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px solid #475569;
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.45);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
}

.modal__dialog {
  position: relative;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid #334155;
  background: #0f172a;
  padding: 14px;
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.modal__header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.modal__close {
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  line-height: 1;
  font-size: 1.1rem;
}

.modal__footer {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.hidden {
  display: none;
}

@media (min-width: 640px) {
  .actions {
    grid-template-columns: repeat(3, 1fr);
  }
}
