:root {
  --bg: #eef3f8;
  --ink: #0f172a;
  --muted: #5b6b7c;
  --card: #ffffff;
  --line: #d7e0ea;
  --blue: #1d4ed8;
  --blue-2: #2563eb;
  --good: #047857;
  --bad: #b91c1c;
  --warn: #b45309;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Be Vietnam Pro", "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 400px at 100% 0, #dbeafe 0, transparent 50%),
    var(--bg);
  color: var(--ink);
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}

h1 { margin: 8px 0 0; font-size: 28px; letter-spacing: -0.03em; }
.sub { color: var(--muted); margin-top: 6px; }

.brand {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 10px;
  margin: 0 0 4px;
}
.brand-name {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.brand-site {
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}
.brand-site a { color: var(--blue); }

.site-foot {
  margin-top: 22px;
  padding: 16px 4px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.site-foot a { color: var(--blue); font-weight: 600; }

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tabs button, .btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
}

.tabs button.active, .btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.ghost { background: transparent; }

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

label { font-size: 14px; color: var(--muted); }
input, select {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.key-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 8px;
}

.key-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 8px;
}

.key-item b { width: 28px; }

.opt {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid #94a3b8;
  background: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.opt.on {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.scan-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .scan-layout { grid-template-columns: 1fr; }
}

.stage {
  position: relative;
  background: #0b1220;
  border-radius: 16px;
  overflow: hidden;
  min-height: 360px;
}

video, .stage canvas {
  width: 100%;
  display: block;
}

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.finder {
  position: absolute;
  width: 54px;
  height: 54px;
  border: 3px solid rgba(255,255,255,0.75);
}
.finder.tl { top: 8%; left: 7%; border-right: 0; border-bottom: 0; }
.finder.tr { top: 8%; right: 7%; border-left: 0; border-bottom: 0; }
.finder.br { bottom: 8%; right: 7%; border-left: 0; border-top: 0; }
.finder.bl { bottom: 8%; left: 7%; border-right: 0; border-top: 0; }
.finder.hot { border-color: #34d399; }

.status {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  color: #fff;
  background: rgba(15,23,42,0.55);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
}

.result-box { font-size: 15px; line-height: 1.5; }
.score { font-size: 42px; font-weight: 800; letter-spacing: -0.04em; }
.score small { font-size: 18px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-top: 1px solid var(--line); padding: 7px 8px; text-align: left; }
.ok { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }

.print-sheet {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.print-sheet svg { width: 100%; height: auto; display: block; }

@media print {
  body { background: #fff; }
  header, .tabs, .no-print, .site-foot { display: none !important; }
  .panel { display: none !important; }
  #panel-print { display: block !important; }
  .print-sheet { border: 0; }
}
