/* J-2: สไตล์ของระบบ Report ทั้งหมด — โหลดทั้ง axon.html (admin) และ app.html (learner)
 *
 * แบ่ง 2 กลุ่ม:
 *   .rpt-*  = แท็บ Report ฝั่ง admin (อยู่ในบริบท legacy CSS — อ้าง var ของ
 *             tokens-legacy ได้ เพราะ selector เหล่านี้โผล่เฉพาะใน axon)
 *   .irpt-* = ตัวเอกสาร Individual Report — self-contained ไม่พึ่ง token ระบบใด
 *             (ต้องหน้าตาเหมือนกันทั้งใน admin preview, หน้านักเรียน R6, และงานพิมพ์)
 *
 * ไฟล์นี้เป็นไฟล์ใหม่ทั้งไฟล์ — จงใจไม่แตะ base-legacy.css ตามกฎ design.md §8 ข้อ 12
 *
 * .irpt-* rebuilt 2026-08-01 (pivot ที่ 2): ยกโครง/ฟอนต์/สีมาจากรายงาน TUXSA
 * ต้นแบบตรงๆ ตามคำขอเจ้าของ ("แปะ html ของ tuxsa แปลงให้เป็น general") — Fraunces +
 * IBM Plex Sans Thai self-host จากไฟล์ vendor ที่มีอยู่แล้ว (ไม่ใช่ CDN แบบต้นฉบับ)
 * โทนสี --tu-red ของ TUXSA ยกมาทั้งค่า
 */

/* ================= admin Report tab ================= */

