/* ============================================================
   TOOL 01 — CSS riêng cho tab "Tự đánh giá thể chất Đông y"
   Scope: #t01-app — cô lập hoàn toàn khỏi các tab khác.
   Chỉ dùng class có sẵn; KHÔNG cần sửa HTML/JS.
   ============================================================ */

/* ---------- 1. BIẾN MÀU (khớp palette VSH xanh lá) ---------- */
#t01-app {
  /* Xanh VSH */
  --t01-green-900: #0f3d24;
  --t01-green-700: #1a5f3d;
  --t01-green-500: #2e8b57;
  --t01-green-300: #86c5a2;
  --t01-green-100: #e6f2ea;
  --t01-green-050: #f4faf6;

  /* Màu phụ trợ cho từng loại khối */
  --t01-blue:      #1d4ed8;   /* chủ — xanh dương */
  --t01-blue-bg:   #eff6ff;
  --t01-blue-br:   #bfdbfe;

  --t01-amber:     #b45309;   /* bản — cam đất */
  --t01-amber-bg:  #fffbeb;
  --t01-amber-br:  #fde68a;

  --t01-teal:      #0e7490;   /* tiêu — teal */
  --t01-teal-bg:   #ecfeff;
  --t01-teal-br:   #a5f3fc;

  --t01-violet:    #6d28d9;   /* đặc thù — tím */
  --t01-violet-bg: #f5f3ff;
  --t01-violet-br: #ddd6fe;

  --t01-slate:     #475569;   /* chuỗi — xám */
  --t01-slate-bg:  #f1f5f9;
  --t01-slate-br:  #cbd5e1;

  --t01-emerald:   #047857;   /* thứ tự — xanh lá đậm */
  --t01-emerald-bg:#ecfdf5;
  --t01-emerald-br:#a7f3d0;

  --t01-red:       #b91c1c;   /* red flag */
  --t01-red-bg:    #fef2f2;
  --t01-red-br:    #fecaca;

  --t01-yellow:    #a16207;   /* straight-line */
  --t01-yellow-bg: #fefce8;
  --t01-yellow-br: #fde047;

  /* Trung tính */
  --t01-text:      #1f2937;
  --t01-text-mute: #4b5563;
  --t01-text-soft: #6b7280;
  --t01-bg:        #ffffff;
  --t01-bg-soft:   #f9fafb;
  --t01-br:        #e5e7eb;
  --t01-br-2:      #d1d5db;

  /* Hình dạng */
  --t01-radius:    10px;
  --t01-radius-sm: 6px;
  --t01-gap:       12px;
  --t01-pad:       14px 16px;
}

/* ---------- 2. LAYOUT KẾT QUẢ ---------- */
#t01-app #t01-result {
  max-width: 820px;
  margin: 0 auto;
  color: var(--t01-text);
  font-size: 15px;
  line-height: 1.6;
}

#t01-app #t01-headline {
  margin: 0 0 16px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--t01-green-700);
  line-height: 1.35;
}

#t01-app #t01-headline a {
  color: var(--t01-green-700);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- 3. KHỐI CHUNG .r-block ---------- */
#t01-app .r-block {
  margin: 0 0 var(--t01-gap);
  padding: var(--t01-pad);
  background: var(--t01-bg);
  border: 1px solid var(--t01-br);
  border-radius: var(--t01-radius);
  color: var(--t01-text);
}

#t01-app .r-block > h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--t01-green-700);
}

#t01-app .r-block > p {
  margin: 0 0 8px;
  line-height: 1.6;
}

#t01-app .r-block > p:last-child { margin-bottom: 0; }

#t01-app .r-block ul {
  margin: 4px 0 8px;
  padding-left: 1.25rem;
}

#t01-app .r-block ul:last-child { margin-bottom: 0; }

#t01-app .r-block li {
  margin-bottom: 4px;
  line-height: 1.55;
}

#t01-app .r-block a {
  color: var(--t01-green-700);
  text-decoration: underline;
  text-underline-offset: 2px;
}

#t01-app .r-block a:hover,
#t01-app .r-block a:focus-visible {
  color: var(--t01-green-900);
  text-decoration-thickness: 2px;
}

