:root {
  --bg: #eef3f6;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --surface-border: rgba(18, 50, 74, 0.1);
  --text: #12324a;
  --text-muted: #537186;
  --primary: #0e6ba8;
  --primary-strong: #0a5483;
  --accent: #14b8a6;
  --success: #127a51;
  --warning: #b76a00;
  --danger: #a3353c;
  --shadow: 0 18px 50px rgba(15, 40, 60, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --max-width: 1160px;
  --font-display: "Segoe UI", "Aptos", "Helvetica Neue", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-display);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(14, 107, 168, 0.14), transparent 24%),
    linear-gradient(180deg, #f8fbfc 0%, var(--bg) 100%);
}

button,
textarea,
summary,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(100%, var(--max-width));
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.hero {
  background:
    linear-gradient(135deg, rgba(18, 50, 74, 0.96), rgba(14, 107, 168, 0.92)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent);
  color: white;
  padding: 24px;
  border-radius: 32px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -40% auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(20, 184, 166, 0.3), transparent 68%);
}

.hero__brand,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hero__brand {
  justify-content: flex-start;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  color: inherit;
  opacity: 0.72;
}

.hero h1,
.section-heading h2,
.empty-state h3,
.scanner-placeholder h3,
.location-card h3,
.confirm-dialog h2 {
  margin: 0;
}

.hero__copy {
  margin: 18px 0 0;
  max-width: 60ch;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.88);
}

.hero__actions,
.scanner-controls,
.manual-panel__actions,
.result-actions {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.layout {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  padding: 20px;
}

.card--status {
  padding: 12px;
}

.status-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid transparent;
}

.status-message strong {
  font-size: 0.98rem;
}

.status-message--info {
  background: rgba(14, 107, 168, 0.08);
  color: var(--primary-strong);
  border-color: rgba(14, 107, 168, 0.16);
}

.status-message--success {
  background: rgba(18, 122, 81, 0.09);
  color: var(--success);
  border-color: rgba(18, 122, 81, 0.16);
}

.status-message--warning {
  background: rgba(183, 106, 0, 0.1);
  color: var(--warning);
  border-color: rgba(183, 106, 0, 0.18);
}

.status-message--error {
  background: rgba(163, 53, 60, 0.08);
  color: var(--danger);
  border-color: rgba(163, 53, 60, 0.16);
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(18, 50, 74, 0.08);
  color: var(--text);
  font-size: 0.86rem;
  text-align: center;
}

.chip--muted {
  background: rgba(18, 50, 74, 0.06);
  color: var(--text-muted);
}

.scanner-frame {
  position: relative;
  min-height: 280px;
  margin-top: 18px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(18, 50, 74, 0.9), rgba(12, 78, 118, 0.9)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent);
}

#scanner-video,
.scanner-overlay,
.scanner-placeholder {
  position: absolute;
  inset: 0;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  background: #0a2231;
}

.scanner-overlay {
  display: none;
  place-items: center;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.4));
}

.scanner-target {
  width: min(72vw, 240px);
  aspect-ratio: 1;
  border-radius: 24px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 999px rgba(10, 34, 49, 0.28);
}

.scanner-placeholder {
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 24px;
  color: rgba(255, 255, 255, 0.9);
}

.scanner-placeholder p,
.empty-state p,
.manual-panel__intro,
.confirm-dialog p,
.comparison-summary,
.location-meta,
.location-card p {
  margin: 0;
  line-height: 1.55;
  color: var(--text-muted);
}

.scanner-placeholder p {
  color: rgba(255, 255, 255, 0.78);
}

.btn {
  border: 0;
  border-radius: 18px;
  min-height: 54px;
  padding: 14px 18px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  font-weight: 600;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-1px);
}

.btn:focus-visible,
summary:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(20, 184, 166, 0.32);
  outline-offset: 3px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: white;
  box-shadow: 0 16px 28px rgba(14, 107, 168, 0.24);
}

.btn--secondary {
  background: rgba(14, 107, 168, 0.1);
  color: var(--primary-strong);
}

.btn--ghost {
  background: rgba(18, 50, 74, 0.06);
  color: var(--text);
}

.btn--danger {
  background: linear-gradient(135deg, var(--danger), #c84b53);
  color: white;
}

.manual-panel {
  margin-top: 18px;
  border-radius: 18px;
  border: 1px solid rgba(18, 50, 74, 0.1);
  background: rgba(248, 251, 252, 0.86);
  padding: 0 16px 16px;
}

.manual-panel[open] {
  padding-top: 16px;
}

.manual-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.field span {
  font-weight: 600;
}

textarea {
  width: 100%;
  border: 1px solid rgba(18, 50, 74, 0.14);
  border-radius: 16px;
  padding: 14px;
  resize: vertical;
  min-height: 180px;
  color: var(--text);
  background: white;
}

.file-input {
  width: 100%;
  border: 1px solid rgba(18, 50, 74, 0.14);
  border-radius: 16px;
  padding: 12px 14px;
  background: white;
  color: var(--text);
}

.empty-state {
  display: grid;
  gap: 10px;
  padding: 18px 0 6px;
}

.location-card,
.comparison-layout {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.location-card {
  padding: 18px;
  border-radius: 20px;
  background: var(--surface-strong);
  border: 1px solid rgba(18, 50, 74, 0.09);
}

.location-card--current {
  background: linear-gradient(180deg, rgba(14, 107, 168, 0.08), rgba(255, 255, 255, 0.96));
}

.location-card--stored {
  background: linear-gradient(180deg, rgba(20, 184, 166, 0.08), rgba(255, 255, 255, 0.96));
}

.location-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.location-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(18, 50, 74, 0.08);
  color: var(--text);
  font-size: 0.82rem;
}

.location-label {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.location-meta {
  font-size: 0.96rem;
}

.comparison-summary {
  padding: 16px;
  border-radius: 18px;
  background: rgba(18, 50, 74, 0.05);
  border: 1px solid rgba(18, 50, 74, 0.08);
}

.comparison-summary--same {
  background: rgba(18, 122, 81, 0.08);
  border-color: rgba(18, 122, 81, 0.16);
  color: var(--success);
}

.comparison-summary--different {
  background: rgba(183, 106, 0, 0.1);
  border-color: rgba(183, 106, 0, 0.18);
  color: var(--warning);
}

.confirm-dialog {
  width: min(92vw, 420px);
  border: 0;
  border-radius: 28px;
  padding: 0;
  box-shadow: var(--shadow);
}

.confirm-dialog::backdrop {
  background: rgba(10, 20, 30, 0.45);
}

.confirm-dialog__content {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.confirm-dialog menu {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
}

@media (min-width: 740px) {
  .app-shell {
    padding: 28px 22px 54px;
  }

  .hero {
    padding: 30px;
  }

  .hero__actions,
  .scanner-controls,
  .manual-panel__actions,
  .result-actions,
  .confirm-dialog menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .manual-panel__actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .card--status,
  .card--scanner {
    grid-column: 1 / -1;
  }

  .comparison-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .location-card {
    min-height: 100%;
  }
}

@media (min-width: 1024px) {
  .hero__actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
