:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --bg: #f5f7fb;
  --text: #111827;
  --muted: #6b7280;
  --D: #ef4444;
  --I: #f59e0b;
  --S: #10b981;
  --C: #3b82f6;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji"; color: var(--text); background: var(--bg); }

.app-header {
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { font-weight: 700; letter-spacing: 0.4px; }
.header-right { display: flex; gap: 8px; align-items: center; }
.tagline { opacity: 0.9; font-size: 14px; }

.container { max-width: 480px; margin: 0 auto; padding: 16px; }
.screen { display: none; }
.screen.active { display: block; }

h1, h2 { margin: 12px 0; }
p { color: var(--muted); }
.note { color: var(--muted); margin-top: 8px; }

.field { margin: 12px 0; }
.field input { width: 100%; padding: 10px 12px; border: 1px solid #d0d5dd; border-radius: 8px; }
.consent { display: flex; align-items: center; gap: 8px; margin: 12px 0; }

.btn { appearance: none; border: 1px solid #d0d5dd; background: #fff; color: var(--text); padding: 10px 14px; border-radius: 999px; cursor: pointer; font-weight: 500; }
.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.35);
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.actions { display: flex; gap: 8px; margin-top: 12px; }

.progress { font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

.options-table { display: flex; flex-direction: column; gap: 6px; }
.options-header,
.option-row { display: grid; grid-template-columns: 3fr 0.7fr 0.7fr; align-items: center; column-gap: 12px; }
.options-header { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.col-title { text-align: center; }
.col-most { color: #16a34a; }
.col-least { color: #b91c1c; }
.option-text { font-size: 15px; }
.cell-most,
.cell-least { text-align: center; }
.cell-most label,
.cell-least label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* ===== Pie Chart ===== */
.pie-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px; /* Giảm gap từ 40px xuống 24px để kéo gần hơn */
  width: 100%;
}

.pie-svg {
  flex: 0 0 auto;
}

.pie-legend {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (max-width: 640px) {
  .pie-layout {
    flex-direction: column;
    gap: 20px;
  }
}

/* ===== Result Screen ===== */
.scores {
  display: none;
}

.result-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (min-width: 640px) {
  .result-columns {
    grid-template-columns: 1fr 1fr;
  }
}

.chart-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.chart-title {
  font-size: 15px;
  font-weight: 700;
  color: #334155;
  text-align: center;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.bars {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  height: 160px;
  padding-bottom: 24px; /* space for labels */
  position: relative;
  border-bottom: 1px solid #cbd5e1;
}

.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 16%;
  position: relative;
  height: 100%;
  justify-content: flex-end;
}

.bar-val {
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 4px;
}

.bar-fill {
  width: 100%;
  border-radius: 4px 4px 0 0;
  transition: height 0.5s ease;
  min-height: 2px;
}

.bar-label {
  position: absolute;
  bottom: -24px;
  font-weight: 700;
  font-size: 13px;
  color: #475569;
}

/* Colors for traits */
.bg-D { background-color: #ef4444; }
.bg-I { background-color: #f59e0b; }
.bg-S { background-color: #10b981; }
.bg-C { background-color: #3b82f6; }

.result-analysis {
  background: #f8fafc;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  border: 1px solid #e2e8f0;
}

.analysis-section {
  margin-bottom: 20px;
}

.analysis-section:last-child {
  margin-bottom: 0;
}

.analysis-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.analysis-content {
  font-size: 14px;
  color: #334155;
  line-height: 1.6;
}

.analysis-content ul {
  padding-left: 20px;
  margin: 8px 0;
}

.analysis-content li {
  margin-bottom: 4px;
}

.pie-container {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.editor { width: 100%; border: 1px solid #d0d5dd; border-radius: 8px; padding: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.btn.small { padding: 6px 10px; font-size: 13px; }

.auth-screen { padding-top: 12px; }
.auth-hero {
  position: relative;
  margin: 8px 0 24px 0;
  padding: 20px 18px 52px 18px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.35);
  overflow: hidden;
}
.auth-hero::before {
  content: "";
  position: absolute;
  left: -10%;
  bottom: -130px;
  width: 170%;
  height: 180px;
  background: #fff;
  border-radius: 50% 50% 0 0;
}
.auth-hero::after {
  content: "";
  position: absolute;
  right: -40px;
  top: 24%;
  width: 140px;
  height: 140px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 50%;
}
.auth-hero-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.auth-hero-text {
  margin-top: 6px;
  font-size: 14px;
  max-width: 65%;
  padding-right: 0;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.96);
  position: relative;
  z-index: 2;
}
.auth-hero-disc {
  position: absolute;
  right: 5px; /* Dịch sang trái một chút so với -5px */
  top: 10%; /* Đẩy lên trên một chút so với 24% */
  width: 150px;
  height: auto;
  z-index: 1;
  filter: drop-shadow(0 6px 14px rgba(15, 23, 42, 0.35));
}
.auth-card { margin: 0 auto 16px auto; }
.auth-title { margin-top: 0; margin-bottom: 4px; font-size: 20px; }
.auth-subtitle { margin-top: 0; margin-bottom: 12px; font-size: 14px; }
.auth-error { margin-bottom: 8px; color: #b42318; }
.auth-btn { width: 100%; justify-content: center; display: inline-flex; align-items: center; text-align: center; }
.auth-card form .auth-btn + .auth-btn { margin-top: 8px; }
.auth-switch { margin-top: 12px; font-size: 14px; text-align: center; color: var(--muted); }
.auth-switch a { color: var(--primary); text-decoration: none; font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }
.auth-extra { margin-top: 4px; margin-bottom: 4px; text-align: right; font-size: 13px; }
.auth-extra a { color: var(--primary); text-decoration: none; }
.auth-extra a:hover { text-decoration: underline; }

.test-hero { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.test-logo { height: 80px; object-fit: contain; }
.test-header-bar {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-bottom: 8px;
}
#app-toolbar.active {
  display: flex;
}
.test-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 520px;
  padding: 0 16px;
  background: #e5edff;
  border-radius: 999px;
}
.test-header-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  justify-content: center;
  width: 100%;
  text-align: center;
}
.test-header-text { max-width: 520px; }
.test-title { margin: 4px 0; font-size: 20px; letter-spacing: 1px; text-transform: uppercase; color: #004a94; }
.test-subtitle { margin: 0; font-size: 14px; }
.test-disc-img { max-width: 340px; width: 60%; height: auto; object-fit: contain; }
.progress { margin-top: 4px; font-size: 16px; font-weight: 700; }
.test-question-card { margin-top: 8px; }

.test-desc { margin-top: 24px; line-height: 1.6; }
.test-desc-title { margin-top: 0; margin-bottom: 8px; font-size: 18px; color: #004a94; }
.test-desc p { margin: 6px 0; }
.test-desc .accent { color: var(--primary); font-weight: 600; }
.disc-tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff; margin-right: 4px; }
.disc-tag.disc-d { background: var(--D); }
.disc-tag.disc-i { background: var(--I); }
.disc-tag.disc-s { background: var(--S); }
.disc-tag.disc-c { background: var(--C); }
.test-desc-list { list-style: none; padding-left: 0; margin: 8px 0 4px 0; }
.test-desc-list li { margin-bottom: 4px; position: relative; padding-left: 18px; color: #004a94; font-weight: 600; font-size: 14px; }
.test-desc-list li::before { content: ""; position: absolute; left: 0; top: 0.65em; width: 8px; height: 8px; border-radius: 999px; background: var(--primary); }

.candidate-card { padding: 0; overflow: hidden; }
.candidate-header { padding: 14px 16px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; }
.candidate-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.candidate-subtitle { font-size: 13px; opacity: 0.95; }
.candidate-body { padding: 12px 16px 8px 16px; background: #f9fafb; }
.required-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #ef4444; margin-right: 6px; vertical-align: middle; }
.consent-note { margin: 12px 0 8px 0; font-size: 14px; }

.icon-btn.home-btn {
  border: none;
  background: transparent;
  padding: 2px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
}
.home-icon { width: 32px; height: 32px; object-fit: contain; display: block; }
.icon-btn.home-btn:hover { background: #dbeafe; }
.account-shell { position: relative; }
.account-menu { position: absolute; right: 0; top: 100%; margin-top: 4px; background: #fff; border-radius: 10px; box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18); padding: 6px 0; min-width: 190px; display: none; z-index: 20; }
.account-menu button { width: 100%; padding: 6px 12px; text-align: left; border: none; background: transparent; font-size: 14px; cursor: pointer; }
.account-menu button:hover { background: #eff6ff; }
.account-menu.open { display: block; }
.btn.ghost { background: var(--primary); border: none; color: #fff; }
.btn.small { padding: 8px 18px; font-size: 14px; }
.spacer { flex: 1; }



@media (min-width: 640px) {
  .options { grid-template-columns: 1fr 1fr; }
  .details { grid-template-columns: 1fr 1fr; }
}

/* ===== Version Select Screen ===== */
.selection-card {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  text-align: center;
}

.selection-header {
  margin-bottom: 24px;
}

.selection-title {
  font-size: 20px;
  margin-bottom: 8px;
  color: #1e293b;
}

.selection-subtitle {
  color: #64748b;
  font-size: 14px;
}

.selection-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (min-width: 640px) {
  .selection-options {
    grid-template-columns: 1fr 1fr;
  }
}

.selection-item {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.2s;
  background: #fff;
  height: 100%;
}

.selection-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
  border-color: var(--primary);
}

#select-12-questions {
  border-top: 4px solid var(--primary);
}

#select-28-questions {
  border-top: 4px solid #64748b;
}

.selection-info {
  flex: 1;
  margin-bottom: 16px;
}

.selection-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #0f172a;
}

.selection-desc {
  font-size: 13px;
  color: #64748b;
  line-height: 1.5;
}

.selection-item .btn {
  margin-top: auto;
  font-size: 13px;
  padding: 10px 16px;
}

.bpv-container {
  position: relative;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
}

.bpv-bg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.bpv-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 24px;
  line-height: 1;
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
}

.marker-natural {
  color: #000; /* Màu đen cho Tự nhiên */
  font-size: 28px;
}

.marker-adapted {
  color: #000; /* Màu đen cho Thích ứng */
  font-size: 32px;
}

.bpv-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 8px; /* Đẩy sát lên ảnh */
  font-size: 14px;
  color: #334155;
  font-weight: 500;
}

.bpv-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bpv-legend-item .bpv-marker {
  position: static;
  transform: none;
  font-size: 18px;
}
.info-card {
  padding: 24px;
}

.info-title {
  color: var(--primary);
  text-align: center;
  margin-bottom: 20px;
}

.info-content {
  color: #334155;
  font-size: 14px;
  line-height: 1.6;
}

.info-content p {
  margin-bottom: 12px;
}

.disc-legend {
  list-style: none;
  padding: 0;
  margin: 16px 0;
}

.disc-legend li {
  margin-bottom: 8px;
  font-weight: 500;
}

.legend-d { color: #ef4444; font-weight: 700; }
.legend-i { color: #f59e0b; font-weight: 700; }
.legend-s { color: #10b981; font-weight: 700; }
.legend-c { color: #3b82f6; font-weight: 700; }

.bpv-details {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.bpv-quadrant {
  background: #f8fafc;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  font-size: 13px;
}

.bpv-quadrant strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

/* ===== History Screen ===== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.history-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 20px 50px 20px 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  position: relative;
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border-color: var(--primary);
}

.history-item::after {
  content: "→";
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: #cbd5e1;
  font-size: 20px;
  font-weight: 300;
  transition: color 0.2s;
}

.history-item:hover::after {
  color: var(--primary);
}