#t01-app .r-label {
  font-weight: 600;
  color: var(--t01-text-mute);
  margin-top: 8px;
}

/* ---------- 4. KHỐI TÓM TẮT CHỦ – THỨ / BẢN – TIÊU ---------- */
#t01-app .r-priority-summary {
  background: linear-gradient(180deg, var(--t01-green-050), var(--t01-green-100));
  border: 1px solid var(--t01-green-300);
  border-left: 4px solid var(--t01-green-700);
  border-radius: var(--t01-radius);
  padding: 16px 18px;
  margin: 0 0 18px;
  box-shadow: 0 1px 3px rgba(15, 61, 36, 0.06);
}

#t01-app .r-priority-summary > h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--t01-green-900);
  letter-spacing: 0.01em;
}

#t01-app .r-priority-summary > h3::before {
  content: "🌿";
  margin-right: 6px;
}

#t01-app .r-priority-summary > p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--t01-text);
  font-weight: 500;
}

/* ---------- 5. CÁC SECTION PRIORITY (đều là .r-block) ----------
   Không thể phân biệt bằng CSS thuần vì cùng class .r-block.
   Giải pháp: dùng icon mặc định cho mọi priority section,
   và nhấn mạnh màu qua thứ tự xuất hiện trong #t01-groups.
   ------------------------------------------------------------ */

/* Tất cả section priority — nền nhạt, viền trái xanh VSH */
#t01-app #t01-groups > .r-block {
  background: var(--t01-bg-soft);
  border-left: 3px solid var(--t01-green-500);
}

/* Block đầu tiên (chủ) — nhấn mạnh nhất */
#t01-app #t01-groups > .r-block:first-of-type {
  background: var(--t01-blue-bg);
  border-color: var(--t01-blue-br);
  border-left-color: var(--t01-blue);
}
#t01-app #t01-groups > .r-block:first-of-type > h3 {
  color: var(--t01-blue);
}

/* Block thứ hai (bản) — cam đất */
#t01-app #t01-groups > .r-block:nth-of-type(2) {
  background: var(--t01-amber-bg);
  border-color: var(--t01-amber-br);
  border-left-color: var(--t01-amber);
}
#t01-app #t01-groups > .r-block:nth-of-type(2) > h3 {
  color: var(--t01-amber);
}

/* Block thứ ba (tiêu) — teal */
#t01-app #t01-groups > .r-block:nth-of-type(3) {
  background: var(--t01-teal-bg);
  border-color: var(--t01-teal-br);
  border-left-color: var(--t01-teal);
}
#t01-app #t01-groups > .r-block:nth-of-type(3) > h3 {
  color: var(--t01-teal);
}

/* Block thứ tư (đặc thù) — tím */
#t01-app #t01-groups > .r-block:nth-of-type(4) {
  background: var(--t01-violet-bg);
  border-color: var(--t01-violet-br);
  border-left-color: var(--t01-violet);
}
#t01-app #t01-groups > .r-block:nth-of-type(4) > h3 {
  color: var(--t01-violet);
}

/* Block thứ năm (chuỗi) — xám */
#t01-app #t01-groups > .r-block:nth-of-type(5) {
  background: var(--t01-slate-bg);
  border-color: var(--t01-slate-br);
  border-left-color: var(--t01-slate);
}
#t01-app #t01-groups > .r-block:nth-of-type(5) > h3 {
  color: var(--t01-slate);
}

/* Block thứ sáu (thứ tự ưu tiên) — xanh lá đậm */
#t01-app #t01-groups > .r-block:nth-of-type(6) {
  background: var(--t01-emerald-bg);
  border-color: var(--t01-emerald-br);
  border-left-color: var(--t01-emerald);
}
#t01-app #t01-groups > .r-block:nth-of-type(6) > h3 {
  color: var(--t01-emerald);
}

/* Các block chi tiết thể (từ thứ 7 trở đi) — về nền trắng mặc định */
#t01-app #t01-groups > .r-block:nth-of-type(n+7) {
  background: var(--t01-bg);
  border-left-color: var(--t01-br-2);
}

