:root {
  --bg0: #0c1210;
  --line: #2a3d34;
  --text: #e7f0ea;
  --muted: #8aa396;
  --accent: #3ecf8e;
  --warn: #e8b84a;
  --danger: #e36d6d;
  --match: #3ecf8e;
  --nomatch: #e36d6d;
  --card: rgba(20, 32, 27, 0.92);
  --font: "Segoe UI", "IBM Plex Sans", system-ui, sans-serif;
  --mono: "Cascadia Code", "Consolas", monospace;
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg0);
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
}
.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(900px 500px at 10% -10%, #1d4d3a55, transparent 60%),
    radial-gradient(700px 400px at 90% 0%, #3a2f1455, transparent 55%),
    linear-gradient(180deg, #0c1210, #101816 40%, #0b100e);
}
.stats article {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem;
}
.stats span { color: var(--muted); font-size: .78rem; text-transform: uppercase; }
.stats strong { display: block; margin-top: .35rem; font-size: 1.45rem; }
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 1rem 1.1rem 1.2rem;
}
.panel h2 { margin: 0 0 .4rem; font-size: 1.05rem; }
.muted { color: var(--muted); margin: 0 0 .8rem; font-size: .9rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .7rem; }
.row.between { justify-content: space-between; }
.btn {
  border: 1px solid var(--line); background: #18241e; color: var(--text);
  border-radius: 8px; padding: .55rem .9rem; cursor: pointer; font-weight: 600;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: #1f6b4a; border-color: #2f9b6a; }
.btn.danger { background: #6b2a2a; border-color: #a84a4a; }
.box {
  background: #0a100e; border: 1px solid var(--line); border-radius: 10px;
  padding: .8rem; min-height: 80px; overflow: auto; font-family: var(--mono);
  font-size: .78rem; white-space: pre-wrap;
}
.table-wrap { overflow: auto; max-height: 420px; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .55rem .65rem; border-bottom: 1px solid var(--line); text-align: left; }
th { position: sticky; top: 0; background: #132019; color: var(--muted); }
.badge {
  display: inline-block; padding: .1rem .45rem; border-radius: 999px; font-size: .75rem; font-weight: 700;
}
.badge.high { background: #5a2222; color: #ffb4b4; }
.badge.medium { background: #5a4a1a; color: #ffe29a; }
.badge.low { background: #1a3a2a; color: #a8e6c5; }

/* On/off switch (thay checkbox vuông) */
.checks { display: flex; flex-wrap: wrap; gap: .65rem 1rem; align-items: center; }
.switch, .chk {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  font-size: .88rem;
}
.switch > input[type="checkbox"],
.chk > input[type="checkbox"] {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  pointer-events: none;
}
.switch-ui {
  position: relative;
  width: 44px;
  height: 26px;
  flex: 0 0 44px;
  border-radius: 999px;
  background: #243029;
  border: 1px solid var(--line);
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.switch-ui::before {
  content: "OFF";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: .55rem;
  font-weight: 800;
  letter-spacing: .02em;
  color: #7a9084;
  padding-left: 12px;
  pointer-events: none;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #c5d4cb;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
  transition: transform .18s ease, background .18s ease;
}
.switch > input[type="checkbox"]:checked + .switch-ui,
.chk > input[type="checkbox"]:checked + .switch-ui {
  background: #1f7a4d;
  border-color: #2f9b6a;
  box-shadow: inset 0 0 0 1px rgba(62,207,142,.25);
}
.switch > input[type="checkbox"]:checked + .switch-ui::before,
.chk > input[type="checkbox"]:checked + .switch-ui::before {
  content: "ON";
  color: #d8ffe9;
  padding-left: 0;
  padding-right: 12px;
}
.switch > input[type="checkbox"]:checked + .switch-ui::after,
.chk > input[type="checkbox"]:checked + .switch-ui::after {
  transform: translateX(18px);
  background: #e8fff2;
}
.switch > input[type="checkbox"]:focus-visible + .switch-ui,
.chk > input[type="checkbox"]:focus-visible + .switch-ui {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.switch-text {
  line-height: 1.25;
}
.switch > input[type="checkbox"]:checked ~ .switch-text,
.chk > input[type="checkbox"]:checked ~ .switch-text {
  color: #cfe9da;
}

.file-lab { display: grid; gap: .25rem; font-size: .78rem; color: var(--muted); }
.hidden { display: none !important; }

/* So sánh visual */
.compare-stage { margin-top: .5rem; display: grid; gap: .9rem; }
.duel {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: stretch;
}
.person-card {
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #0f1814;
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.person-card.match {
  border-color: var(--match);
  box-shadow: 0 0 0 1px #3ecf8e44, 0 12px 32px #3ecf8e22;
}
.person-card.nomatch {
  border-color: #5a3333;
  box-shadow: 0 0 0 1px #e36d6d33;
}
.avt-frame {
  aspect-ratio: 1;
  background:
    linear-gradient(135deg, #1a2a22, #0c1210),
    repeating-linear-gradient(45deg, #16211c 0 8px, #121a16 8px 16px);
  display: grid; place-items: center;
  border-bottom: 1px solid var(--line);
}
.avt-frame img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.avt-frame .placeholder {
  color: var(--muted); font-size: .85rem; padding: 1rem; text-align: center;
}
.person-meta {
  padding: .75rem .9rem;
  display: grid; gap: .2rem;
}
.person-meta strong { font-size: 1.02rem; }
.person-meta span { color: var(--muted); font-size: .84rem; }
.vs-col {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .55rem; min-width: 110px;
}
.vs {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; letter-spacing: .04em;
  background: #1a2820; border: 2px solid var(--line); color: var(--warn);
}
.verdict-banner {
  text-align: center; font-weight: 800; font-size: 1rem;
  padding: .7rem 1rem; border-radius: 12px;
  border: 1px solid var(--line); background: #121a16;
}
.verdict-banner.match {
  color: #b8f5d4; background: #163528; border-color: #2f9b6a;
}
.verdict-banner.nomatch {
  color: #ffc9c9; background: #3a1a1a; border-color: #a84a4a;
}
.verdict-banner.warn {
  color: #ffe29a; background: #3a3018; border-color: #a88a3a;
}
.score-line {
  font-family: var(--mono); font-size: .8rem; color: var(--muted); text-align: center;
}
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  border: 1px solid var(--line); border-radius: 999px;
  padding: .25rem .65rem; font-size: .78rem; background: #15201b; color: #cfe6d8;
}
.chip.signal { border-color: #3a6b52; color: #9fe0bf; }
.chip.weak { border-color: #6b5a2a; color: #e8d29a; }
.related-row {
  display: flex; flex-wrap: wrap; gap: .6rem;
}
.related-mini {
  width: 88px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: #0f1814; text-align: center; font-size: .72rem; color: var(--muted);
}
.related-mini img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.related-mini div { padding: .25rem; }
.duel.single { grid-template-columns: minmax(180px, 280px); justify-content: start; }
.raw { color: var(--muted); }
.raw summary { cursor: pointer; margin-bottom: .4rem; }
code { color: #9fe0bf; }

.scan-progress {
  margin: .75rem 0 .5rem;
  padding: .85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f1814;
}
.scan-progress.hidden { display: none; }
.scan-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: .55rem;
  font-size: .9rem;
}
.scan-progress-head span { color: var(--muted); }
.scan-progress-head strong {
  font-family: var(--mono);
  font-size: 1.05rem;
  color: #9fe0bf;
}
.progress-track {
  height: 12px;
  border-radius: 999px;
  background: #1a2820;
  border: 1px solid var(--line);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2f9b6a, #5ee0a0);
  transition: width .35s ease;
}
.progress-bar.indeterminate {
  width: 35% !important;
  animation: scan-indeterminate 1.2s ease-in-out infinite;
}
.progress-bar.done {
  background: linear-gradient(90deg, #2f9b6a, #8ff0b8);
}
.progress-bar.failed {
  background: linear-gradient(90deg, #a84a4a, #e08080);
}
.progress-bar.cancelled {
  background: linear-gradient(90deg, #8a6a2a, #d0b060);
}
@keyframes scan-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
.scan-progress-msg {
  margin-top: .55rem;
  font-size: .88rem;
  color: #cfe6d8;
  word-break: break-word;
}
.scan-progress-meta {
  margin-top: .25rem;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--muted);
}

input, select {
  background: #0e1613;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: .55rem .7rem;
  min-width: 0;
}
.grow-input {
  flex: 1 1 180px;
  min-width: 0;
}