/* Opt-in domain radar uses the same measured counts as the evidence table. */
.irpt-radar { margin: 1.5rem 0 2rem; padding: 1.25rem 0; border-block: 1px solid #e8e1d6; }
.irpt-radar h3 { margin: 0 0 .5rem; font-size: 1.15rem; }
.irpt-radar__layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: center; }
.irpt-radar__plot { display: block; width: 100%; max-width: 420px; height: auto; margin: auto; overflow: visible; }
.irpt-radar__grid { fill: none; stroke: #ddd7ce; stroke-width: 1; }
.irpt-radar__before { fill: rgba(111,106,98,.06); stroke: #6f6a62; stroke-width: 2; stroke-dasharray: 5 4; }
.irpt-radar__current { fill: rgba(176,32,47,.12); stroke: #b0202f; stroke-width: 2.5; }
.irpt-radar__axis { fill: #1c1a17; font-size: 13px; font-weight: 700; }
.irpt-radar__scale { fill: #6f6a62; font-size: 10px; }
.irpt-radar__values { margin: 0; padding: 0; list-style: none; display: grid; gap: .85rem; }
.irpt-radar__values li { display: flex; gap: .7rem; font-size: .95rem; }
.irpt-radar__values li strong, .irpt-radar__values li span span { display: block; }
.irpt-radar__values li span span { color: #6f6a62; font-size: .85rem; margin-top: .15rem; }
.irpt-radar__number { flex: 0 0 1.65rem; height: 1.65rem; text-align: center; border-bottom: 2px solid #b0202f; font-weight: 700; }
.irpt-radar__legend { display: flex; gap: 1.25rem; margin: 1rem 0 0; color: #6f6a62; font-size: .85rem; }
.irpt-radar__key::before { content: ''; display: inline-block; width: 1.2rem; margin-right: .4rem; border-top: 3px solid #b0202f; vertical-align: middle; }
.irpt-radar__key--before::before { border-color: #6f6a62; border-top-style: dashed; }
@media (max-width: 560px) { .irpt-radar__layout { grid-template-columns: minmax(0, 1fr); gap: .75rem; } }
@media print { .irpt-radar { break-inside: avoid; } }

/* โซนแบ่ง "This round" vs "Pre → Post trend" (REDUNDANCY REVIEW 2026-08-07) —
 * แค่กันตัวเลขคนละ scope (รอบเดียว vs รวมทุกรอบ) มาปนกันโดยไม่มีป้ายบอก ไม่ใช่การ์ด
 * แยกกรอบ (จงใจไม่ใส่ border/background จะได้ไม่หนักตา ให้หัวข้อทำหน้าที่คั่นพอ) */
.rpt-zone + .rpt-zone { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--line, rgba(12, 39, 84, .12)); }
.rpt-zone__title {
  margin: 0 0 .75rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink-700, #1a2b4a);
}

.rpt-h3 { margin: 1.5rem 0 .5rem; }

.rpt-kpis { margin-bottom: .25rem; }

.rpt-hist {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  margin: .25rem 0 .5rem;
}
.rpt-hist-n { font-size: 11px; font-weight: 700; fill: var(--ink-600, #465674); }
.rpt-hist-x { font-size: 10px; fill: var(--ink-500, #68758f); }

.rpt-heat td.num { min-width: 4.5rem; }

/* การ์ด "Learner access" — จุดเดียวที่เปิด/ปิด Debrief ให้ผู้เรียน (ไม่มีปุ่มรายรอบแล้ว) */
.card--inner.rpt-access { margin-bottom: 1rem; padding: .875rem 1rem; }
.rpt-access__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
}
.rpt-access__toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem 1rem;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--line, rgba(12, 39, 84, .12));
}
.rpt-access__toggles label { white-space: nowrap; }

/* R17: การ์ด "Answer key" — พี่น้องกับ .rpt-access ด้านบน (คนละสวิตช์ คนละ endpoint
   ดู panelReport()/bindAnswerKeyCard() ใน admin.js) ใช้ token สีเดิมของหน้านี้ล้วน */
.akcard__rounds { display: flex; flex-direction: column; gap: .5rem; }
.akcard__round {
  border: 1px solid var(--line, rgba(12, 39, 84, .12));
  border-radius: 8px;
  padding: .625rem .75rem;
}
.akcard__round-head {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.akcard__round-title { font-size: .875rem; font-weight: 600; }
.akcard__round-head .btn { margin-left: auto; min-width: 4.5rem; }
.akcard__subpanel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem 1rem;
  margin-top: .625rem;
  padding-top: .625rem;
  border-top: 1px solid var(--line, rgba(12, 39, 84, .12));
}
.akcard__check { display: flex; align-items: center; gap: .35rem; font-size: .875rem; white-space: nowrap; }
.akcard__check.is-disabled { color: var(--muted, #68758f); cursor: not-allowed; }

/* แถบติ๊กเลือก section ที่จะโชว์บนจอ admin — คนละชุดกับ toggle ของ Learner results */
/* .card--inner ประกาศทีหลังในไฟล์นี้ ต้องเจาะจงกว่าถึงจะชนะเรื่อง padding */
.card--inner.rpt-showbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1rem;
  margin-bottom: 1rem;
  padding: .625rem .875rem;
}
.rpt-showbar__item {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .875rem;
  white-space: nowrap;
}
#rpt-content [data-rpt-sec][hidden] { display: none; }

/* แถบปุ่มเรียงตารางรายข้อ */
.rpt-sortbar { gap: .375rem; margin: 0 0 .5rem; flex-wrap: wrap; }
.rpt-sortbar__label { font-size: .875rem; font-weight: 600; color: var(--muted); align-self: center; }

/* ปุ่ม QID ที่กดกางดูโจทย์/เฉลย/สัดส่วนตัวเลือก — ทำหน้าตาเหมือน link ในตาราง ไม่ใช่ปุ่มก้อน */
.rpt-item-toggle {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--brand-500, #126db6);
  cursor: pointer;
}
.rpt-item-toggle:hover { text-decoration: underline; }
.rpt-item-row:has(+ .rpt-item-detail) > td { background: var(--surface-2); }
.rpt-item-detail .q-choices li { display: block; }
.badge--picked {
  background: color-mix(in srgb, var(--brand-500, #126db6) 14%, transparent);
  color: var(--brand-500, #126db6);
}

.rpt-delta--ok  { color: var(--ok, #199b63); font-weight: 700; }
.rpt-delta--err { color: var(--err, #b9264d); font-weight: 700; }

/* ชิ้นที่ legacy ไม่มี — นิยามเฉพาะที่แท็บ Report ใช้ */
.pill--ok   { background: color-mix(in srgb, var(--ok, #199b63) 14%, transparent); color: var(--ok, #199b63); }
.pill--warn { background: color-mix(in srgb, var(--warn, #e29a00) 14%, transparent); color: var(--warn, #e29a00); }
.card--inner {
  border: 1px solid var(--line, rgba(12, 39, 84, .12));
  box-shadow: none;
  padding: 1rem;
}
.btn--danger {
  color: var(--err, #b9264d);
  border-color: color-mix(in srgb, var(--err, #b9264d) 45%, transparent);
}
.btn--danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--err, #b9264d) 10%, transparent);
}

/* โหมดฉายจอ (design.md §6): KPI 28-38px · ตาราง 14.5px · label กราฟ 16-17px */
.report-projector .stat__value { font-size: clamp(28px, 2.5vw, 38px); }
.report-projector .stat__label { font-size: 14px; }
.report-projector table { font-size: 14.5px; }
.report-projector th { font-size: 13px; }
.report-projector .rpt-hist { max-width: 900px; }
.report-projector .rpt-hist-n { font-size: 16px; }
.report-projector .rpt-hist-x { font-size: 16px; }
.report-projector .rpt-h3 { font-size: 1.35rem; }
.report-projector .rpt-zone__title { font-size: 1.55rem; }
.report-projector .small,
.report-projector .muted.small { font-size: .95rem; }

/* ================= Pre/Post comparison — SHARED renderer (K5-H3 v2) =================
 * markup มาจาก prepost-render.js เดียวกันเป๊ะทั้ง admin (ที่นี่) และ HR
 * (base.css) — เจ้าของสั่งตรงๆ "report ของหน้า admin และ hr report กรณีที่
 * เป็น pre post ควรจะเหมือนกันทุกอย่าง" คลาส .pp-* ชื่อเดียวกันทั้งสองไฟล์
 * แค่ค่า token ต่างกันตามระบบสีของแต่ละหน้า (ที่นี่ = legacy)
 *
 * design.md §2.1 (LOCKED): แดง CONC (--conc-600 #ed1a23) เป็นสีนำจริงเดียวของ
 * ทั้งระบบ — axon.html (admin) ทั้งหน้ายังไม่พอร์ตเข้า R6 (ยังใช้
 * tokens-legacy.css สีฟ้า TBS เดิมทั้งจอ ตามกฎ "ห้ามเปลี่ยน <link> จนกว่าจะมี
 * รอบพอร์ต admin") — ส่วนนี้เป็นข้อยกเว้นที่เจ้าของอนุมัติเฉพาะจุด: After ใช้
 * --conc-600 แดงของแบรนด์จริงแทนสีฟ้า legacy เดิม, Before เป็นเทาเข้ม (ค่า
 * อ้างอิง) · delta +/- ยังคง --ok/--err เขียว/แดงเหมือนเดิมทั้งไฟล์ (ห้ามใช้
 * --color-signature กับข้อความ error — สองแดงนี้สื่อคนละเรื่อง) */
.pp-report { margin: 0 0 1.5rem; }
.pp-muted { color: var(--ink-500, #68758f); }
.pp-h3 { margin: 1.25rem 0 .375rem; font-size: 1rem; font-weight: 700; }
.pp-note { margin: .375rem 0 0; font-size: .8125rem; color: var(--ink-500, #68758f); }
.pp-section { margin-top: 1rem; }
.pp-delta--ok  { color: var(--ok, #199b63); font-weight: 700; }
.pp-delta--err { color: var(--err, #b9264d); font-weight: 700; }

.pp-topbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding-bottom: .625rem;
  margin-bottom: .5rem;
  border-bottom: 1px solid var(--line, rgba(12, 39, 84, .12));
}
.pp-logo { display: block; height: 28px; width: auto; object-fit: contain; }
.pp-topbar__t1 { margin: 0; font-weight: 700; font-size: 1.0625rem; }
.pp-topbar__t2 { margin: .125rem 0 0; font-size: .8125rem; color: var(--ink-500, #68758f); }

.pp-hero {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  margin: .5rem 0;
}
.pp-hero__card {
  border: 1px solid var(--line, rgba(12, 39, 84, .12));
  border-radius: 12px;
  padding: 1rem 1.25rem;
  background: var(--surface-muted, #f6f9fc);
}
.pp-hero__card--after {
  background: color-mix(in srgb, var(--conc-600, #ed1a23) 8%, var(--surface-muted, #f6f9fc));
  border-color: color-mix(in srgb, var(--conc-600, #ed1a23) 30%, transparent);
}
.pp-hero__label { margin: 0 0 .375rem; font-size: .8125rem; font-weight: 600; color: var(--ink-600, #465674); }
.pp-hero__num { margin: 0; font-size: 2.25rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-900, #0c1938); line-height: 1; }
.pp-hero__card--after .pp-hero__num { color: var(--conc-600, #ed1a23); }
.pp-hero__unit { font-size: 1.25rem; font-weight: 500; color: var(--ink-500, #68758f); }
.pp-hero__arrow { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.pp-hero__arrowicon { font-size: 1.5rem; color: var(--ink-400, #8e99ad); }

.pp-legend { display: flex; gap: 1rem; margin: .25rem 0 .5rem; }
.pp-legend__item { display: inline-flex; align-items: center; gap: .375rem; font-size: .8125rem; color: var(--ink-600, #465674); }
.pp-legend__swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.pp-legend__swatch--before { background: var(--ink-400, #8e99ad); }
.pp-legend__swatch--after  { background: var(--conc-600, #ed1a23); }

.pp-dist-svg { display: block; width: 100%; max-width: 640px; height: auto; }
.pp-dist-before { fill: var(--ink-400, #8e99ad); }
.pp-dist-after  { fill: var(--conc-600, #ed1a23); }
.pp-dist-n { font-size: 11px; font-weight: 700; fill: var(--ink-600, #465674); }
.pp-dist-x { font-size: 10px; fill: var(--ink-500, #68758f); }
.pp-dist-axis { stroke: var(--line-strong, rgba(12, 39, 84, .2)); }

.pp-topics { display: flex; flex-direction: column; gap: .75rem; }
.pp-topic { border: 1px solid var(--line, rgba(12, 39, 84, .12)); border-radius: 10px; padding: .625rem .875rem; }
.pp-topic__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .375rem; }
.pp-topic__name { font-weight: 600; font-size: .9375rem; }
.pp-topic__track { height: 7px; border-radius: 999px; background: var(--surface-muted, #f6f9fc); overflow: hidden; margin-bottom: 3px; }
.pp-topic__track:last-of-type { margin-bottom: 0; }
.pp-topic__fill { height: 100%; border-radius: inherit; }
.pp-topic__fill--before { background: var(--ink-400, #8e99ad); }
.pp-topic__fill--after  { background: var(--conc-600, #ed1a23); }
.pp-topic__missing { height: 100%; padding-left: .35rem; color: var(--ink-500, #667085); font-size: .625rem; line-height: 7px; white-space: nowrap; }

.pp-tablewrap { overflow-x: auto; }
.pp-table { width: 100%; border-collapse: collapse; font-size: .9375rem; margin-top: .375rem; }
.pp-table th { text-align: left; padding: .5rem .625rem; font-weight: 600; font-size: .8125rem; color: var(--ink-500, #68758f); border-bottom: 1px solid var(--line-strong, rgba(12, 39, 84, .2)); }
.pp-table td { padding: .5rem .625rem; border-bottom: 1px solid var(--line, rgba(12, 39, 84, .12)); }
.pp-table tbody tr:nth-child(even) { background: var(--surface-muted, #f6f9fc); }
.pp-num { text-align: right; font-variant-numeric: tabular-nums; }

/* ปุ่มหัวคอลัมน์ที่กดเรียงได้ (admin only — hr.js ไม่เรียก bindTable() เลยไม่มี
   <button> โผล่ในตารางฝั่ง HR) — reset ปุ่มให้กลืนกับ <th> เดิมทุกอย่าง ต่างแค่
   cursor + hover/focus ให้รู้ว่ากดได้ */
.pp-table th button.pp-sortbtn {
  all: unset;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: inline-block;
  border-radius: 4px;
  padding: .125rem .25rem;
  margin: -.125rem -.25rem;
}
.pp-table th button.pp-sortbtn:hover,
.pp-table th button.pp-sortbtn:focus-visible {
  color: var(--ink-900, #0c2754);
  background: var(--surface-muted, #f6f9fc);
}
.pp-table th button.pp-sortbtn:focus-visible { outline: 2px solid var(--focus, #2f6fed); outline-offset: 1px; }
.pp-table th[aria-sort="ascending"] button.pp-sortbtn,
.pp-table th[aria-sort="descending"] button.pp-sortbtn { color: var(--ink-900, #0c2754); font-weight: 700; }

@media (max-width: 680px) {
  .pp-hero { grid-template-columns: 1fr; }
  .pp-hero__arrow { flex-direction: row; justify-content: center; }
}

/* ================= Individual Report — ฟอนต์ =================
 * Noto Sans Thai ตระกูลเดียวทั้งฉบับ (story redesign 2026-09-30) — ประกาศ @font-face
 * ไว้แล้วใน fonts.css ซึ่งทั้ง app.html และ axon.html โหลด (self-host, wght 400–700)
 * เดิมหัวข้อ/ตัวเลขใช้ "Fraunces Report" ที่มีแต่ Latin: ในบรรทัดเดียวกันตัวไทยตกไปเป็น
 * sans ส่วนตัวเลข/อังกฤษเป็น serif — เจ้าของเห็นเป็น "ฟอนต์ตก" จึงถอดออกทั้งหมด
 * ห้ามใช้ font-weight เกิน 700 (ไม่มีไฟล์ จะกลายเป็น faux bold)
 * ตัวเลขใช้ tabular-nums ให้หลักตรงกันในตาราง/ตัวเลขใหญ่ */

/* ================= Individual Report (เอกสาร) ================= */

.irpt-report {
  --tu-red: #b01e2e;
  --tu-red-dark: #7c1620;
  --tu-ink: #1a1a1a;
  --tu-muted: #6b6b6b;
  --tu-line: #e7e3dd;
  --tu-paper: #fbf9f6;
  --tu-card: #ffffff;
  /* --tu-good/--tu-warn ปรับเข้มขึ้นจากค่า TUXSA ต้นฉบับ (#2f7d4f / #b8860b) —
     วัด contrast จริงบน -bg ของตัวเองแล้วตกเกณฑ์ WCAG AA (4.29:1 / 2.92:1,
     ต้องการ 4.5:1) ค่าใหม่วัดได้ 5.47:1 / 4.94:1 — --tu-warn ใหม่ตรงกับ
     --warn-600 ของ design.md แม่ระบบพอดี (ค่าที่ verify แล้วจริงในโปรเจกต์นี้) */
  --tu-good: #256b45;
  --tu-good-bg: #e3f0e7;
  --tu-warn: #8f5f08;
  --tu-warn-bg: #fbf2da;
  /* บทบาทสีของรายงาน (เจ้าของเลือก 2026-10-02, ทางเลือก B) — ห้ามใช้สีนอกบทบาท:
   *   คุณ (หลังเรียน/คะแนนปัจจุบัน) = --tu-red   ก่อนเรียน = --tu-muted
   *   ค่าเฉลี่ยรุ่น = เส้นประ --tu-ink (ไม่มีสี)   ดีขึ้น = --tu-good   ลดลง/ต่ำ = --tu-bad (ส้มอำพัน)
   * แดงจึงไม่เคยแปลว่า "แย่" — เดิม --tu-bad เป็นแดงค่าเดียวกับ --tu-red ทำให้คะแนนที่เพิ่มขึ้น
   * ดูเหมือนผลแย่ #a35400: ตัวหนังสือ AA ทุกพื้น (5.22:1 บน paper, 4.81:1 บน -bg) และห่างจาก
   * --tu-good สำหรับสายตาปกติ ΔE 18.3 (dataviz validator) — ตาบอดสีแยกได้น้อย จึงต้องมี
   * +/− หรือคำกำกับทุกจุดที่ใช้คู่นี้ */
  --tu-bad: #a35400;
  --tu-bad-bg: #fbeedf;
  --tu-gold: #c9a44c;
  --tu-ink-soft: #333333;
  --tu-track: #eeeeee;
  --tu-stripe: #faf7f3;
  --tu-tag-bg: #f3efe9;

  position: relative;
  container-type: inline-size;
  max-width: 880px;
  margin: 0 auto;
  padding: 1.75rem 2rem 2rem;
  background: var(--tu-paper);
  color: var(--tu-ink);
  border: 1px solid var(--tu-line);
  border-radius: 14px;
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

.irpt-flag {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: .5rem;
  border-radius: 2px;
  background: var(--tu-red);
  vertical-align: middle;
}

/* masthead — ชื่อผู้เรียนเป็นหัวเรื่อง ข้อมูลประกอบเป็นบรรทัดเล็กสีเทา */
.irpt-topbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  border-bottom: 2px solid var(--tu-red);
  padding-bottom: .75rem;
}
.irpt-logo { display: block; height: 34px; width: auto; object-fit: contain; }
.irpt-topbar__t1 { margin: 0; font-weight: 600; font-size: .9375rem; color: var(--tu-red); }
.irpt-topbar__t2 { margin: 0; font-size: .8125rem; color: var(--tu-muted); }
.irpt-mast__name { margin: 1.25rem 0 .25rem; font-size: 1.875rem; font-weight: 700; line-height: 1.35; color: var(--tu-ink); }
.irpt-mast__meta { display: flex; flex-wrap: wrap; margin: 0; font-size: .8125rem; color: var(--tu-muted); }
.irpt-mast__meta > span:not(:last-child)::after { content: "·"; margin: 0 .5rem; }
.irpt-mast__partial { color: var(--tu-warn); font-weight: 600; }
.irpt-muted { color: var(--tu-muted); }
/* กันเบราว์เซอร์ตัดคำไทยกลางชื่อด้าน หรือแยกตัวเลขออกจากหน่วย (ดู keep() ใน report-render.js) */
.irpt-keep { white-space: nowrap; }

/* บท — แบ่งด้วยช่องว่าง + เส้นบางเส้นเดียว ไม่ใช้กล่อง (handoff §6) */
.irpt-ch { margin-top: 3rem; }
.irpt-ch--overview { margin-top: 2rem; }
.irpt-chhead {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  margin: 0 0 1rem;
  padding-top: .875rem;
  border-top: 1px solid var(--tu-line);
}
.irpt-chhead__no { font-size: .8125rem; font-weight: 700; color: var(--tu-red); font-variant-numeric: tabular-nums; }
.irpt-chhead__title { margin: 0; font-size: 1.375rem; font-weight: 700; line-height: 1.45; color: var(--tu-ink); }

/* บทที่ 1 · ภาพรวม */
/* ประโยคสรุปเป็นจุดแรกที่สายตาตก — เนื้อประโยคน้ำหนักกลาง คำสำคัญหนาและมีสีตามความหมาย */
.irpt-headline { margin: 0 0 1.5rem; max-width: 34em; font-size: 1.5rem; font-weight: 500; line-height: 1.6; color: var(--tu-ink-soft); text-wrap: pretty; }
.irpt-em { font-weight: 700; color: var(--tu-ink); }
.irpt-em--post { color: var(--tu-red); }
.irpt-em--up { color: var(--tu-good); }
.irpt-em--down { color: var(--tu-bad); }

/* แผงคะแนน — ตัวเลขใหญ่ + เส้นทางบนสเกล + เทียบรุ่น อยู่ในกรอบเดียว (กรอบเดียวของบท) */
.irpt-journey { margin-top: .25rem; }
.irpt-journey .irpt-rankline {
  margin-top: 1.25rem;
  padding: .875rem 0 0;
  border-top: 1px solid var(--tu-line);
  border-radius: 0;
  background: none;
  border-top: 0;
  padding-top: 0;
}

/* เส้นทางคะแนน 0–100 (ดู renderScoreTrack) — ป้ายค่าเฉลี่ยรุ่นอยู่เหนือเส้น แกนอยู่ใต้เส้น
   จึงไม่ชนกันไม่ว่าค่าเฉลี่ยจะอยู่ตรงไหน */
.irpt-track { margin-top: 2.5rem; }
.irpt-track__plot { position: relative; height: 16px; }
.irpt-track__rail,
.irpt-track__seg {
  position: absolute;
  top: 5px;
  height: 6px;
  border-radius: 999px;
}
.irpt-track__rail { left: 0; right: 0; background: var(--tu-track); }
.irpt-track__seg--up { background: color-mix(in srgb, var(--tu-good) 55%, transparent); }
.irpt-track__seg--down { background: color-mix(in srgb, var(--tu-bad) 45%, transparent); }
.irpt-track__dot {
  position: absolute;
  top: 0;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--tu-card);
}
.irpt-track__dot--before { background: var(--tu-muted); }
.irpt-track__dot--after { background: var(--tu-red); }
.irpt-track__avg {
  position: absolute;
  top: -7px;
  bottom: -7px;
  width: 0;
  border-left: 2px dashed var(--tu-ink);
}
.irpt-track__avglbl {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  transform: translateX(-50%);
  font-size: .75rem;
  color: var(--tu-ink-soft);
  white-space: nowrap;
}
.irpt-track__avg--start .irpt-track__avglbl { transform: translateX(-4px); }
.irpt-track__avg--end .irpt-track__avglbl { transform: translateX(calc(-100% + 4px)); }
.irpt-track__axis {
  display: flex;
  justify-content: space-between;
  margin-top: .375rem;
  font-size: .6875rem;
  color: var(--tu-muted);
  font-variant-numeric: tabular-nums;
}

/* สรุปรายด้าน — รายการสามบรรทัด คั่นด้วยเส้นบางสีกลาง ไม่ใช่การ์ด/แถบสี */
.irpt-summary { margin: 1.75rem 0 0; padding: 0; }
.irpt-sumrow {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: .75rem;
  align-items: baseline;
  padding: .625rem 0;
  border-top: 1px solid var(--tu-line);
}
.irpt-sumrow:last-child { border-bottom: 1px solid var(--tu-line); }
.irpt-sumrow dt { margin: 0; font-size: .875rem; color: var(--tu-muted); }
.irpt-sumrow dd { display: flex; flex-wrap: wrap; align-items: baseline; gap: .125rem .75rem; margin: 0; }
.irpt-sumrow strong { font-size: 1.125rem; font-weight: 700; color: var(--tu-ink); }
.irpt-sumrow dd span { font-size: .9375rem; color: var(--tu-muted); font-variant-numeric: tabular-nums; }
.irpt-figs { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem 1.75rem; }
.irpt-fig { min-width: 0; }
.irpt-fig__lbl { margin: 0 0 .125rem; font-size: .8125rem; font-weight: 600; color: var(--tu-muted); }
.irpt-fig__num {
  margin: 0;
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  color: var(--tu-ink);
}
.irpt-fig__unit { margin-left: .05em; font-size: .45em; font-weight: 600; }
.irpt-fig__sub { margin: .125rem 0 0; font-size: .8125rem; color: var(--tu-muted); font-variant-numeric: tabular-nums; }
.irpt-fig--before .irpt-fig__num { color: var(--tu-muted); }
.irpt-fig--after .irpt-fig__num { color: var(--tu-red); }
.irpt-fig--delta { padding-left: 1.75rem; border-left: 1px solid var(--tu-line); }
.irpt-fig--delta .irpt-fig__num { font-size: 2.25rem; }
.irpt-fig--up .irpt-fig__num { color: var(--tu-good); }
.irpt-fig--down .irpt-fig__num { color: var(--tu-bad); }
.irpt-fig--flat .irpt-fig__num { color: var(--tu-muted); }
.irpt-figs__arrow {
  flex: none;
  align-self: center;
  width: 28px;
  height: 28px;
  margin-top: .75rem;
  fill: none;
  stroke: var(--tu-muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.irpt-rankline {
  margin: 1.5rem 0 0;
  padding: .625rem .875rem;
  border-radius: 10px;
  background: var(--tu-tag-bg);
  font-size: .9375rem;
  font-variant-numeric: tabular-nums;
}
.irpt-rankline strong { font-weight: 700; color: var(--tu-ink); }

/* บทที่ 2 · สิ่งที่คุณได้จากการเรียน (ดู renderEvidence) */
.irpt-ch-lead { margin: 0 0 1rem; max-width: 34em; font-size: 1.125rem; font-weight: 500; line-height: 1.6; color: var(--tu-ink-soft); text-wrap: pretty; }
.irpt-ch-lead + .irpt-db__legend { margin-top: -.25rem; }
.irpt-tbar__key ~ .irpt-ch-lead { margin-top: 2.25rem; }

/* แถบเดียวแบ่งส่วน: ตระกูลเขียว = หลังเรียนตอบถูก (เข้ม = เปลี่ยน อ่อน = เท่าเดิม)
   ตระกูลส้ม = หลังเรียนยังผิด ช่องว่าง 2px สีพื้นคั่นทุกส่วน + ป้ายข้อความทุกส่วน */
.irpt-tbar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; }
.irpt-tbar__seg { flex-basis: 0; min-width: 4px; }
.irpt-tbar__seg--ret, .irpt-tbar__sw--ret { background: #b7d3c0; }
.irpt-tbar__seg--learn, .irpt-tbar__sw--learn { background: var(--tu-good); }
.irpt-tbar__seg--slip, .irpt-tbar__sw--slip { background: var(--tu-bad); }
.irpt-tbar__seg--gap, .irpt-tbar__sw--gap { background: #e8c9a4; }
.irpt-tbar__key { display: flex; flex-wrap: wrap; gap: .375rem 1.25rem; margin: .625rem 0 0; padding: 0; list-style: none; font-size: .875rem; color: var(--tu-ink-soft); }
.irpt-tbar__item { display: inline-flex; align-items: center; gap: .375rem; }
.irpt-tbar__item strong { font-weight: 700; color: var(--tu-ink); font-variant-numeric: tabular-nums; }
.irpt-tbar__item--zero { color: var(--tu-muted); }
.irpt-tbar__item--zero strong { color: var(--tu-muted); font-weight: 500; }
.irpt-tbar__sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }

/* dumbbell รายด้าน — ชื่อ | สเกล 0–100 | ส่วนต่าง เส้นเชื่อมสีตามทิศ + หัวลูกศรที่ปลายหลังเรียน */
.irpt-db__legend { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.25rem; margin: 2rem 0 .5rem; font-size: .8125rem; color: var(--tu-muted); }
.irpt-db__legend span { display: inline-flex; align-items: center; gap: .375rem; }
.irpt-db__key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.irpt-db__key--pre { background: var(--tu-muted); }
.irpt-db__key--post { background: var(--tu-red); }
.irpt-db__key--avg { width: 0; height: 14px; border-radius: 0; border-left: 2px dashed var(--tu-ink); }
.irpt-dbs { margin: 0; padding: 0; list-style: none; }
.irpt-db {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr) 4rem;
  align-items: center;
  gap: 1rem;
  padding: .5rem 0;
  border-top: 1px solid var(--tu-line);
}
.irpt-db:last-child { border-bottom: 1px solid var(--tu-line); }
.irpt-db__name { font-size: .9375rem; font-weight: 600; line-height: 1.45; }
.irpt-db__plot { position: relative; height: 22px; }
.irpt-db__rail { position: absolute; left: 0; right: 0; top: 10px; height: 2px; background: var(--tu-track); }
.irpt-db__line { position: absolute; top: 9px; height: 4px; border-radius: 2px; }
.irpt-db__line--up { background: var(--tu-good); }
.irpt-db__line--down { background: var(--tu-bad); }
/* หัวลูกศรชี้ทิศ ปลายแตะขอบจุดหลังเรียนพอดี (จุดรัศมี 7px) */
.irpt-db__line::after { content: ""; position: absolute; top: -4px; border: 6px solid transparent; }
.irpt-db__line--up::after { right: 7px; border-left: 9px solid var(--tu-good); border-right: 0; }
.irpt-db__line--down::after { left: 7px; border-right: 9px solid var(--tu-bad); border-left: 0; }
.irpt-db__dot { position: absolute; top: 4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; box-shadow: 0 0 0 2px var(--tu-paper); }
.irpt-db__dot--pre { background: var(--tu-muted); }
.irpt-db__dot--post { background: var(--tu-red); }
.irpt-db__avg { position: absolute; top: 2px; bottom: 2px; width: 0; border-left: 2px dashed var(--tu-ink); }
.irpt-db__missing { position: absolute; top: 2px; font-size: .8125rem; color: var(--tu-muted); }
.irpt-db__delta { justify-self: end; font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--tu-ink); }
.irpt-db__delta--up { color: var(--tu-good); }
.irpt-db__delta--down { color: var(--tu-bad); }
.irpt-db__delta--flat { color: var(--tu-muted); font-weight: 500; }

/* ตารางในภาคผนวก — หัวตารางเรียบ ไม่ใช่แถบแดง */
.irpt-table.irpt-table--plain th { background: none; color: var(--tu-muted); font-size: .8125rem; border-bottom: 1px solid var(--tu-ink); border-radius: 0 !important; }
.irpt-table.irpt-table--plain tbody tr:nth-child(even) { background: none; }
.irpt-num--post { color: var(--tu-red); font-weight: 700; }

/* บทที่ 3 · จุดแข็งและสิ่งที่ควรทำต่อ (ดู renderNextSteps) — ไม่มีการ์ด ใช้หัวข้อ + เส้นบาง */
/* ชื่อรูปแบบเป็นจุดเด่นของบท — สีแดง = "คุณ" ตามบทบาทสีของรายงาน; น้ำหนักมาจากขนาดตัวอักษร
   ไม่ใช่กรอบ (ห้ามการ์ดซ้อนในการ์ดรายงาน) หัวคอลัมน์ใช้สีตามความหมาย: เขียว = จุดแข็ง, ส้ม = ควรพัฒนา */
.irpt-profile__name { margin: 0 0 .5rem; font-size: 1.875rem; font-weight: 700; line-height: 1.35; color: var(--tu-red); text-wrap: balance; }
.irpt-profile__desc { margin: 0; max-width: 36em; font-size: 1.125rem; line-height: 1.7; color: var(--tu-ink); }
.irpt-profile__cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem 2.5rem; margin: 1.75rem 0 0; }
.irpt-profile__col { padding-top: .75rem; border-top: 2px solid var(--tu-line); }
.irpt-profile__col--strength { border-top-color: var(--tu-good); }
.irpt-profile__col--develop { border-top-color: var(--tu-bad); }
.irpt-profile__cols dt { margin: 0 0 .375rem; font-size: .9375rem; font-weight: 700; }
.irpt-profile__col--strength dt { color: var(--tu-good); }
.irpt-profile__col--develop dt { color: var(--tu-bad); }
.irpt-profile__cols dd { margin: 0; font-size: 1.0625rem; line-height: 1.7; color: var(--tu-ink); }
.irpt-profile__basis { margin: 1rem 0 0; font-size: .875rem; color: var(--tu-muted); }
.irpt-profile__basis strong { font-weight: 600; color: var(--tu-ink-soft); }
.irpt-sub { margin: 2.25rem 0 .5rem; font-size: 1.0625rem; font-weight: 700; line-height: 1.5; color: var(--tu-ink); }
.irpt-chhead + .irpt-sub { margin-top: 0; }
.irpt-topics { margin: 0; padding: 0; list-style: none; counter-reset: topic; }
.irpt-topic {
  position: relative;
  padding: .875rem 0 .875rem 2.25rem;
  border-top: 1px solid var(--tu-line);
  counter-increment: topic;
}
.irpt-topic:last-child { border-bottom: 1px solid var(--tu-line); }
/* เลขลำดับคือความสำคัญ (เรียงจากทำได้น้อยสุด) จึงคงไว้ */
.irpt-topic::before {
  content: counter(topic);
  position: absolute;
  left: 0;
  top: .8rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--tu-muted);
  font-variant-numeric: tabular-nums;
}
.irpt-topic__title { margin: 0; font-size: 1rem; font-weight: 700; line-height: 1.5; color: var(--tu-ink); }
.irpt-topic__score { margin: .125rem 0 0; font-size: .875rem; color: var(--tu-muted); font-variant-numeric: tabular-nums; }
.irpt-topic__desc { margin: .375rem 0 0; max-width: 42em; font-size: .9375rem; line-height: 1.7; color: var(--tu-ink-soft); }
.irpt-topic__ref { margin: .25rem 0 0; font-size: .875rem; color: var(--tu-muted); }

/* บทที่ 4 · เจาะลึกรายข้อ (ดู renderItemDetail) — ทุกข้อเปิดอยู่ คั่นด้วยเส้นบาง ไม่ใช่การ์ด
   ป้ายที่เลือก: ก่อนเรียน เทา · หลังเรียน แดง ("คุณ") · คำตอบที่ถูก เขียว + พื้นเขียวอ่อนทั้งแถว */
.irpt-sub__count { margin-left: .375rem; font-size: .875rem; font-weight: 400; color: var(--tu-muted); }
.irpt-qs { margin: 0; padding: 0; list-style: none; }
.irpt-q { padding: 1rem 0 1.125rem; border-top: 1px solid var(--tu-line); break-inside: avoid; }
.irpt-q:last-child { border-bottom: 1px solid var(--tu-line); }
.irpt-q__meta { display: block; margin: 0 0 .25rem; font-size: .8125rem; color: var(--tu-muted); }
.irpt-q__status { display: inline-flex; align-items: center; gap: .375rem; color: var(--tu-ink-soft); }
.irpt-q__status .irpt-tbar__sw { flex: none; }
.irpt-q__stem { margin: 0 0 .625rem; max-width: 46em; font-size: 1rem; font-weight: 600; line-height: 1.65; color: var(--tu-ink); }
.irpt-q--compact { display: flex; align-items: baseline; gap: 1rem; padding: .5rem 0; }
.irpt-q--compact .irpt-q__stem { flex: 1; margin: 0; font-size: .9375rem; font-weight: 400; color: var(--tu-ink-soft); }
.irpt-q--compact .irpt-q__meta { margin: 0; }
.irpt-q__key { flex: none; font-size: .875rem; font-weight: 700; color: var(--tu-good); font-variant-numeric: tabular-nums; }
.irpt-q__key--count { color: var(--tu-ink); }
.irpt-choices { display: grid; gap: .25rem; margin: 0; padding: 0; list-style: none; }
.irpt-choice { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; padding: .3rem .5rem; margin: 0 -.5rem; border-radius: 6px; font-size: .9375rem; line-height: 1.6; color: var(--tu-ink-soft); }
.irpt-choice--key { background: var(--tu-good-bg); color: #173d28; font-weight: 600; }
.irpt-choice__l { flex: none; width: 1rem; font-weight: 600; color: var(--tu-muted); }
.irpt-choice--key .irpt-choice__l { color: var(--tu-good); }
.irpt-choice__t { flex: 0 1 auto; min-width: 0; }
/* ป้ายวางต่อท้ายข้อความ ไม่ดันไปขอบขวา สายตาไม่ต้องเดินไกล */
.irpt-choice__marks { display: inline-flex; flex-wrap: wrap; gap: .375rem; flex: none; }
.irpt-pick { font-size: .75rem; font-weight: 600; line-height: 1.5; padding: 0 .4rem; border-radius: 4px; border: 1px solid currentColor; white-space: nowrap; }
.irpt-pick--pre { color: var(--tu-muted); }
.irpt-pick--post { color: var(--tu-red); }
.irpt-pick--key { border-color: transparent; padding: 0; color: var(--tu-good); }

/* ภาคผนวก — section ปกติ ไม่พับ แต่ลดน้ำหนักภาพ */
.irpt-appx .irpt-chhead__title { font-size: 1.125rem; }
.irpt-appx__block + .irpt-appx__block { margin-top: 1.75rem; }
.irpt-appx__h { margin: 0 0 .75rem; font-size: 1rem; font-weight: 600; line-height: 1.6; color: var(--tu-ink); }
.irpt-appx__scope { margin-left: .375rem; font-size: .8125rem; font-weight: 400; color: var(--tu-muted); }
.irpt-statgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .75rem 1.25rem;
  margin: 0;
}
.irpt-statgrid > div { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.irpt-statgrid dt { margin: 0; font-size: .75rem; color: var(--tu-muted); }
.irpt-statgrid dd { margin: 0; font-size: 1.125rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.irpt-statgrid dd small { font-size: .75rem; font-weight: 400; color: var(--tu-muted); }

.irpt-card {
  background: var(--tu-card);
  border: 1px solid var(--tu-line);
  border-radius: 16px;
  padding: 1.375rem;
}
.irpt-note--callout {
  margin-top: 1.125rem;
  padding: .625rem .875rem;
  border-radius: 8px;
  background: var(--tu-warn-bg);
  color: var(--tu-warn);
  font-size: .9375rem;
}

/* section headers — editorial: serif + แถบแดง */
.irpt-section { margin-top: 1.75rem; }
.irpt-sec {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin: 0 0 .25rem;
  font-weight: 600;
  font-size: 1.4375rem;
}
.irpt-sec .irpt-flag { width: 7px; height: 22px; border-radius: 3px; margin-right: 0; }
.irpt-seclead { margin: 0 0 1rem; font-size: 1rem; color: var(--tu-muted); }

/* bar — เก็บไว้เพิ่มจากต้นฉบับ TUXSA: threshold/avg line ตาม REPORT-SPEC.md §R7.5 */
.irpt-bar {
  border: 1px solid var(--tu-line);
  border-top: none;
  border-radius: 0 0 11px 11px;
  background: var(--tu-card);
  padding: 0 .875rem .625rem;
  margin-bottom: .75rem;
}
.irpt-bar--level {
  border: 1px solid var(--tu-line);
  border-radius: 11px;
  background: var(--tu-card);
  padding: .75rem .875rem;
  margin-bottom: .625rem;
}
.irpt-bar__head { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .3rem; font-size: 1rem; }
.irpt-bar__label { font-weight: 600; }
.irpt-bar__track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--tu-line);
  overflow: visible;
}
.irpt-bar__fill { height: 100%; border-radius: 999px; background: var(--tu-red); min-width: 2px; }
.irpt-bar__missing {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 .35rem;
  color: var(--tu-muted);
  font-size: .65rem;
  white-space: nowrap;
}

.irpt-bar__num { margin: .4rem 0 0; font-size: .75rem; font-variant-numeric: tabular-nums; }

/* แถบคู่ Pre/Post (before เทา, after แดง) — ใช้ทั้งใน domain breakdown และ level
 * breakdown เมื่อ data.pre_post มีค่า (ดู renderDomainBreakdown/renderLevelBreakdown) */
.irpt-bar--pp .irpt-bar__track { margin-top: .375rem; }
.irpt-bar--pp .irpt-bar__track:first-child { margin-top: .625rem; }
.irpt-bar__track--before { height: 6px; }
.irpt-bar__fill--before { background: var(--tu-muted); }

.irpt-level-desc { font-weight: 400; }

/* action / priority cards — TUXSA .action */

/* trend (Chart.js canvas) */
.irpt-trendwrap { position: relative; height: 240px; }
.irpt-trend-canvas { display: block; width: 100%; height: 100%; }
.irpt-delta--ok   { color: var(--tu-good); }
.irpt-delta--down { color: var(--tu-bad); }

/* persona */

/* ข้อที่ตอบผิด */

.irpt-tablewrap { overflow-x: auto; }
.irpt-table { width: 100%; border-collapse: collapse; font-size: .9375rem; margin-top: .375rem; }
.irpt-table th { background: var(--tu-red); color: #fff; text-align: left; padding: .5625rem .6875rem; font-weight: 600; font-size: .875rem; }
.irpt-table th:first-child { border-radius: 8px 0 0 8px; }
.irpt-table th:last-child { border-radius: 0 8px 8px 0; }
.irpt-table td { padding: .5625rem .6875rem; border-bottom: 1px solid var(--tu-line); vertical-align: top; }
.irpt-table tbody tr:nth-child(even) { background: var(--tu-stripe); }
.irpt-table .irpt-num { text-align: right; font-variant-numeric: tabular-nums; }

.irpt-report--empty { padding: 2.5rem; text-align: center; color: var(--tu-muted, #6b6b6b); }

.irpt-note { margin: .5rem 0 0; font-size: .8125rem; color: var(--tu-muted); }
.irpt-foot { margin-top: 2.25rem; border-top: 1px solid var(--tu-line); padding-top: .875rem; }
.irpt-copyright { margin: .375rem 0 0; font-size: .75rem; color: var(--tu-muted); }

/* กล่องอธิบาย section ที่ว่าง — เฉพาะ admin preview (data.diagnostics, ดู
   report-render.js renderDiagnostics()) เจตนาให้เด่นชัดว่า "ไม่ใช่ส่วนของ
   รายงานจริง" (เส้นประ + สีเตือน ตัดกับการ์ด/section อื่นทั้งหมดที่เป็นเส้นทึบ) —
   ซ่อนตอนพิมพ์ด้วย @media print ด้านล่าง กันหลุดไปโผล่บนกระดาษที่แจกจริง */
.irpt-diag {
  margin-top: 2rem;
  padding: 1rem 1.25rem;
  border: 2px dashed var(--tu-warn);
  border-radius: 10px;
  background: var(--tu-warn-bg);
}
.irpt-diag__title {
  margin: 0 0 .5rem;
  font-size: .8125rem;
  font-weight: 700;
  color: var(--tu-warn);
}
.irpt-diag ul { margin: 0; padding-left: 1.25rem; }
.irpt-diag li { font-size: .875rem; line-height: 1.55; color: var(--tu-ink-soft); margin-bottom: .375rem; }
.irpt-diag li:last-child { margin-bottom: 0; }

/* ================= MAT report brief (2026-08-18) — §03/§05/§06/§07 =================
 * ทุกคลาสด้านล่างใช้ตัวแปร --tu-* ที่ประกาศไว้แล้วใน .irpt-report ด้านบนทั้งหมด — ไม่มี
 * สี/ฟอนต์ใหม่ */

/* ---- ปุ่มสลับภาษา ไทย/EN (ฟีดแบ็กเจ้าของ 2026-08-18) ----
 * เดิมโชว์ไทย+อังกฤษซ้อนกันทุกบรรทัด อ่านรก — เปลี่ยนเป็นเลือกภาษาเดียวแล้วสลับได้
 * โครงเดียวกับ .langtoggle ของหน้าสอบ แต่ประกาศเองที่นี่เพราะ base.css โหลดเฉพาะ
 * ฝั่งผู้เรียน (admin ใช้ base-legacy.css) — รายงานต้องหน้าตาเหมือนกันทั้งสองที่ */
.irpt-langtoggle { display: inline-flex; gap: 2px; padding: 2px; margin-bottom: .75rem; border: 1px solid var(--tu-line); border-radius: 999px; background: var(--tu-card); }
.irpt-langtoggle__btn {
  border: 0; background: none; cursor: pointer;
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, Arial, sans-serif;
  font-size: .75rem; font-weight: 600; color: var(--tu-muted);
  padding: .25rem .75rem; border-radius: 999px; line-height: 1.6;
}
.irpt-langtoggle__btn:hover { color: var(--tu-ink); }
.irpt-langtoggle__btn.is-active { background: var(--tu-red); color: #fff; }
.irpt-langtoggle__btn:focus-visible { outline: 2px solid var(--tu-red); outline-offset: 1px; }

/* ---- ส่วนต่างในตารางรายด้าน (ภาคผนวก) ---- */

.irpt-delta--pos  { color: var(--tu-good); font-weight: 700; }
.irpt-delta--neg  { color: var(--tu-bad); font-weight: 700; }
.irpt-delta--zero { color: var(--tu-muted); }
.irpt-total-row td { border-top: 2px solid var(--tu-ink); font-weight: 700; background: var(--tu-stripe); }

/* ระบบสีเดียวกันทุกที่ (ฟีดแบ็กเจ้าของ 2026-08-18): ดีขึ้น=เขียว · เท่าเดิม=เทา ·
 * แย่ลง=แดง — เดิม Retained (เรื่องดี) เป็นแดงและ Slipped (เรื่องแย่) เป็นส้ม
 * ทำให้สีสื่อสารสวนทางกับความหมาย · ✓✓ กับ ✗✗ เป็นเทาทั้งคู่เพราะ "ไม่เปลี่ยน"
 * เหมือนกัน แยกความหมายด้วยสัญลักษณ์ในช่องและน้ำหนักตัวอักษรแทน */

/* รอทำรอบ Post — เส้นประ พื้นโปร่ง ให้ต่างจากเทาทึบของ "เท่าเดิม" ชัดเจน */

/* สีเดียวกับช่องในกริดด้านบน — ดีขึ้น=เขียว · เท่าเดิม=เทา · แย่ลง=แดง */

/* ---- Item-level detail table (§06) ---- */
/* table-layout:fixed จำเป็น — max-width บน <td> ถูก CSS เพิกเฉยตอน table-layout:auto
 * (สเปกไม่บังคับใช้กับ table cell) ข้อความคำถามยาวๆ จึงดันตารางล้นไปทับคอลัมน์
 * Pre/Post/Transition (เจ้าของเจอจริงบน production 2026-08-18) — fixed + กำหนดความ
 * กว้างคอลัมน์ตัวเลขไว้ ทำให้คอลัมน์คำถามได้พื้นที่ที่เหลือแล้วตัดบรรทัดเองถูกต้อง */

/* overflow-wrap: ตัดคำที่ยาวผิดปกติ (เช่น token ยาวๆ ที่ไม่มีช่องว่างเลย) กันดัน
 * คอลัมน์ล้นซ้ำอีกแม้จะ fixed layout แล้ว */

/* ป้ายในตารางรายข้อ — สีเดียวกับแถบในบทที่ 2 (เขียว = หลังเรียนถูก, ส้ม = หลังเรียนผิด) */

.irpt-choice__l { font-family: var(--font-mono); font-size: .71875rem; color: var(--tu-muted); width: 14px; flex: none; }
.irpt-choice--key { border-color: var(--tu-good); background: var(--tu-good-bg); }

/* ---- Insights (§07, rule-based cards) ---- */

@media (max-width: 680px) {

  /* จอแคบ: ให้ตารางรายข้อกว้างขั้นต่ำแล้วเลื่อนแนวนอนใน .irpt-tablewrap แทนการบีบ
     คอลัมน์คำถามจนอ่านไม่ออก */

}

/* container สำหรับ print-all — อยู่นอกจอ (ไม่ใช่ display:none) ตอนดูปกติ เพราะ
   mountCharts() ต้อง insert HTML แล้ววาด Chart.js ลง canvas "ก่อน" window.print()
   เสมอ (ดู printReport ใน quiz.js / printAllReports ใน admin.js) — ถ้าใช้
   display:none ตอนนั้น container จะกว้าง/สูง 0 ทำให้ Chart.js วาดกราฟลง canvas
   ขนาด 0 ไปเลย พอถึงตอนพิมพ์จริงเลยไม่มีกราฟติดกระดาษ ต้องมีขนาดจริงไว้ก่อน
   วาด แค่เอาออกนอกจอด้วย position แทน */
.print-root { position: fixed; left: -10000px; top: 0; width: 880px; }

/* ⚠️ กฎ .print-root ฐาน (นอกจอ) ต้องอยู่ "ก่อน" @media print เสมอ — สองกฎนี้
   specificity เท่ากัน ตัวที่มาทีหลังชนะ ถ้าวางไว้ทีหลัง @media print จะทับ
   override ของมัน ทำให้ตอนพิมพ์ print-root ยังลอยอยู่ที่ left:-10000px แล้วได้
   กระดาษขาวเปล่า (บั๊กที่เจ้าของแจ้ง 2026-09-01 — Print/Save as PDF หน้าผลลัพธ์) */
/* ================= พิมพ์ / PDF (1 หน้าพอดี) ================= */

@page {
  size: A4 portrait;
  margin: 6mm 8mm;
}

@media print {
  /* ซ่อน chrome ของทั้งสองระบบ — เหลือแต่ตัวเอกสาร */
  body.printing-report > *:not(.print-root) { display: none !important; }
  .print-root {
    position: static !important;
    left: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .irpt-report {
    border: 0 !important;
    border-radius: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
    background-image: none !important;
    page-break-after: always;
    break-after: page;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
  }
  .irpt-report:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
  }

  .irpt-topbar {
    margin-bottom: 0.2rem !important;
    padding-bottom: 0.2rem !important;
    gap: 0.5rem !important;
  }
  .irpt-logo {
    height: 28px !important;
  }
  .irpt-topbar__t1 {
    font-size: 0.95rem !important;
  }
  .irpt-topbar__t2 {
    font-size: 0.75rem !important;
  }

  .irpt-mast__name { margin: .3rem 0 0 !important; font-size: 1.1rem !important; line-height: 1.3 !important; }
  .irpt-mast__meta { font-size: .7rem !important; }
  .irpt-ch { margin-top: .6rem !important; }
  .irpt-chhead { margin-bottom: .3rem !important; padding-top: .3rem !important; }
  .irpt-chhead__title { font-size: .95rem !important; }
  .irpt-headline { margin-bottom: .4rem !important; font-size: .9rem !important; line-height: 1.4 !important; }
  .irpt-fig__num { font-size: 1.9rem !important; }
  .irpt-fig--delta .irpt-fig__num { font-size: 1.3rem !important; }
  .irpt-rankline { margin-top: .4rem !important; padding: .25rem 0 0 !important; font-size: .75rem !important; }
  .irpt-journey { break-inside: avoid !important; }
  .irpt-track { margin-top: 1.7rem !important; }
  .irpt-summary { margin-top: .5rem !important; break-inside: avoid !important; }
  .irpt-q { padding: .3rem 0 .4rem !important; break-inside: avoid !important; }
  .irpt-q__meta { font-size: .65rem !important; margin-bottom: .1rem !important; }
  .irpt-q__stem { font-size: .76rem !important; line-height: 1.4 !important; margin-bottom: .2rem !important; }
  .irpt-q--compact { padding: .15rem 0 !important; }
  .irpt-q--compact .irpt-q__stem { font-size: .72rem !important; }
  .irpt-choice { font-size: .7rem !important; line-height: 1.35 !important; padding: .05rem .3rem !important; }
  .irpt-pick { font-size: .6rem !important; }
  .irpt-profile__name { font-size: 1.15rem !important; margin-bottom: .2rem !important; }
  .irpt-profile__desc, .irpt-profile__cols dd, .irpt-topic__desc { font-size: .72rem !important; line-height: 1.4 !important; }
  .irpt-profile__cols { margin-top: .4rem !important; gap: .3rem 1rem !important; }
  .irpt-profile__cols dt { font-size: .74rem !important; margin-bottom: .1rem !important; }
  .irpt-profile__basis { margin-top: .3rem !important; font-size: .68rem !important; }
  .irpt-sub { margin: .7rem 0 .2rem !important; font-size: .8rem !important; }
  .irpt-topic { padding: .3rem 0 .3rem 1.4rem !important; break-inside: avoid !important; }
  .irpt-topic::before { top: .25rem !important; font-size: .8rem !important; }
  .irpt-topic__title { font-size: .76rem !important; }
  .irpt-topic__score, .irpt-topic__ref { font-size: .68rem !important; }
  .irpt-ch-lead { margin-bottom: .4rem !important; font-size: .8rem !important; line-height: 1.4 !important; }
  .irpt-tbar { height: 9px !important; }
  .irpt-tbar__key { margin-top: .3rem !important; font-size: .7rem !important; }
  .irpt-db__legend { margin: .6rem 0 .2rem !important; font-size: .68rem !important; }
  .irpt-db { padding: .15rem 0 !important; gap: .6rem !important; }
  .irpt-db__name { font-size: .72rem !important; }
  .irpt-db__delta { font-size: .75rem !important; }
  .irpt-dbs { break-inside: avoid !important; }
  .irpt-sumrow { padding: .2rem 0 !important; }
  .irpt-sumrow dt { font-size: .7rem !important; }
  .irpt-sumrow strong { font-size: .8rem !important; }
  .irpt-sumrow dd span { font-size: .72rem !important; }
  .irpt-statgrid { gap: .3rem .75rem !important; }
  .irpt-statgrid dt { font-size: .65rem !important; }
  .irpt-statgrid dd { font-size: .8rem !important; }

  .irpt-trendwrap {
    height: 130px !important;
    max-height: 130px !important;
  }
  .irpt-card {
    padding: 0.35rem 0.5rem !important;
    margin-bottom: 0.25rem !important;
    break-inside: avoid !important;
  }
  .irpt-sec {
    font-size: 0.85rem !important;
    margin-bottom: 0.15rem !important;
  }
  .irpt-seclead {
    font-size: 0.72rem !important;
    margin-bottom: 0.2rem !important;
  }
  .irpt-table th, .irpt-table td {
    padding: 0.2rem 0.35rem !important;
    font-size: 0.72rem !important;
  }
  .irpt-statgrid dt {
    font-size: 0.7rem !important;
  }
  .irpt-statgrid dd {
    font-size: 0.85rem !important;
  }

  .irpt-foot {
    padding-top: 0.15rem !important;
    margin-top: 0.15rem !important;
  }
  .irpt-copyright {
    font-size: 0.65rem !important;
  }

  .irpt-card,
.irpt-table td { break-inside: avoid !important; }

  .irpt-report * { print-color-adjust: exact !important; -webkit-print-color-adjust: exact !important; }

  /* กล่อง diagnostics เป็นของแอดมินเท่านั้น — ห้ามหลุด */
  .irpt-diag { display: none !important; }

  /* ปุ่มสลับภาษาเป็น UI ไม่ใช่เนื้อหา — ห้ามติดไปบนกระดาษ/PDF */
  .irpt-langtoggle { display: none !important; }
}

/* จอคอมพิวเตอร์ — .wrap--wide (quiz.js showResults) เปิดพื้นที่ให้แล้ว แต่การ์ด
   รายงานเองก็ต้องขยายตามด้วย ไม่งั้นเหลือแค่ระยะขอบว่างล้อมการ์ดเดิม 880px ดูเล็ก
   ลอยอยู่กลางจอกว้างๆ */
@media screen and (min-width: 900px) {
  .irpt-report { max-width: 1040px; font-size: 16px; padding: 2.25rem 2.75rem 2.75rem; }
  .irpt-fig__num { font-size: 4rem; }

  .irpt-trendwrap { height: 280px; }
}

/* REPORT-SPEC.md DoD: "มือถือ: ทุก chart อ่านได้บนจอแคบ" — ผู้เรียนใช้มือถือเป็นหลัก */
@media screen and (max-width: 680px) {
  .irpt-report { padding: .25rem 0 1.5rem; border: 0; border-radius: 0; background: transparent; }
  .irpt-mast__name { font-size: 1.5rem; }
  .irpt-headline { font-size: 1.25rem; }
  .irpt-figs { gap: .75rem 1rem; }
  .irpt-fig__num { font-size: 2.5rem; }
  .irpt-fig--delta { flex-basis: 100%; padding-left: 0; padding-top: .75rem; border-left: 0; border-top: 1px solid var(--tu-line); }
  .irpt-fig--delta .irpt-fig__num { font-size: 1.75rem; }
  .irpt-figs__arrow { width: 22px; height: 22px; }

  .irpt-trendwrap { height: 200px; }
}

/* The report is also rendered inside the admin preview modal. Use the report's
   actual available width so bounded containers reflow even when the viewport
   itself is wide. */
@container (max-width: 760px) {
  .irpt-sumrow { grid-template-columns: 1fr; gap: 0; }
  .irpt-profile__cols { grid-template-columns: 1fr; }
  .irpt-profile__name { font-size: 1.5rem; }
  .irpt-profile__desc { font-size: 1rem; }
  .irpt-db { grid-template-columns: minmax(0, 1fr) 3.5rem; gap: .125rem .75rem; }
  .irpt-db__name { grid-column: 1 / -1; }

}

/* A readable summary first; evidence follows on subsequent A4 pages. */
.irpt-evidence-context { overflow-wrap: anywhere; }
.irpt-db__coverage { display: block; font-weight: 400; font-size: .75rem; color: var(--tu-muted); }
@media print {
  .irpt-report { break-inside: auto !important; page-break-inside: auto !important; font-size: 12px !important; line-height: 1.45 !important; }
  .irpt-ch--overview { break-inside: avoid; }
  .irpt-ch--evidence { break-before: page; }
  .irpt-appx { break-before: page; }
  .irpt-table tr, .irpt-q { break-inside: avoid; }
  .irpt-table thead { display: table-header-group; }
  .irpt-chhead, .irpt-appx__h { break-after: avoid; }
  .irpt-db { break-inside: avoid; }
  .irpt-dbs { break-inside: auto !important; }
  .irpt-evidence-context { font-size: 11px; line-height: 1.45; }
}