/* ---------- 6. SỐ THỨ TỰ CHO "THỨ TỰ ƯU TIÊN XỬ LÝ" ----------
   Nhận diện block thứ tự bằng việc có nhiều <li> bắt đầu bằng "1. "
   Trick: dùng counter trên block đó — chọn nth-of-type(6)
   ------------------------------------------------------------ */
#t01-app #t01-groups > .r-block:nth-of-type(6) ul {
  list-style: none;
  padding-left: 0;
  counter-reset: t01-order;
}

#t01-app #t01-groups > .r-block:nth-of-type(6) li {
  position: relative;
  padding: 10px 12px 10px 44px;
  background: var(--t01-bg);
  border: 1px solid var(--t01-emerald-br);
  border-radius: var(--t01-radius-sm);
  margin-bottom: 8px;
  counter-increment: t01-order;
  font-weight: 500;
}

#t01-app #t01-groups > .r-block:nth-of-type(6) li::before {
  content: counter(t01-order);
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--t01-emerald);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(4, 120, 87, 0.25);
}

#t01-app #t01-groups > .r-block:nth-of-type(6) li:first-child {
  border-color: var(--t01-emerald);
  background: var(--t01-emerald-bg);
  font-weight: 600;
}

/* ---------- 7. CHUỖI NHÂN QUẢ (block thứ 5) — số tròn xám ---------- */
#t01-app #t01-groups > .r-block:nth-of-type(5) ul {
  list-style: none;
  padding-left: 0;
  counter-reset: t01-chain;
}

#t01-app #t01-groups > .r-block:nth-of-type(5) li {
  position: relative;
  padding: 8px 12px 8px 36px;
  background: var(--t01-bg);
  border-radius: var(--t01-radius-sm);
  margin-bottom: 6px;
  font-size: 0.92rem;
  counter-increment: t01-chain;
}

#t01-app #t01-groups > .r-block:nth-of-type(5) li::before {
  content: counter(t01-chain);
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--t01-slate);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- 8. RED FLAG ---------- */
#t01-app .r-redflags {
  background: var(--t01-red-bg);
  border: 1px solid var(--t01-red-br);
  border-left: 4px solid var(--t01-red);
}

#t01-app .r-redflags > h3 {
  color: var(--t01-red);
  display: flex;
  align-items: center;
  gap: 6px;
}

#t01-app .r-redflags > h3::before {
  content: "⚠";
  font-size: 1.15em;
}

#t01-app .r-redflags ul {
  list-style: none;
  padding-left: 0;
}

#t01-app .r-redflags li {
  position: relative;
  padding: 6px 10px 6px 28px;
  background: var(--t01-bg);
  border-radius: var(--t01-radius-sm);
  margin-bottom: 6px;
  border-left: 2px solid var(--t01-red);
  line-height: 1.5;
}

#t01-app .r-redflags li::before {
  content: "!";
  position: absolute;
  left: 8px;
  top: 8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--t01-red);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- 9. STRAIGHT-LINE (cảnh báo dữ liệu) ---------- */
#t01-app .r-straightline {
  background: var(--t01-yellow-bg);
  border: 1px solid var(--t01-yellow-br);
  border-left: 4px solid var(--t01-yellow);
}

#t01-app .r-straightline > h3 {
  color: var(--t01-yellow);
  display: flex;
  align-items: center;
  gap: 6px;
}

#t01-app .r-straightline > h3::before {
  content: "⚠";
  font-size: 1.05em;
}

/* ---------- 10. DANH SÁCH "MÔ TẢ GẦN NHẤT" ---------- */
#t01-app #t01-list-box {
  margin: 12px 0;
  padding: 12px 14px;
  background: var(--t01-green-050);
  border: 1px solid var(--t01-green-300);
  border-radius: var(--t01-radius);
}

#t01-app #t01-list-title {
  margin: 0 0 6px;
  font-weight: 600;
  color: var(--t01-green-700);
  font-size: 0.92rem;
}

#t01-app #t01-list {
  margin: 0;
  padding-left: 1.25rem;
}

