/* link.css — หน้าเชื่อมโยงมาตรฐานอาชีพ (ใช้ร่วมกับ style.css ของหน้าค้นหา) */
.container-wide { max-width: 1400px; }
.link-header { padding: 32px 0 56px; }
.link-header h1 { font-size: 2rem; }
.link-back { position: absolute; left: 20px; top: 16px; color: #fff; opacity: .85; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; font-size: .9rem; }
.link-back:hover { opacity: 1; text-decoration: underline; }
.link-header .container { position: relative; }
.link-step { position: relative; z-index: 1; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 20px 24px 24px; margin: 0 0 20px; }
.link-step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.link-step-head h2 { font-size: 1.15rem; font-weight: 700; color: var(--text); margin: 0; flex: 1 1 auto; }
.link-step-no { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.link-step-hint { font-size: .85rem; color: var(--text-secondary); }
.link-btn-ghost { background: var(--primary-50); }
.filters .filter-group input[type=text] { padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font: inherit; background: #fff; }
.search-wrapper.compact { margin: 10px 0 8px; }

/* รายการวิชา */
.link-course-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.link-course { display: grid; grid-template-columns: 110px 1fr auto auto auto; gap: 12px; align-items: center; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: #fff; cursor: pointer; transition: var(--transition); }
.link-course:hover { border-color: var(--primary-light); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.link-course .c-code { font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.link-course .c-name { font-weight: 500; }
.link-course .c-name small { display: block; color: var(--text-secondary); font-weight: 400; font-size: .8rem; }
.link-course .c-credit { color: var(--text-secondary); font-size: .85rem; white-space: nowrap; }
.badge-ref { font-size: .75rem; padding: 3px 9px; border-radius: 999px; white-space: nowrap; font-weight: 600; }
.badge-ref.tpqi { background: #dcfce7; color: #166534; }
.badge-ref.other { background: var(--amber-100); color: var(--amber-dark); }
.badge-ref.none { background: #f1f5f9; color: #475569; }
.link-course .c-pick { color: var(--primary); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }

/* วิชาที่เลือก + บล็อกอ้างอิง */
.link-course-banner { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: baseline; padding: 12px 16px; background: var(--primary-50); border-radius: var(--radius-sm); margin-bottom: 14px; }
.link-course-banner .b-code { font-weight: 800; color: var(--primary); font-size: 1.1rem; }
.link-course-banner .b-name { font-weight: 600; font-size: 1.05rem; }
.link-course-banner .b-meta { color: var(--text-secondary); font-size: .88rem; }
.link-ref-blocks { display: grid; gap: 12px; grid-template-columns: 1fr; }
.link-ref { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: #fff; cursor: pointer; transition: var(--transition); }
.link-ref:hover { border-color: var(--primary-light); }
.link-ref.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.link-ref.disabled { opacity: .6; cursor: default; }
.link-ref .r-type { font-size: .75rem; font-weight: 700; letter-spacing: .02em; }
.link-ref .r-occ { font-weight: 700; font-size: 1.12rem; margin: 2px 0; }
.link-ref .r-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.link-ref .r-use { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.link-ref .r-lv { color: var(--text-secondary); font-size: .88rem; }
.link-ref .r-uocs { margin: 10px 0 0; padding-left: 0; list-style: none; font-size: .9rem; color: var(--text); display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 2px 18px; }
.link-ref .r-uocs li { display: flex; gap: 6px; align-items: baseline; padding: 2px 0; }
.link-ref .r-uocs code { font-size: .8rem; background: #f1f5f9; padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.link-ref .r-uocs .miss { color: #b91c1c; }
.link-status { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; padding: 2px 8px; border-radius: 999px; margin-top: 6px; }
.link-status.ok { background: #dcfce7; color: #166534; }
.link-status.warn { background: var(--amber-100); color: var(--amber-dark); }
.link-status.bad { background: #fee2e2; color: #991b1b; }
.link-status a { color: inherit; }
.link-tpqi-search { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 10px; }
.link-tpqi-search summary { cursor: pointer; color: var(--primary); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.link-tpqi-results { display: flex; flex-direction: column; gap: 6px; }
.link-tpqi-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.link-tpqi-item:hover { border-color: var(--primary-light); background: var(--primary-50); }
.link-tpqi-item small { color: var(--text-secondary); display: block; }
.link-standard-panel { margin-top: 14px; padding: 14px 16px; border-radius: var(--radius-sm); background: #f8fafc; border: 1px solid var(--border); }
.link-standard-title { font-weight: 800; font-size: 1.05rem; }
.link-standard-meta { color: var(--text-secondary); font-size: .88rem; margin-top: 2px; }
.link-level-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.link-level-row .lv { padding: 5px 12px; border-radius: 999px; border: 1.5px solid var(--border); background: #fff; cursor: pointer; font: inherit; font-size: .88rem; }
.link-level-row .lv.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.link-uoc-picker { margin-top: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px; }
.link-uoc { display: flex; gap: 8px; align-items: flex-start; padding: 6px 10px; border-radius: 8px; background: #fff; border: 1px solid var(--border); font-size: .88rem; cursor: pointer; }
.link-uoc input { margin-top: 4px; }
.link-uoc code { font-size: .8rem; color: var(--primary-dark); white-space: nowrap; }
.link-uoc.extra { border-style: dashed; }
.link-uoc-note { grid-column: 1 / -1; font-size: .82rem; color: var(--text-secondary); }

/* กระดาษ A4 แนวนอน จำลองแบบฟอร์ม Word */
.link-toggle { font-size: .85rem; display: inline-flex; gap: 6px; align-items: center; color: var(--text-secondary); }
.link-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.link-actions .btn-word, .link-actions .btn-tool { display: inline-flex; align-items: center; gap: 6px; }
.link-file { cursor: pointer; }
.link-autosave { font-size: .8rem; color: var(--text-muted); margin-left: auto; }
.link-sheet-wrap { overflow-x: auto; background: #e2e8f0; padding: 18px; border-radius: var(--radius-sm); }
.link-sheet { width: 1123px; min-height: 794px; margin: 0 auto; background: #fff; box-shadow: var(--shadow-lg); padding: 38px 38px 30px; font-family: 'TH Sarabun New', 'TH SarabunPSK', 'Sarabun', sans-serif; font-size: 15px; line-height: 1.35; color: #000; }
.link-sheet .s-title { text-align: center; font-weight: 700; font-size: 19px; line-height: 1.5; }
.link-sheet table { width: 100%; border-collapse: collapse; table-layout: fixed; margin-top: 14px; }
.link-sheet td { border: 1px solid #000; padding: 2px 6px; vertical-align: top; word-wrap: break-word; }
.link-sheet .h-left p, .link-sheet .h-right p { text-align: center; margin: 0; }
.link-sheet .h-right .h-lv { font-size: 16.5px; }
.link-sheet .lbl { font-weight: 700; }
.link-sheet .outcome { text-indent: 2.4em; }
.link-sheet .uoc-code { text-align: center; font-size: 16.5px; font-family: 'TH SarabunPSK', 'TH Sarabun New', 'Sarabun', sans-serif; }
.link-sheet .uoc-name { text-align: center; font-size: 12.5px; padding: 2px 1px; vertical-align: top; }
.link-sheet .head-c { text-align: center; font-weight: 700; }
.link-sheet .desc { text-indent: 1.9em; }
.link-sheet .comp { padding-left: 1.1em; text-indent: -0.75em; }
.link-sheet .chk { text-align: center; cursor: pointer; user-select: none; font-size: 22px; font-weight: 700; line-height: 1; padding-top: 1px; }
.link-sheet .chk:hover { background: #eff6ff; }
.link-sheet .chk.on::after { content: '✓'; }
.link-sheet .s-summary { text-align: center; font-size: 16.5px; margin-top: 12px; }
.link-sheet .s-summary b { font-weight: 700; }
.link-sheet [contenteditable] { outline: none; border-bottom: 1px dashed #94a3b8; min-width: 40px; display: inline-block; }
.link-sheet [contenteditable]:empty::before { content: attr(data-ph); color: #94a3b8; }
.link-sheet [contenteditable]:focus { background: #fef9c3; }
.link-summary { margin-top: 10px; font-size: .95rem; color: var(--text); display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.link-summary .pass { color: #166534; font-weight: 800; }
.link-summary .fail { color: #b91c1c; font-weight: 800; }
.link-summary small { color: var(--text-secondary); }
.link-empty { text-align: center; color: var(--text-secondary); padding: 20px; }
@media print {
  .mb-heads, .mb-bar, .mb-board, .mb-foot, .mb-paper > summary { display: none !important; }
  .mb-paper { border: 0; }
  @page { size: A4 landscape; margin: 12mm; }
  /* พิมพ์เฉพาะแบบฟอร์มกระดาษของขั้นที่ 3 (เดิมเขียน .link-step:not(#stepSheet) ซึ่งซ่อนขั้นที่ 3 ไปด้วย เพราะไม่มี id นี้จริง) */
  body.link-page > *:not(main), #page1, #page2, #page3, .link-step-head, .link-nav, .std-panel, .std-panel-bar,
  .link-actions, .link-summary, .bg-decoration, footer { display: none !important; }
  .link-step { box-shadow: none; padding: 0; margin: 0; }
  .link-sheet-wrap { background: none; padding: 0; overflow: visible; }
  .link-sheet { box-shadow: none; width: 100%; min-height: 0; padding: 0; }
  .link-sheet .chk { cursor: default; }
  .link-sheet [contenteditable] { border-bottom: none; }
}
@media (max-width: 720px) { .link-course { grid-template-columns: 1fr; gap: 4px; } .link-back { position: static; display: inline-flex; margin-bottom: 8px; } }

/* ===== วิซาร์ด ===== */
.link-stepper { position: relative; z-index: 1; display: flex; align-items: center; gap: 6px; margin: -34px 0 18px; padding: 8px 12px; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow-md); width: fit-content; max-width: 100%; }
.link-stepper .stp { display: inline-flex; align-items: center; gap: 8px; border: none; background: transparent; padding: 8px 14px; border-radius: 999px; font: inherit; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.link-stepper .stp .n { width: 26px; height: 26px; border-radius: 50%; background: var(--border); color: var(--text-secondary); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem; }
.link-stepper .stp.done .n { background: #dcfce7; color: #166534; }
.link-stepper .stp.active { background: var(--primary-50); color: var(--primary-dark); }
.link-stepper .stp.active .n { background: var(--primary); color: #fff; }
.link-stepper .stp:disabled { cursor: default; opacity: .55; }
.link-stepper .stp-sep { color: var(--text-muted); }
.link-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.link-nav .btn-word, .link-nav .btn-tool { display: inline-flex; align-items: center; gap: 6px; }
.link-nav .btn-word:disabled { opacity: .5; cursor: not-allowed; }
.link-hint { color: var(--text-secondary); font-size: .9rem; margin: -4px 0 10px; }
.link-filters .filter-group select { min-width: 160px; }
.link-filters .filter-dept { flex: 1 1 320px; }
.link-filters .filter-dept select { width: 100%; }
.link-adjust { margin-bottom: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #f8fafc; padding: 8px 14px; }
.link-adjust summary { cursor: pointer; font-weight: 600; color: var(--primary-dark); display: flex; align-items: center; gap: 6px; }
.link-adjust[open] { padding-bottom: 14px; }
@media (max-width: 720px) { .link-stepper .stp .t { display: none; } .link-stepper { margin-top: -26px; } }

/* ===== แผงรายละเอียดมาตรฐาน (พอร์ตจาก dles-landing standards.css .std-* — modal ของ /standards/tpqi แสดงแบบฝังในหน้า) ===== */
.std-panel { background: #fff; border-radius: 18px; padding: 24px 26px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1); border: 1px solid rgba(0,0,0,.06); margin-bottom: 14px; }
.std-panel-bar { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; font: inherit; font-weight: 600; color: #1e3a8a; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 12px; padding: 10px 14px; cursor: pointer; margin-bottom: 14px; }
.std-panel-bar small { font-weight: 400; color: #64748b; margin-left: auto; }
.std-modal-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 1px solid #eef0f3; padding-bottom: 14px; margin-bottom: 8px; }
.std-modal-head h2 { margin: 0; font-size: 1.25rem; color: #111827; line-height: 1.4; }
.std-modal-close { background: #f1f5f9; border: none; border-radius: 10px; width: 38px; height: 38px; cursor: pointer; font-size: 20px; color: #475569; flex: none; }
.std-modal-close:hover { background: #e2e8f0; }
.std-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.std-badge { font-size: 0.78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 4px; }
.b-saakhaa { background: #e0ecff; color: #1d4ed8; }
.b-level { background: #fef3c7; color: #92710a; }
.b-kind-occ { background: #e2e8f0; color: #334155; }
.b-kind-support { background: #ede9fe; color: #6d28d9; }
.b-warn { background: #fee2e2; color: #991b1b; }
.std-occ { font-size: 0.85rem; color: #475569; line-height: 1.5; display: flex; align-items: baseline; gap: 4px; }
.std-btn { text-decoration: none; text-align: center; font-weight: 600; font-size: 0.9rem; border: none; cursor: pointer; padding: 10px 16px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: filter 0.15s; font-family: inherit; }
.std-btn .material-symbols-rounded { font-size: 18px; }
.std-btn:hover { filter: brightness(0.95); }
.std-btn.btn-word { background: #2563eb; color: #fff; }
.std-btn.btn-word:disabled { background: #f1f5f9; color: #94a3b8; pointer-events: none; }
.std-btn.btn-src { background: #fee2e2; color: #b91c1c; }
.std-btn.btn-src:hover { background: #fecaca; filter: none; }
.std-source-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.std-level-pills { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.std-level-pills-label { font-weight: 600; color: #334155; font-size: 0.9rem; }
.std-level-pill { border: 1.5px solid #cbd5e1; background: #fff; color: #334155; border-radius: 999px; padding: 6px 14px; font-size: 0.9rem; cursor: pointer; font-family: inherit; transition: all 0.12s; }
.std-level-pill small { color: #94a3b8; font-weight: 400; }
.std-level-pill:hover { border-color: #60a5fa; }
.std-level-pill.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.std-level-pill.active small { color: #dbeafe; }
.std-export-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 12px; padding: 10px 14px; margin-top: 14px; }
.std-export-bar .sel-all { display: flex; align-items: center; gap: 7px; cursor: pointer; color: #1e3a8a; }
.std-export-bar .sel-count { color: #2563eb; font-size: 0.85rem; font-weight: 600; }
.std-export-bar .btn-word { margin-left: auto; }
.std-sel-hint { font-size: 0.8rem; color: #64748b; margin: 8px 2px 0; line-height: 1.5; }
.std-uoc { border: 1px solid #e5e7eb; border-radius: 12px; margin-top: 12px; overflow: hidden; }
.std-uoc-head { background: #f8fafc; padding: 11px 14px; font-weight: 700; color: #1e3a8a; display: flex; gap: 8px; align-items: center; cursor: pointer; }
.std-uoc-code { font-family: ui-monospace, monospace; background: #dbeafe; color: #1d4ed8; padding: 1px 8px; border-radius: 6px; font-size: 0.82rem; flex: none; }
.std-uoc-toggle { font-size: 20px; color: #64748b; transition: transform 0.15s; flex: none; }
.std-uoc-toggle.open { transform: rotate(90deg); }
.std-uoc-name { flex: 1; font-weight: 400; color: #334155; }
.std-uoc-cnt { font-size: 0.76rem; color: #64748b; background: #eef2ff; border-radius: 999px; padding: 2px 9px; flex: none; }
.std-eoc { padding: 10px 14px; border-top: 1px solid #eef0f3; }
.std-eoc-title { font-weight: 600; color: #334155; display: flex; gap: 8px; align-items: baseline; cursor: pointer; }
.std-eoc ul { margin: 6px 0 0; padding-left: 20px; color: #475569; font-size: 0.9rem; line-height: 1.55; }
.std-eoc .lbl { font-size: 0.78rem; color: #64748b; font-weight: 600; margin-top: 6px; }
.std-sel-row input[type="checkbox"] { margin-top: 3px; flex: none; width: 16px; height: 16px; cursor: pointer; accent-color: #2563eb; }
.std-course-refs { margin-top: 18px; }
.std-course-refs h4 { margin: 0 0 8px; font-size: 0.95rem; color: #1e3a8a; border-left: 3px solid #2563eb; padding-left: 8px; }
.std-course-refs h4 small { font-weight: 400; color: #64748b; }
.std-course-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.std-course-chips button { border: 1px solid #e2e8f0; background: #f8fafc; border-radius: 999px; padding: 5px 12px; font-size: 0.8rem; color: #334155; cursor: pointer; font-family: inherit; transition: background .15s, border-color .15s; }
.std-course-chips button:hover { background: #dbeafe; border-color: #93c5fd; }
.std-course-chips button b { color: #1d4ed8; }
.std-loading { text-align: center; padding: 40px; color: var(--text-secondary); }
.std-spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: std-spin 0.8s linear infinite; margin: 0 auto 12px; }
@keyframes std-spin { to { transform: rotate(360deg); } }
/* เพิ่มเฉพาะหน้าเชื่อมโยง: ปุ่มเลือกหน่วยเป็นคอลัมน์ในตาราง (สูงสุด 8) */
.std-uoc-use { flex: none; font: inherit; font-size: 0.78rem; font-weight: 700; border-radius: 999px; padding: 4px 11px; cursor: pointer; border: 1.5px solid #cbd5e1; background: #fff; color: #475569; }
.std-uoc-use.on { background: #dcfce7; border-color: #86efac; color: #166534; }
.std-uoc-use:hover { border-color: #60a5fa; }
.std-note { font-size: .85rem; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 8px 12px; margin-top: 12px; }
@media print {
  .mb-heads, .mb-bar, .mb-board, .mb-foot, .mb-paper > summary { display: none !important; }
  .mb-paper { border: 0; } .std-panel, .std-panel-bar { display: none !important; } }

/* ===== ตารางหลายคอลัมน์ (ไม่จำกัดจำนวน UoC): ย่อตัวอักษรฝั่ง UoC ตามจำนวนคอลัมน์ ===== */
.link-sheet table.cols-9 .uoc-name { font-size: 11px; }
.link-sheet table.cols-9 .uoc-code { font-size: 14px; }
.link-sheet table.cols-13 .uoc-name { font-size: 9.5px; line-height: 1.3; }
.link-sheet table.cols-13 .uoc-code { font-size: 12.5px; }
.link-sheet table.cols-13 .chk { font-size: 18px; }
.link-sheet table.cols-17 .uoc-name { font-size: 8.5px; line-height: 1.25; padding: 2px 0; }
.link-sheet table.cols-17 .uoc-code { font-size: 11px; }
.link-sheet table.cols-17 .chk { font-size: 16px; }
.link-sheet table.cols-25 .uoc-name { font-size: 7.5px; line-height: 1.2; padding: 1px 0; }
.link-sheet table.cols-25 .uoc-code { font-size: 9.5px; }
.link-sheet table.cols-25 .chk { font-size: 14px; }
.link-sheet .uoc-hover { cursor: help; }
.link-sheet .uoc-hover:hover { background: #eff6ff; }
/* popup รายละเอียด UoC (EoC + PC) */
.uoc-pop { position: absolute; z-index: 80; background: #fff; border: 1px solid #cbd5e1; border-radius: 12px; box-shadow: 0 14px 40px rgba(15, 23, 42, 0.22); padding: 12px 14px; font-family: 'Noto Sans Thai', sans-serif; font-size: .85rem; line-height: 1.5; color: #1e293b; max-height: 60vh; overflow: auto; }
.uoc-pop .pop-head { display: flex; align-items: center; gap: 8px; font-size: .92rem; border-bottom: 1px solid #eef0f3; padding-bottom: 8px; margin-bottom: 6px; }
.uoc-pop .pop-head b { flex: 1; }
.uoc-pop .pop-close { border: none; background: #f1f5f9; border-radius: 8px; width: 28px; height: 28px; cursor: pointer; font-size: 16px; color: #475569; }
.uoc-pop .pop-eoc { padding: 6px 0; border-top: 1px dashed #eef0f3; }
.uoc-pop .pop-eoc:first-of-type { border-top: none; }
.uoc-pop .pop-eoc-title { font-weight: 600; color: #1e3a8a; display: flex; gap: 6px; align-items: baseline; }
.uoc-pop .lbl { font-size: .75rem; color: #64748b; font-weight: 600; margin-top: 4px; }
.uoc-pop ul { margin: 2px 0 0; padding-left: 18px; color: #475569; font-size: .82rem; }
.uoc-pop .pop-empty { color: #92400e; background: #fffbeb; border-radius: 8px; padding: 6px 10px; }
@media print {
  .mb-heads, .mb-bar, .mb-board, .mb-foot, .mb-paper > summary { display: none !important; }
  .mb-paper { border: 0; } .uoc-pop { display: none !important; } }

/* ===== กระดานจับคู่ (หน้าจอใช้งาน) ===== */
.mb-heads { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: stretch; margin: 4px 0 14px; }
.mb-card { position: relative; border-radius: 14px; padding: 14px 18px 14px; color: #fff; box-shadow: var(--shadow-md); overflow: hidden; }
.mb-card::after { content: ''; position: absolute; inset: 0; background: radial-gradient(120% 90% at 100% 0%, rgba(255,255,255,.22), transparent 60%); pointer-events: none; }
.mb-c-course { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.mb-c-std { background: linear-gradient(135deg, #0f766e, #0d9488); }
.mb-tag { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .02em; background: rgba(255,255,255,.22); padding: 3px 10px; border-radius: 999px; margin-bottom: 8px; }
.mb-code { font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; opacity: .95; }
.mb-title { font-size: 1.18rem; font-weight: 800; line-height: 1.35; }
.mb-meta { font-size: .85rem; opacity: .92; margin-top: 3px; }
.mb-units { font-weight: 700; opacity: 1; }
.mb-join { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--primary); font-weight: 700; }
.mb-join .material-symbols-rounded { font-size: 30px; }
.mb-join small { font-size: .75rem; color: var(--text-secondary); }

.mb-bar { position: sticky; top: 8px; z-index: 6; display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between;
  background: #fff; border: 1.5px solid var(--border); border-radius: 14px; padding: 10px 16px; box-shadow: var(--shadow-md); margin-bottom: 14px; }
.mb-progress { display: flex; align-items: center; gap: 14px; }
.mb-ring { position: relative; --p: 0; width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--ring, #22c55e) calc(var(--p) * 1%), #e5e7eb 0); }
.mb-ring.no { --ring: #f59e0b; }
.mb-ring::before { content: ''; position: absolute; width: 46px; height: 46px; border-radius: 50%; background: #fff; }
.mb-ring span { position: relative; font-weight: 800; font-size: 1.02rem; color: var(--text); }
.mb-ring small { font-size: .68rem; font-weight: 700; }
.mb-prog-t { display: flex; flex-direction: column; gap: 2px; }
.mb-prog-t b { font-size: 1.02rem; }
.mb-prog-t small { color: var(--text-secondary); font-size: .8rem; }
.mb-pill { align-self: flex-start; font-size: .78rem; font-weight: 800; padding: 3px 12px; border-radius: 999px; }
.mb-pill.ok { background: #dcfce7; color: #166534; }
.mb-pill.no { background: var(--amber-100, #fef3c7); color: #92400e; }
.mb-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mb-actions .btn-word, .mb-actions .btn-tool { display: inline-flex; align-items: center; gap: 6px; }
.mb-dl { font-size: 1rem; padding: 11px 20px; box-shadow: 0 6px 16px rgba(37,99,235,.28); }

.mb-board { overflow-x: auto; padding-bottom: 4px; }
.mb-grid { min-width: calc(300px + var(--n) * 96px + 96px); display: flex; flex-direction: column; gap: 6px; }
.mb-row { display: grid; grid-template-columns: minmax(260px, 1.6fr) repeat(var(--n), minmax(88px, 1fr)) 96px; gap: 6px; align-items: stretch; }
.mb-head-row { position: relative; margin-bottom: 2px; }
.mb-comp { display: flex; gap: 10px; align-items: flex-start; background: #fff; border: 1.5px solid var(--border); border-left: 5px solid #cbd5e1; border-radius: 10px; padding: 10px 12px; font-size: .93rem; line-height: 1.45; }
.mb-no { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--primary-50); color: var(--primary); font-weight: 800; font-size: .82rem; display: grid; place-items: center; }
.mb-row.ok .mb-comp { border-left-color: #22c55e; background: #f6fefa; }
.mb-h { background: var(--primary-50); border-color: transparent; font-weight: 800; color: var(--primary-dark, #1e40af); align-items: center; }
.mb-stat { display: grid; place-items: center; text-align: center; font-size: .78rem; font-weight: 700; color: #94a3b8; background: #f8fafc; border: 1.5px dashed #e2e8f0; border-radius: 10px; padding: 4px; }
.mb-row.ok .mb-stat { color: #166534; background: #dcfce7; border: 1.5px solid #bbf7d0; }
.mb-stat.mb-h { border-style: solid; }

.mb-uoc { display: flex; flex-direction: column; gap: 2px; align-items: center; text-align: center; justify-content: center; cursor: help;
  border-radius: 10px; padding: 8px 6px; color: #fff; box-shadow: var(--shadow-sm); transition: var(--transition); outline: none; }
.mb-uoc:hover, .mb-uoc:focus { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.mb-uoc.t0 { background: linear-gradient(135deg, #4f46e5, #6366f1); }
.mb-uoc.t1 { background: linear-gradient(135deg, #0891b2, #06b6d4); }
.mb-uoc.t2 { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.mb-uoc.t3 { background: linear-gradient(135deg, #0d9488, #14b8a6); }
.mb-uoc.t4 { background: linear-gradient(135deg, #db2777, #ec4899); }
.mb-uoc.t5 { background: linear-gradient(135deg, #ea580c, #f97316); }
.mb-uoc-code { font-weight: 800; font-size: .86rem; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.mb-uoc-name { font-size: .72rem; line-height: 1.25; opacity: .95; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.mb-uoc-eoc { font-size: .66rem; background: rgba(255,255,255,.22); padding: 1px 8px; border-radius: 999px; margin-top: 2px; }

.mb-cell { border: 1.5px solid var(--border); background: #fff; border-radius: 10px; cursor: pointer; display: grid; place-items: center; min-height: 46px; transition: var(--transition); padding: 0; }
.mb-cell .material-symbols-rounded { font-size: 26px; color: transparent; transition: var(--transition); }
.mb-cell:hover { border-color: var(--primary-light); background: var(--primary-50); }
.mb-cell:hover .material-symbols-rounded { color: #bfdbfe; }
.mb-cell.on { background: linear-gradient(135deg, #16a34a, #22c55e); border-color: #16a34a; box-shadow: 0 3px 10px rgba(22,163,74,.28); }
.mb-cell.on .material-symbols-rounded { color: #fff; font-variation-settings: 'wght' 700; }
.mb-cell:focus-visible { outline: 3px solid var(--primary-100); }

.mb-empty { padding: 26px; text-align: center; color: var(--text-secondary); background: #f8fafc; border: 1.5px dashed var(--border); border-radius: 12px; }
.mb-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.mb-note { background: #fff; border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.mb-note summary { cursor: pointer; font-weight: 700; color: var(--primary); font-size: .92rem; }
.mb-note p { margin: 8px 0 0; font-size: .9rem; line-height: 1.6; color: var(--text-secondary); text-indent: 1.6em; }
.mb-foot { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 14px; }
.mb-paper { margin-top: 12px; border: 1.5px solid var(--border); border-radius: 12px; background: #fff; }
.mb-paper > summary { cursor: pointer; padding: 12px 16px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.mb-paper > summary small { color: var(--text-secondary); font-weight: 400; }
.mb-paper[open] > summary { border-bottom: 1.5px solid var(--border); }
.mb-paper .link-sheet-wrap { border-radius: 0 0 12px 12px; }
@media (max-width: 900px) {
  .mb-heads { grid-template-columns: 1fr; }
  .mb-join { flex-direction: row; gap: 8px; }
  .mb-notes { grid-template-columns: 1fr; }
}
/* ปุ่มรองในแถบขาว (btn-tool เดิมออกแบบไว้สำหรับพื้นเข้ม) */
.mb-actions .btn-tool { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.mb-actions .btn-tool:hover { background: var(--primary-50); border-color: var(--primary-light); color: var(--primary); }
.mb-foot .link-autosave { color: var(--text-secondary); font-size: .85rem; }
.mb-actions .btn-tool.mb-pdf { border-color: #fecaca; color: #b91c1c; }
.mb-actions .btn-tool.mb-pdf:hover { background: #fef2f2; border-color: #ef4444; color: #b91c1c; }

/* ปุ่ม "ดูบน TPQI" ในแถบสถานะคลังมาตรฐาน (ขั้นที่ 2) */
.link-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.link-status .ls-text { flex: 1 1 240px; }
.btn-tpqi { display: inline-flex; align-items: center; gap: 5px; flex: none; background: var(--primary); color: #fff !important;
  font-weight: 700; font-size: .82rem; line-height: 1; padding: 7px 14px; border-radius: 999px; text-decoration: none !important;
  box-shadow: 0 2px 6px rgba(37,99,235,.28); transition: var(--transition); white-space: nowrap; }
.btn-tpqi:hover { background: var(--primary-dark, #1e40af); box-shadow: 0 4px 10px rgba(37,99,235,.36); transform: translateY(-1px); }
.btn-tpqi .material-symbols-rounded { font-size: 16px; }
.link-back-right { left: auto; right: 20px; }

/* ===== ปุ่มย้อนกลับ: ตัวหนังสือสีน้ำเงินบนพื้นฟ้าอ่อน (เดิมตัวหนังสือขาวมองไม่เห็น) ===== */
.link-btn-ghost { background: var(--primary-50); color: var(--primary); border: 1.5px solid var(--primary-light); box-shadow: none; font-weight: 700; }
.link-btn-ghost:hover { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,.3); }

/* ===== ยืนยันผลการวิเคราะห์ / รายงานความคืบหน้า ===== */
.btn-confirm { display: inline-flex; align-items: center; gap: 6px; height: 46px; padding: 0 18px; border-radius: var(--radius-sm); border: none; font: inherit; font-weight: 800; font-size: .92rem;
  color: #fff; cursor: pointer; background: linear-gradient(135deg, #15803d, #22c55e); box-shadow: 0 3px 10px rgba(22,163,74,.35); transition: var(--transition); white-space: nowrap; }
.btn-confirm:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(22,163,74,.45); }
.btn-confirm:disabled { opacity: .6; cursor: default; transform: none; }
.btn-confirm.is-confirmed { background: linear-gradient(135deg, #166534, #16a34a); }
.btn-confirm.is-updated { background: linear-gradient(135deg, #c2410c, #f97316); box-shadow: 0 3px 10px rgba(249,115,22,.35); }
.btn-confirm .material-symbols-rounded { font-size: 20px; }
.btn-report { display: inline-flex; align-items: center; gap: 6px; height: 46px; padding: 0 16px; border-radius: var(--radius-sm); font: inherit; font-weight: 700; font-size: .9rem; text-decoration: none;
  color: #fff; background: linear-gradient(135deg, #0e7490, #06b6d4); box-shadow: 0 3px 10px rgba(6,182,212,.3); transition: var(--transition); white-space: nowrap; }
.btn-report:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(6,182,212,.4); color: #fff; }
.btn-report .material-symbols-rounded { font-size: 20px; }
.mb-confirm-note { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -6px 0 12px; padding: 10px 14px; border-radius: 10px; background: #f0fdf4; border: 1.5px solid #86efac; color: #166534; font-size: .9rem; }
.mb-confirm-note.updated { background: #fff7ed; border-color: #fdba74; color: #9a3412; }
.mb-confirm-note small { flex-basis: 100%; color: var(--text-secondary); font-size: .8rem; }
.mb-confirm-note .material-symbols-rounded { font-size: 20px; }

/* ===== กล่องคำอธิบายรายวิชา / ผลลัพธ์การเรียนรู้ / มาตรฐานที่หลักสูตรอ้างอิง — ใต้การ์ดจับคู่ ===== */
.mb-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: -4px 0 14px; }
.mb-notes:empty { display: none; }
.mb-note-ref { grid-column: 1 / -1; border-color: #86efac; background: #f6fefa; }
.mb-note-ref summary { color: #166534; }
.mb-note-tag { display: inline-block; margin-left: 6px; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: #dcfce7; color: #166534; }
.mb-note-noref { grid-column: 1 / -1; background: #fffbeb; border-color: #fcd34d; color: #92400e; font-size: .9rem; }
.mbn-ref { margin-top: 10px; padding-top: 10px; border-top: 1px dashed #bbf7d0; }
.mbn-ref:first-of-type { border-top: none; padding-top: 6px; }
.mbn-occ { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mbn-tpqi { font-size: .8rem; padding: 4px 10px; }
.mbn-meta { font-size: .85rem; color: var(--text-secondary); margin-top: 2px; }
.mbn-uocs { margin: 6px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 4px 14px; font-size: .88rem; }
.mbn-uocs li { display: flex; gap: 8px; align-items: baseline; }
.mbn-uocs code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; background: #e0f2fe; color: #075985; padding: 1px 6px; border-radius: 6px; flex: none; }
.mb-ref-chip { display: inline-block; margin-top: 8px; font-size: .76rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.4); }

/* ===== รายการวิชา: วิชาที่ยืนยันแล้วซ่อนจากรายการ (โผล่เฉพาะตอนพิมพ์ค้นหา) ===== */
.link-course.confirmed { border-left: 5px solid #22c55e; background: #f6fefa; }
.c-done { color: #166534; font-weight: 700; }
.link-hidden-note { display: inline-flex; align-items: center; gap: 4px; margin-left: 10px; font-size: .82rem; color: #6b7280; }
.link-hidden-note .material-symbols-rounded { font-size: 16px; }
@media print { .mb-notes, .mb-confirm-note { display: none !important; } }
@media (max-width: 720px) { .mb-notes { grid-template-columns: 1fr; } }

/* ===== ขั้นที่ 2: ข้อมูลหลักสูตรรายวิชา ===== */
.ci-head { display: flex; gap: 18px; align-items: flex-start; padding: 16px 20px; border-radius: 14px; background: linear-gradient(135deg, #1e40af, #3b82f6); color: #fff; margin-bottom: 14px; box-shadow: 0 6px 18px rgba(37,99,235,.25); }
.ci-code { font-size: 1.5rem; font-weight: 800; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.35); padding: 8px 14px; border-radius: 12px; flex: none; }
.ci-title h3 { margin: 0; font-size: 1.35rem; font-weight: 800; }
.ci-en { opacity: .85; font-size: .95rem; }
.ci-meta { opacity: .9; font-size: .9rem; margin-top: 4px; }
.ci-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ci-chip { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 700; padding: 4px 11px; border-radius: 999px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.4); color: #fff; text-decoration: none; }
.ci-chip.ok { background: #16a34a; border-color: #16a34a; }
.ci-chip.warn { background: #f59e0b; border-color: #f59e0b; color: #1f2937; }
.ci-chip.none { background: rgba(255,255,255,.18); }
.ci-chip.link:hover { background: #fff; color: var(--primary); }
.ci-chip .material-symbols-rounded { font-size: 16px; }
.ci-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ci-card { background: #fff; border: 1.5px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.ci-card.ci-wide { grid-column: 1 / -1; background: #f8fbff; border-color: #bfdbfe; }
.ci-card h4 { margin: 0 0 8px; font-size: .98rem; font-weight: 800; color: var(--primary); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ci-card h4 small { font-weight: 500; color: var(--text-secondary); font-size: .8rem; }
.ci-card h4 .material-symbols-rounded { font-size: 20px; }
.ci-card p { margin: 0 0 6px; font-size: .92rem; line-height: 1.65; color: var(--text); text-indent: 1.4em; }
.ci-card p:last-child { margin-bottom: 0; }
.ci-empty { color: var(--text-secondary) !important; text-indent: 0 !important; font-style: italic; }
.ci-comps { margin: 0; padding-left: 1.6em; font-size: .93rem; line-height: 1.6; display: grid; gap: 4px; }
.ci-comps li::marker { font-weight: 800; color: var(--primary); }
.ci-ref { white-space: pre-line; text-indent: 0 !important; }
@media (max-width: 760px) { .ci-grid { grid-template-columns: 1fr; } .ci-head { flex-direction: column; gap: 10px; } }

/* ===== ขั้นที่ 3: มาตรฐานที่ใกล้เคียง ===== */
.link-suggest:empty { display: none; }
.link-suggest { margin-top: 14px; }
.sg-title { display: flex; align-items: center; gap: 8px; font-size: 1.02rem; font-weight: 800; color: #7c2d12; margin: 0 0 10px; flex-wrap: wrap; }
.sg-title .material-symbols-rounded { color: #f59e0b; }
.sg-title small { font-weight: 500; color: var(--text-secondary); font-size: .82rem; }
.sg-list { display: grid; gap: 10px; }
.sg-item { border: 1.5px solid var(--border); border-radius: 12px; padding: 12px 14px; background: #fff; transition: var(--transition); }
.sg-item:hover { border-color: var(--primary-light); }
.sg-item.active { border-color: #16a34a; box-shadow: 0 0 0 3px #dcfce7; background: #f6fefa; }
.sg-item.sg-skip { background: #fffbeb; border-color: #fcd34d; }
.sg-tag { display: inline-block; font-size: .72rem; font-weight: 800; padding: 2px 9px; border-radius: 999px; margin-bottom: 6px; }
.sg-tag.sn { background: #dcfce7; color: #166534; }
.sg-tag.sim { background: #fef3c7; color: #92400e; }
.sg-tag.warn { background: #fde68a; color: #78350f; }
.sg-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.sg-head b { font-size: 1.05rem; }
.sg-head small { display: block; color: var(--text-secondary); font-size: .85rem; margin-top: 2px; }
.sg-use { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sg-meta { font-size: .85rem; color: var(--text-secondary); margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.sg-meta code { background: #fef3c7; color: #92400e; padding: 1px 7px; border-radius: 6px; font-size: .82rem; }
.sg-why { margin: 6px 0 0; font-size: .88rem; color: var(--text); line-height: 1.55; }
.sg-hint { margin: 6px 0 0; font-size: .85rem; color: var(--text-secondary); }

/* ===== ปุ่ม TPQI สีแดง (หน้ามาตรฐาน — วิชาที่ไม่อ้างอิง) ===== */
.link-tpqi-cta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; padding: 12px 14px; border-radius: 12px; background: #fff1f2; border: 1.5px solid #fecdd3; }
.btn-tpqi-red { display: inline-flex; align-items: center; gap: 7px; padding: 11px 20px; border-radius: var(--radius-sm); font-weight: 800; font-size: .95rem; text-decoration: none; color: #fff;
  background: linear-gradient(135deg, #b91c1c, #ef4444); box-shadow: 0 4px 14px rgba(220,38,38,.35); transition: var(--transition); white-space: nowrap; }
.btn-tpqi-red:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(220,38,38,.45); color: #fff; }
.btn-tpqi-red .material-symbols-rounded { font-size: 20px; }
.btn-tpqi-red.outline { background: #fff; color: #b91c1c; border: 2px solid #ef4444; box-shadow: none; }
.btn-tpqi-red.outline:hover { background: #fee2e2; }
.link-tpqi-cta-hint { flex: 1 1 260px; font-size: .86rem; color: #7f1d1d; }

/* กรอบแรกของหน้าข้อมูลรายวิชา: มาตรฐานอาชีพที่หลักสูตรอ้างอิง — สีต่างจากกรอบอื่น */
.ci-card.ci-std { border-width: 2px; }
.ci-card.ci-std.tpqi { background: linear-gradient(135deg, #f0fdf4, #dcfce7); border-color: #22c55e; }
.ci-card.ci-std.tpqi h4 { color: #166534; }
.ci-card.ci-std.other { background: linear-gradient(135deg, #fffbeb, #fef3c7); border-color: #f59e0b; }
.ci-card.ci-std.other h4 { color: #92400e; }
.ci-card.ci-std.none { background: linear-gradient(135deg, #fff1f2, #ffe4e6); border-color: #f87171; }
.ci-card.ci-std.none h4 { color: #b91c1c; }
.ci-card.ci-std .ci-ref { font-weight: 600; }
.ci-card.ci-std .ci-empty { color: #7f1d1d !important; font-style: normal; }

/* ===== หลายมาตรฐานต่อ 1 วิชา: แท็บในหน้าตาราง + ช่องติ๊กในบล็อกอ้างอิง ===== */
.set-tabs { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: #eef2ff; border: 1.5px solid #c7d2fe; }
.st-label { display: flex; align-items: center; gap: 6px; font-size: .88rem; color: #3730a3; margin-bottom: 8px; flex-wrap: wrap; }
.st-label .material-symbols-rounded { font-size: 20px; }
.st-row { display: flex; gap: 8px; flex-wrap: wrap; }
.set-tab { position: relative; display: inline-flex; align-items: center; gap: 10px; padding: 8px 34px 8px 10px; border-radius: 12px; border: 1.5px solid var(--border); background: #fff; font: inherit; color: var(--text); cursor: pointer; text-align: left; transition: var(--transition); max-width: 100%; }
.set-tab:hover { border-color: var(--primary-light); box-shadow: var(--shadow-sm); }
.set-tab.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); background: var(--primary-50); }
.set-tab .st-no { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: none; font-size: .85rem; }
.set-tab .st-t { display: flex; flex-direction: column; min-width: 0; }
.set-tab .st-t b { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.set-tab .st-t small { color: var(--text-secondary); font-size: .76rem; }
.set-tab .st-res { display: flex; flex-direction: column; align-items: flex-end; font-size: .8rem; font-weight: 700; color: var(--text-secondary); white-space: nowrap; }
.set-tab .st-res em { font-style: normal; font-size: .72rem; padding: 1px 8px; border-radius: 999px; background: #fef3c7; color: #92400e; }
.set-tab.ok .st-res em { background: #dcfce7; color: #166534; }
.set-tab .st-x { position: absolute; top: 4px; right: 6px; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--text-secondary); font-weight: 700; font-size: 14px; }
.set-tab .st-x:hover { background: #fee2e2; color: #b91c1c; }
.set-tab.add { border-style: dashed; color: var(--primary); font-weight: 700; padding-right: 12px; gap: 4px; }
.set-tab.add .material-symbols-rounded { font-size: 18px; }
.link-ref .r-check { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .86rem; color: #166534; margin-bottom: 4px; cursor: pointer; }
.link-ref .r-check input { width: 17px; height: 17px; accent-color: #16a34a; }
.sg-btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sg-add { background: #fff; color: var(--primary); border: 1.5px solid var(--primary-light); box-shadow: none; height: auto; padding: 8px 12px; font-size: .84rem; }
.sg-add:hover { background: var(--primary-50); }
.sg-add .material-symbols-rounded { font-size: 18px; }

/* ===== ปุ่ม "ดูรายละเอียด" + กล่องรายละเอียดมาตรฐาน ===== */
.sg-detail, .r-detail { background: #fff; color: #0e7490; border: 1.5px solid #67e8f9; box-shadow: none; height: auto; padding: 8px 12px; font-size: .84rem; }
.sg-detail:hover, .r-detail:hover { background: #ecfeff; }
.sg-detail .material-symbols-rounded, .r-detail .material-symbols-rounded { font-size: 18px; }
.r-btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sg-head b.sg-link { cursor: pointer; }
.sg-head b.sg-link:hover { color: var(--primary); text-decoration: underline; }
.std-modal { position: fixed; inset: 0; z-index: 60; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; padding: 18px; }
.std-modal[hidden] { display: none; }
.std-modal-box { background: #fff; border-radius: 16px; width: min(980px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0,0,0,.3); overflow: hidden; }
.sm-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1.5px solid var(--border); background: linear-gradient(135deg, #eff6ff, #fff); }
.sm-head > div:first-child { flex: 1 1 auto; min-width: 0; }
.sm-title { font-weight: 800; font-size: 1.15rem; }
.sm-meta { color: var(--text-secondary); font-size: .86rem; margin-top: 2px; }
.sm-close { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--border); background: #fff; font-size: 20px; cursor: pointer; color: var(--text-secondary); flex: none; }
.sm-close:hover { background: #fee2e2; color: #b91c1c; }
.std-modal-box .std-level-pills { padding: 10px 20px 0; }
.sm-units { padding: 10px 20px 14px; overflow: auto; flex: 1 1 auto; display: grid; gap: 8px; }
.sm-unit { border: 1.5px solid var(--border); border-radius: 10px; padding: 8px 12px; background: #fff; }
.sm-unit summary { cursor: pointer; font-weight: 700; font-size: .95rem; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.sm-unit summary code { background: #e0f2fe; color: #075985; padding: 1px 8px; border-radius: 6px; font-size: .82rem; }
.sm-unit summary small { color: var(--text-secondary); font-weight: 500; margin-left: auto; }
.sm-eoc { margin: 8px 0 0 6px; padding-left: 10px; border-left: 3px solid #bfdbfe; font-size: .9rem; }
.sm-eoc-t { font-weight: 600; }
.sm-eoc-t code { background: #f1f5f9; padding: 1px 6px; border-radius: 6px; font-size: .78rem; }
.sm-eoc ul { margin: 4px 0 0; padding-left: 1.4em; color: var(--text-secondary); font-size: .86rem; line-height: 1.5; }
.sm-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1.5px solid var(--border); background: #f8fafc; flex-wrap: wrap; }
.sm-foot .btn-tool, .sm-foot .btn-word { display: inline-flex; align-items: center; gap: 6px; }
.sm-cancel { background: #fff; color: var(--text); border: 1.5px solid var(--border); box-shadow: none; }
.sm-add { background: #fff; color: var(--primary); border: 1.5px solid var(--primary-light); box-shadow: none; }
.sm-add:disabled { opacity: .5; cursor: default; }
@media print { .std-modal { display: none !important; } }

/* ===== ยืนยันแยกตามมาตรฐาน ===== */
.btn-confirm.all { background: #fff; color: #166534; border: 2px solid #22c55e; box-shadow: none; }
.btn-confirm.all:hover { background: #f0fdf4; }
.mb-confirm-note .cn-list { flex-basis: 100%; margin: 4px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.mb-confirm-note .cn-list li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .88rem; padding: 4px 8px; border-radius: 8px; background: rgba(255,255,255,.7); }
.mb-confirm-note .cn-list li.ok { color: #166534; }
.mb-confirm-note .cn-list li.upd { color: #9a3412; }
.mb-confirm-note .cn-list li em { font-style: normal; font-weight: 700; }
.mb-confirm-note .cn-list .material-symbols-rounded { font-size: 18px; }
.set-tab .st-conf { font-style: normal; font-size: .7rem; font-weight: 800; padding: 1px 7px; border-radius: 999px; margin-top: 2px; }
.set-tab .st-conf.ok { background: #16a34a; color: #fff; }
.set-tab .st-conf.upd { background: #f97316; color: #fff; }

/* ===== แถบสถานะเข้าสู่ระบบ (ดูได้ทุกคน · ลงมือทำต้องล็อกอิน) ===== */
.auth-bar { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; padding: 10px 16px; border-radius: 12px;
  background: #fff7ed; border: 1.5px solid #fdba74; color: #9a3412; font-size: .9rem; }
.auth-bar.on { background: #f0fdf4; border-color: #86efac; color: #166534; }
.auth-bar .material-symbols-rounded { font-size: 20px; }
.auth-bar .auth-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; background: linear-gradient(135deg, #b91c1c, #ef4444); color: #fff; text-decoration: none;
  font-weight: 800; font-size: .9rem; padding: 9px 18px; border-radius: 999px; box-shadow: 0 3px 10px rgba(220,38,38,.3); transition: var(--transition); white-space: nowrap; }
.auth-bar .auth-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(220,38,38,.4); color: #fff; }
body.guest .mb-cell { cursor: not-allowed; opacity: .85; }
body.guest .btn-confirm, body.guest .btn-word, body.guest .mb-pdf { filter: grayscale(.35); }
@media print { .auth-bar { display: none !important; } }

/* ป้าย "ทำไปแล้ว" ในรายการเลือกวิชา (วิชาที่ยืนยันแล้วยังอยู่ในรายการ — เจ้าของสั่ง 2026-09-08) */
.badge-done { display: inline-flex; align-items: center; gap: 3px; font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: #16a34a; color: #fff; box-shadow: 0 2px 6px rgba(22,163,74,.3); }
.badge-done .material-symbols-rounded { font-size: 15px; }
.link-course.done { background: linear-gradient(90deg, #f0fdf4, #fff 60%); border-color: #bbf7d0; }
.link-course.done .c-code { color: #15803d; }
.link-done-note { display: inline-flex; align-items: center; gap: 4px; margin-left: 10px; color: #15803d; font-weight: 600; }
.link-done-note .material-symbols-rounded { font-size: 16px; }
/* ป้ายทั้งสอง (ทำไปแล้ว + การอ้างอิง) อยู่ในช่องกริดเดียว ไม่ให้ปุ่ม "เลือก" ตกบรรทัด */
.link-course .c-badges { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }

/* ---------- แบบบันทึกผลการพิจารณา กรณีไม่มีมาตรฐานอาชีพรองรับ (ในกระดาษ .link-sheet — ใช้ทั้ง link.html และ PDF แดชบอร์ด) ---------- */
.link-sheet .ns-table td { vertical-align: top; padding: 6px 10px; }
.link-sheet .ns-h { margin-top: 8px; }
.link-sheet .ns-ind { padding-left: 1.5em; }
.link-sheet .ns-list { margin: 2px 0 0 1.6em; padding: 0; }
.link-sheet .ns-list li { padding-left: .2em; }
.link-sheet .ns-verdict { text-align: center; font-size: 17px; margin-top: 4px; }
/* ปุ่ม/กล่อง "ไม่มีมาตรฐานรองรับ" ในขั้นที่ 3 */
.btn-nostd { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 12px; border: 2px dashed #64748b; background: #f8fafc; color: #334155; font-weight: 700; cursor: pointer; font-family: inherit; font-size: .95rem; transition: var(--transition); }
.btn-nostd:hover { background: #e2e8f0; border-color: #334155; }
.btn-nostd .material-symbols-rounded { font-size: 20px; }
.nostd-form { display: grid; gap: 12px; }
.nostd-form fieldset { border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.nostd-form legend { font-weight: 700; padding: 0 6px; }
.nostd-form label.r { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.nostd-form label.r input { margin-top: 4px; }
.nostd-form label.c { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; font-size: .92rem; }
.nostd-form input[type=text], .nostd-form textarea { width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 10px; font-family: inherit; font-size: .95rem; }
.nostd-warn { background: #fff7ed; border: 1.5px solid #fed7aa; color: #9a3412; border-radius: 10px; padding: 10px 12px; font-size: .9rem; }
.nostd-actions { display: flex; justify-content: flex-end; gap: 10px; }
.mb-card.mb-c-none { border-color: #94a3b8; background: linear-gradient(135deg, #f1f5f9, #fff); }
.mb-pill.none { background: #e2e8f0; color: #334155; }
.mb-ring.none { --c: #64748b; }
.set-tab.nostd { border-color: #94a3b8; }

/* ---------- ป้าย "ใช้แล้ว" ในรายการมาตรฐานที่ใกล้เคียง (เจ้าของสั่ง 2026-09-09) ---------- */
.sg-tag.used { background: #ecfdf5; color: #065f46; border-color: #6ee7b7; }
.sg-used { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 8px; font-size: .8rem; }
.sg-used-tag { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: #065f46; background: #d1fae5; padding: 2px 9px; border-radius: 999px; }
.sg-used-tag .material-symbols-rounded { font-size: 15px; }
.sg-uc { background: #f8fafc; border: 1px solid var(--border); color: var(--text-secondary); padding: 2px 8px; border-radius: 999px; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.sg-uc.same { border-color: #6ee7b7; color: #065f46; background: #f0fdf4; }
.sg-uc.more { cursor: help; font-weight: 600; }
.sg-item.has-used { border-left: 4px solid #34d399; }

/* โมดัล "ไม่มีมาตรฐานรองรับ": หัวคงที่ · เนื้อหาเลื่อนได้ · ปุ่มยืนยันติดขอบล่างเสมอ (เจ้าของแจ้ง 2026-09-09: ไม่เห็นปุ่ม) */
#noStdModal .std-modal-box { padding: 18px 20px 0; }
#noStdModal .std-modal-head { flex: none; }
#noStdModal .nostd-form { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
#noStdModal .nostd-actions { position: sticky; bottom: 0; background: #fff; border-top: 1px solid #eef0f3; padding: 12px 0; margin-top: 2px; }

/* ปุ่มยืนยันตอนไม่ได้รับมอบหมายสาขานั้น (เจ้าของสั่ง 2026-09-10) */
.bar-confirm .btn-confirm.is-locked, .btn-confirm.is-locked { background: #e2e8f0; border-color: #cbd5e1; color: #64748b; cursor: not-allowed; box-shadow: none; }
.confirm-note .material-symbols-rounded { vertical-align: -4px; }
