:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --success-soft: #ecfdf5;
  --warning: #ea580c;
  --warning-soft: #fff7ed;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --info: #0284c7;
  --info-soft: #f0f9ff;
  --purple: #7c3aed;
  --purple-soft: #f5f3ff;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
  --radius: 12px;
  --font: "Apple SD Gothic Neo", "Pretendard", system-ui, sans-serif;
  --touch-min: 44px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 16px 3rem;
}

.landing-page .container {
  max-width: 960px;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.app-brand-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.app-header-user {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

.app-user-name {
  font-weight: 600;
  color: var(--text);
}

.app-user-role {
  color: var(--muted);
  padding: 0.15rem 0.5rem;
  background: var(--surface-muted);
  border-radius: 6px;
}

.header {
  margin-bottom: 1.25rem;
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.header p,
.page-lead {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 40rem;
}

.landing-hero {
  text-align: center;
  margin-bottom: 2rem;
  padding: 2rem 1rem 0;
}

.landing-hero h1 {
  margin: 0;
  font-size: 1.75rem;
  color: var(--primary);
}

.landing-hero .landing-title-ko {
  margin: 0.5rem 0 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.landing-hero .landing-sub {
  margin: 0.75rem auto 0;
  max-width: 32rem;
  color: var(--muted);
}

.value-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.value-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.value-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--primary);
}

.value-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.login-card-wrap {
  max-width: 420px;
  margin: 0 auto 2rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.demo-toggle {
  margin-top: 1rem;
  width: 100%;
}

.demo-panel {
  margin-top: 0.75rem;
  padding: 1rem;
  background: var(--surface-muted);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--muted);
}

.demo-panel ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card:hover {
  border-color: #bfdbfe;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.1);
}

.menu-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.menu-card p {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.btn-touch {
  min-height: var(--touch-min);
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  color: #fff;
  text-decoration: none;
}

.btn-secondary {
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-sm {
  min-height: 36px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1rem;
  box-shadow: var(--shadow);
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.field-error {
  display: block;
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 0.35rem;
}

.field-error[hidden] {
  display: none;
}

.engine-global-banner {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.mobile-app-body .engine-global-banner {
  margin: 0.5rem 0.75rem 0;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-top: 1rem;
  font-size: 0.875rem;
}

.alert-info {
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.alert-success {
  background: var(--success-soft);
  border: 1px solid #86efac;
  color: #166534;
}

.alert-error {
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-box strong {
  display: block;
  font-size: 1.4rem;
  color: var(--primary);
}

.stat-box span {
  font-size: 0.78rem;
  color: var(--muted);
}

.stat-box.stat-mobis strong {
  color: var(--success);
}

.stat-box.stat-sold strong {
  color: var(--info);
}

.stat-box.stat-installed strong {
  color: var(--purple);
}

.stat-box.stat-warn strong {
  color: var(--warning);
}

.stat-box.stat-fake strong {
  color: var(--danger);
}

.section-title {
  font-size: 1rem;
  margin: 0 0 1rem;
  color: var(--text);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.form-sections section {
  margin-bottom: 2rem;
}

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

.region-row {
  margin-bottom: 0.5rem;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

details.advanced-panel {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface-muted);
  border-radius: 8px;
  border: 1px solid var(--border);
}

details.advanced-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}

.parts-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.parts-list-item {
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.parts-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.parts-list-meta {
  margin: 0;
  padding-left: 0;
  list-style: none;
  font-size: 0.875rem;
  color: var(--muted);
}

.parts-list-meta li {
  margin-bottom: 0.25rem;
}

.parts-list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-info {
  background: var(--info-soft);
  color: var(--info);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-purple {
  background: var(--purple-soft);
  color: var(--purple);
}

.badge-registered,
.badge-default {
  background: var(--surface-muted);
  color: var(--muted);
}

.badge-mobis {
  background: var(--success-soft);
  color: var(--success);
}

.badge-suspicious {
  background: var(--warning-soft);
  color: var(--warning);
}

.verdict-card {
  margin-bottom: 1.5rem;
  padding: 1.75rem 1.5rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.verdict-card.verdict-genuine {
  border-color: var(--success);
  background: linear-gradient(180deg, var(--success-soft) 0%, var(--surface) 40%);
}

.verdict-card.verdict-notice {
  border-color: var(--info);
  background: linear-gradient(180deg, var(--info-soft) 0%, var(--surface) 40%);
}

.verdict-card.verdict-suspicious {
  border-color: var(--warning);
  background: linear-gradient(180deg, var(--warning-soft) 0%, var(--surface) 40%);
}

.verdict-card.verdict-unauthorized {
  border-color: var(--purple);
  background: linear-gradient(180deg, var(--purple-soft) 0%, var(--surface) 40%);
}

.verdict-card.verdict-fake {
  border-color: var(--danger);
  background: linear-gradient(180deg, var(--danger-soft) 0%, var(--surface) 40%);
}

.verdict-label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.verdict-result {
  margin: 0.35rem 0 0.75rem;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}

.verdict-consumer {
  margin: 0 0 1.25rem;
  font-size: 1.05rem;
  line-height: 1.6;
}

.verdict-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem 1rem;
  font-size: 0.9rem;
}

.verdict-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 0.15rem;
}

.security-summary {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.security-summary ul {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.security-summary li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--surface-muted);
  font-size: 0.9rem;
}

.reason-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.result-card {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--success-soft);
  border: 1px solid #86efac;
  border-radius: var(--radius);
}

.result-card h3 {
  margin: 0 0 0.75rem;
  color: var(--success);
}

.result-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-note {
  margin-top: 2rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.stats-table-wrap {
  overflow-x: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.stats-table th,
.stats-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.stats-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
}

pre.result,
pre.diagnostics-raw {
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 1rem;
  overflow: auto;
  font-size: 0.78rem;
  max-height: 400px;
}

.hidden-internal {
  display: none !important;
}

.nav-link {
  font-size: 0.875rem;
  color: var(--muted);
}

/* —— 테스트 라벨 (QR·바코드) —— */
.label-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.label-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  break-inside: avoid;
  page-break-inside: avoid;
}

.label-card-head h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.label-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 600;
}

.label-meta,
.label-status {
  margin: 0.25rem 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.label-codes {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.label-code-title {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.label-qr-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.label-payload {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.7rem;
  word-break: break-all;
  color: var(--muted);
}

.label-bar-block svg {
  max-width: 100%;
  height: auto;
}

.result-card-with-label .register-label-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.result-card-with-label .register-label-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.label-card-compact {
  margin-top: 0.5rem;
  box-shadow: none;
}

@media print {
  .result-card-with-label form,
  .result-card-with-label #recentPartsSection,
  .result-card-with-label .register-label-actions {
    display: none !important;
  }
}

@media print {
  .no-print,
  #appHeader,
  .app-header,
  .header .page-lead {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .label-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8mm;
  }

  .label-card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* —— 모바일 정품 확인 (일반 사용자) —— */
.mobile-app-body {
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.mobile-app-brand {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
}

.mobile-app-user {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.mobile-app-main {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

.mobile-title {
  font-size: 1.35rem;
  margin: 0 0 0.35rem;
}

.mobile-lead {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 0 1rem;
}

.mobile-scan-frame {
  aspect-ratio: 4 / 3;
  background: #0f172a;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  margin-bottom: 1rem;
}

.mobile-scan-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-scan-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
}

.mobile-scan-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.7;
}

.mobile-scan-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.mobile-manual-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.mobile-manual-form input {
  min-height: var(--touch-min);
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

.mobile-fallback-details {
  margin: 0.75rem 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.mobile-fallback-details summary {
  cursor: pointer;
  color: var(--primary);
}

.scan-picker-fallback {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.scan-picker-fallback input {
  flex: 1;
  min-height: var(--touch-min);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.scan-picker-frame {
  max-height: 200px;
  aspect-ratio: 16 / 10;
}

.scan-picker-selected {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--primary-soft);
  border-radius: var(--radius);
}

.scan-picker-selected-title {
  margin: 0 0 0.35rem;
}

.mobile-hint {
  font-size: 0.8rem;
  color: var(--muted);
  word-break: break-all;
}

.mobile-product-image {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--surface-muted);
  margin-bottom: 1rem;
}

.mobile-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.mobile-badge--ok {
  background: var(--success-soft);
  color: var(--success);
}

.mobile-badge--warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.mobile-consumer-msg {
  font-size: 1rem;
  line-height: 1.5;
  margin: 1rem 0;
}

.mobile-footer-note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 1rem;
}

.btn-sm {
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

@media (max-width: 768px) {
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  .card-grid,
  .value-grid {
    grid-template-columns: 1fr;
  }

  .login-card-wrap {
    max-width: 100%;
  }

  .app-header {
    flex-direction: column;
    align-items: stretch;
  }

  .app-header-user {
    justify-content: space-between;
  }

  .verdict-result {
    font-size: 1.5rem;
  }

  .stats-table thead {
    display: none;
  }

  .stats-table tbody tr {
    display: block;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--surface-muted);
    border-radius: 8px;
  }

  .stats-table tbody td {
    display: flex;
    justify-content: space-between;
    border: none;
    padding: 0.25rem 0;
  }

  .stats-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    margin-right: 0.5rem;
  }
}