#t01-app #t01-list a {
  color: var(--t01-green-700);
  text-decoration: none;
  font-weight: 500;
}

#t01-app #t01-list a:hover,
#t01-app #t01-list a:focus-visible {
  text-decoration: underline;
}

/* ---------- 11. BẢNG ĐIỂM 9 THỂ ---------- */
#t01-app #t01-scores {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.92rem;
}

#t01-app #t01-scores th,
#t01-app #t01-scores td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--t01-br);
}

#t01-app #t01-scores th {
  font-weight: 600;
  color: var(--t01-text-mute);
  background: var(--t01-green-050);
  border-bottom: 2px solid var(--t01-green-300);
}

#t01-app #t01-scores tr:last-child td {
  border-bottom: none;
}

#t01-app #t01-scores td:nth-child(2) {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#t01-app #t01-scores td:nth-child(3) {
  color: var(--t01-text-soft);
  font-size: 0.88rem;
}

#t01-app #t01-scores a {
  color: var(--t01-green-700);
  text-decoration: none;
  font-weight: 500;
}

#t01-app #t01-scores a:hover,
#t01-app #t01-scores a:focus-visible {
  text-decoration: underline;
}

/* ---------- 12. KHỐI META (Phương pháp & nguồn) ---------- */
#t01-app .r-meta {
  background: var(--t01-green-050);
  border: 1px solid var(--t01-green-100);
  font-size: 0.88rem;
}

#t01-app .r-meta > h3 {
  color: var(--t01-green-700);
  font-size: 0.95rem;
}

#t01-app .r-meta details {
  margin-top: 10px;
  border-top: 1px solid var(--t01-green-300);
  padding-top: 10px;
}

#t01-app .r-meta summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--t01-green-700);
  padding: 6px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

#t01-app .r-meta summary::-webkit-details-marker { display: none; }

#t01-app .r-meta summary::before {
  content: "▸";
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--t01-green-500);
  font-size: 0.85em;
}

#t01-app .r-meta details[open] summary::before {
  transform: rotate(90deg);
}

#t01-app .r-meta summary:hover,
#t01-app .r-meta summary:focus-visible {
  color: var(--t01-green-900);
  text-decoration: underline;
  outline: none;
}

#t01-app .r-meta details > p {
  margin: 6px 0 4px;
  color: var(--t01-text-mute);
  line-height: 1.55;
  font-size: 0.86rem;
}

/* ---------- 13. NÚT HÀNH ĐỘNG (In / Làm lại) ---------- */
#t01-app #t01-print,
#t01-app #t01-restart {
  display: inline-block;
  padding: 10px 18px;
  margin: 8px 8px 8px 0;
  border-radius: var(--t01-radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

#t01-app #t01-print {
  background: var(--t01-green-700);
  color: #fff;
  border-color: var(--t01-green-700);
}

#t01-app #t01-print:hover,
#t01-app #t01-print:focus-visible {
  background: var(--t01-green-900);
  border-color: var(--t01-green-900);
  outline: 3px solid var(--t01-green-300);
  outline-offset: 2px;
}

#t01-app #t01-restart {
  background: #fff;
  color: var(--t01-green-700);
  border-color: var(--t01-green-300);
}

#t01-app #t01-restart:hover,
#t01-app #t01-restart:focus-visible {
  background: var(--t01-green-050);
  outline: 3px solid var(--t01-green-300);
  outline-offset: 2px;
}

/* ---------- 14. RESPONSIVE ---------- */
@media (max-width: 640px) {
  #t01-app .r-block,
  #t01-app .r-priority-summary {
    padding: 12px 14px;
    border-radius: var(--t01-radius-sm);
  }

  #t01-app .r-priority-summary > h3 { font-size: 1rem; }
  #t01-app .r-priority-summary > p  { font-size: 0.9rem; }

  #t01-app #t01-groups > .r-block:nth-of-type(5) li,
  #t01-app #t01-groups > .r-block:nth-of-type(6) li {
    padding: 10px 10px 10px 38px;
    font-size: 0.9rem;
  }

  #t01-app #t01-scores th,
  #t01-app #t01-scores td {
    padding: 7px 8px;
    font-size: 0.86rem;
  }

  #t01-app #t01-scores td:nth-child(3) {
    display: none; /* đã có link mô tả chi tiết */
  }
}

