:root,
[data-bs-theme="light"] {
  --bs-font-sans-serif: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bs-body-font-family: var(--bs-font-sans-serif);
  --bs-body-bg: #eef2f7;
  --bs-body-color: #1a2332;
  --bs-primary: #1e3a5f;
  --bs-primary-rgb: 30, 58, 95;
  --bs-secondary: #5c6b7a;
  --bs-secondary-rgb: 92, 107, 122;
  --bs-success: #1f7a4d;
  --bs-warning: #b36b00;
  --bs-danger: #b42318;
  --bs-link-color: #2d6a9f;
  --bs-link-hover-color: #1e3a5f;
  --bs-border-color: #dde3ea;
  --bs-border-radius: 0.875rem;
  --bs-border-radius-lg: 1rem;
  --bs-border-radius-xl: 1.25rem;
  --bs-box-shadow-sm: 0 0.125rem 0.75rem rgba(26, 35, 50, 0.08);

  --bg: #eef2f7;
  --surface: #ffffff;
  --text: #1a2332;
  --text-muted: #5c6b7a;
  --primary: #1e3a5f;
  --primary-hover: #163049;
  --accent: #2d6a9f;
  --border: #dde3ea;
  --success: #1f7a4d;
  --warning: #b36b00;
  --danger: #b42318;
  --shadow: var(--bs-box-shadow-sm);
  --radius: var(--bs-border-radius-lg);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html, body {
  min-height: 100%;
}

.app-body {
  font-family: var(--bs-body-font-family);
  background:
    radial-gradient(circle at top right, rgba(45, 106, 159, 0.08), transparent 28rem),
    linear-gradient(180deg, #f7f9fc 0%, var(--bg) 100%);
  color: var(--text);
  line-height: 1.5;
}

.site-nav {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.site-nav .navbar-brand {
  color: var(--primary);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero-name {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  color: var(--primary);
  font-size: clamp(2.4rem, 9vw, 3.4rem);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

.hero-name span {
  display: block;
}

.site-nav .navbar-brand:hover,
.site-nav .navbar-brand:focus {
  color: var(--primary-hover);
}

.site-nav-logo {
  border-radius: 10px;
  box-shadow: 0 0.125rem 0.4rem rgba(26, 35, 50, 0.12);
}

.site-nav .nav-link {
  color: var(--text-muted);
  font-weight: 500;
}

.site-nav .nav-link:hover,
.site-nav .nav-link:focus,
.site-nav .nav-link.active {
  color: var(--primary);
}

.site-nav .navbar-toggler {
  border-color: var(--border);
}

.page.page-prose {
  max-width: 720px;
}

.site-footer {
  background: rgba(255, 255, 255, 0.92);
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus {
  color: var(--primary);
}

.cookie-banner {
  z-index: 1100;
  background: var(--primary);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -0.25rem 1rem rgba(26, 35, 50, 0.18);
}

.app-body:has(#cookieBanner:not(.d-none)) {
  padding-bottom: 7rem;
}

.legal-copy h2 {
  color: var(--primary);
}

.legal-copy table {
  font-size: 0.9rem;
}

.info-card h2 {
  font-size: 1.05rem;
}

.info-list dt {
  font-weight: 600;
}

.info-list dd {
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.page {
  max-width: 640px;
  padding-bottom: calc(1.5rem + var(--safe-bottom));
}

.link-accent {
  color: var(--accent) !important;
}

.btn-primary {
  --bs-btn-bg: var(--primary);
  --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary-hover);
  --bs-btn-hover-border-color: var(--primary-hover);
  --bs-btn-active-bg: var(--primary-hover);
  --bs-btn-active-border-color: var(--primary-hover);
}

.btn-outline-primary {
  --bs-btn-color: var(--primary);
  --bs-btn-border-color: rgba(30, 58, 95, 0.35);
  --bs-btn-hover-bg: var(--primary);
  --bs-btn-hover-border-color: var(--primary);
  --bs-btn-active-bg: var(--primary-hover);
  --bs-btn-active-border-color: var(--primary-hover);
}

.hero {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.actions {
  padding: 0 0.25rem;
}

.disclaimer {
  margin-top: 2rem;
}

.top-bar h1 {
  font-size: 1.05rem;
}

.card {
  border-color: rgba(221, 227, 234, 0.9);
}

.form-card label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.help-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: -0.25rem 0 1rem;
}

.scanner-body {
  background: #0f1720 !important;
}

.scanner-page {
  padding-bottom: 0;
}

.scanner-page .top-bar .btn-link {
  color: rgba(255, 255, 255, 0.85) !important;
}

.scanner-page .top-bar h1 {
  color: #fff;
}

.scanner-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  max-height: 70vh;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scan-frame {
  width: 75%;
  max-width: 280px;
  aspect-ratio: 2/1;
  border: 2px solid rgba(255,255,255,0.85);
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.35);
}

.scan-hint {
  margin-top: 1.5rem;
  color: #fff;
  font-size: 0.95rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.scanner-actions {
  padding: 1rem 0;
  text-align: center;
}

.loading-section {
  margin-bottom: 1rem;
}

.product-image,
.product-header img {
  width: 160px;
  height: 160px;
  object-fit: contain;
}

.history-thumb {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.history-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 0.35rem 1rem rgba(26, 35, 50, 0.12) !important;
}

.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 1.5rem;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  text-align: left;
  max-width: 280px;
  margin-inline: auto;
}

.progress-steps li {
  padding: 0.5rem 0;
  color: var(--text-muted);
}

.progress-steps li.active {
  color: var(--primary);
  font-weight: 600;
}

.progress-steps li.done {
  color: var(--success);
}

.progress-steps li.done::before {
  content: "✓ ";
}

.hidden,
.d-none {
  display: none !important;
}

.product-header {
  text-align: center;
}

.product-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.product-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.chain {
  display: grid;
  gap: 0;
  margin: 1rem 0;
}

.chain-node {
  position: relative;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0;
}

.chain-node + .chain-arrow {
  text-align: center;
  color: var(--text-muted);
  padding: 0.35rem 0;
  font-size: 1.1rem;
}

.chain-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.chain-name {
  font-weight: 600;
  font-size: 1.05rem;
}

.confidence-high { background: #e6f4ec; color: var(--success); }
.confidence-medium { background: #eef4fb; color: var(--accent); }
.confidence-low { background: #fff4e5; color: var(--warning); }
.confidence-unverified { background: #f0f2f5; color: var(--text-muted); }

.history-list {
  display: grid;
  gap: 0.75rem;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
}

.correction-captcha .cwds-block:last-child {
  margin-bottom: 0;
}

.correction-captcha .form-control {
  background: #fff;
}

.offline-banner {
  background: #fff4e5;
  color: var(--warning);
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  border-bottom: 1px solid #f0dcc0;
}

.sources-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.sources-list li:last-child {
  border-bottom: none;
}

.source-name {
  font-weight: 600;
}

.source-desc,
.source-date {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.source-date {
  font-size: 0.8rem;
}

.debug-badge {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: #fff4e5;
  color: var(--warning);
  font-size: 0.8rem;
  font-weight: 600;
}

.debug-panel {
  text-align: left;
  margin-top: 1rem;
}

.debug-panel h3 {
  margin-top: 0;
}

.debug-log-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 420px;
  overflow: auto;
  font-size: 0.82rem;
}

.debug-log-list li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.debug-time {
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
}

.debug-phase {
  color: var(--accent);
  font-weight: 600;
}

.debug-context {
  margin: 0.35rem 0 0;
  padding: 0.5rem;
  background: #f0f2f5;
  border-radius: 8px;
  overflow: auto;
  font-size: 0.75rem;
}

.loading-elapsed {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

.loading-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 1rem;
  max-width: 320px;
  margin-inline: auto;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
  font-weight: 500;
}

.checkbox-row input {
  width: auto;
  margin: 0;
}

.settings-status {
  list-style: none;
  padding: 0;
  margin: 0;
}

.settings-status li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.config-path code,
.warning-text code {
  font-size: 0.875rem;
}

.warning-text {
  color: var(--warning, #b45309);
  margin: 0.75rem 0 0;
}

.lookup-log-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
}

.lookup-log-list li {
  display: grid;
  gap: 0.15rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.lookup-log-list li:last-child {
  border-bottom: none;
}

.lookup-log-time {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.lookup-log-ip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.lookup-log-barcode {
  color: var(--text-muted);
}

.success-card {
  background: #e6f4ec;
  border-left: 4px solid var(--success);
  margin-bottom: 1rem;
}

.form-card h2 {
  margin-top: 0;
}

.summary-card {
  display: grid;
  gap: 0.65rem;
}

.summary-row {
  display: grid;
  gap: 0.35rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.summary-row-main {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.summary-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.summary-row:last-of-type {
  border-bottom: none;
}

.summary-label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.summary-value {
  font-weight: 600;
  text-align: right;
}

.summary-unknown .summary-value {
  color: var(--text-muted);
  font-weight: 500;
  font-style: italic;
}

.summary-status {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.ownership-history {
  margin-bottom: 1rem;
}

.ownership-history summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.ownership-history summary::-webkit-details-marker {
  display: none;
}

.ownership-history summary::before {
  content: '▸';
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--text-muted);
}

.ownership-history[open] summary::before {
  transform: rotate(90deg);
}

.ownership-history-count {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
}

.ownership-history-list {
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.65rem;
}

.ownership-history-item {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.02);
}

.ownership-history-item.is-current {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.06);
}

.ownership-history-name {
  font-weight: 600;
}

.ownership-history-name a {
  color: inherit;
  text-decoration: none;
}

.ownership-history-name a:hover {
  text-decoration: underline;
}

.ownership-history-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--success);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  vertical-align: middle;
}

.ownership-history-period {
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.corporate-chain-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.corporate-chain-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.5rem;
}

.corporate-chain-item {
  display: grid;
  gap: 0.2rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.corporate-chain-role {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.corporate-chain-name {
  font-weight: 600;
}

.corporate-chain-name a {
  color: inherit;
  text-decoration: none;
}

.corporate-chain-name a:hover {
  text-decoration: underline;
}

.corporate-chain-arrow {
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1;
}

.warnings ul {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.875rem;
}