/* ---------- 15. ACCESSIBILITY ---------- */
#t01-app a:focus-visible,
#t01-app button:focus-visible,
#t01-app summary:focus-visible {
  outline: 3px solid var(--t01-green-500);
  outline-offset: 2px;
  border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
  #t01-app .r-meta summary::before { transition: none; }
}

/* ---------- 16. DARK MODE (tùy chọn) ---------- */
@media (prefers-color-scheme: dark) {
  #t01-app {
    --t01-text:      #e5e7eb;
    --t01-text-mute: #cbd5e1;
    --t01-text-soft: #94a3b8;
    --t01-bg:        #0f172a;
    --t01-bg-soft:   #1e293b;
    --t01-br:        #334155;
    --t01-br-2:      #475569;
    --t01-green-050: #052e1a;
    --t01-green-100: #0f3d24;
    --t01-green-300: #1a5f3d;
    --t01-green-700: #86c5a2;
    --t01-green-900: #d1fae5;
  }
  #t01-app #t01-scores th { background: #0f3d24; }
  #t01-app #t01-restart { background: #0f172a; }
}

/* ---------- 17. PRINT ---------- */
@media print {
  #t01-app .r-block,
  #t01-app .r-priority-summary {
    box-shadow: none;
    background: #fff !important;
    border: 1px solid #999;
    page-break-inside: avoid;
  }

  #t01-app .r-priority-summary {
    border-left: 4px solid #333;
  }

  #t01-app #t01-groups > .r-block:nth-of-type(5) li::before,
  #t01-app #t01-groups > .r-block:nth-of-type(6) li::before {
    background: #333 !important;
    color: #fff !important;
  }

  #t01-app .r-redflags li::before { background: #900 !important; }
  #t01-app #t01-scores th { background: #f0f0f0 !important; }
}
/* ============================================================
   r6-C: 2 khối red flag tách biệt (urgent / note)
   Thêm vào cuối file tool01.css
   ============================================================ */

/* Khối urgent — đỏ (cần khám sớm) */
#t01-app .r-redflags-urgent {
  padding: 10px 12px;
  background: #fef2f2;
  border-left: 3px solid #dc2626;
  border-radius: var(--t01-radius-sm, 6px);
  margin-bottom: 10px;
}
#t01-app .r-redflags-urgent > h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
  color: #991b1b;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
#t01-app .r-redflags-urgent > h3::before {
  content: "⚠";
  font-size: 1.15em;
}
#t01-app .r-redflags-urgent ul {
  margin: 4px 0 0;
  padding-left: 1.25rem;
}
#t01-app .r-redflags-urgent li {
  color: #7f1d1d;
  line-height: 1.5;
  margin-bottom: 4px;
}

/* Khối note — vàng (theo dõi) */
#t01-app .r-redflags-note {
  padding: 10px 12px;
  background: #fefce8;
  border-left: 3px solid #ca8a04;
  border-radius: var(--t01-radius-sm, 6px);
  margin-bottom: 10px;
}
#t01-app .r-redflags-note > h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  color: #854d0e;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
#t01-app .r-redflags-note > h3::before {
  content: "ℹ️";
  font-size: 1rem;
}
#t01-app .r-redflags-note ul {
  margin: 4px 0 0;
  padding-left: 1.25rem;
}
#t01-app .r-redflags-note li {
  color: #713f12;
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 4px;
}

/* Khối always — xám (dấu hiệu cần chú ý chung) */
#t01-app .r-redflags-always {
  padding: 10px 12px;
  background: #f9fafb;
  border-left: 3px solid #9ca3af;
  border-radius: var(--t01-radius-sm, 6px);
  margin-top: 10px;
}
#t01-app .r-redflags-always > h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  color: #374151;
  font-weight: 600;
}
#t01-app .r-redflags-always ul {
  margin: 4px 0 0;
  padding-left: 1.25rem;
}
#t01-app .r-redflags-always li {
  color: #4b5563;
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 4px;
}

