/* ==========================================================================
   ใบฮับ · ชิ้นส่วนแบบ School Gradebook (รอบ 2)
   1) แท็บ (.tabs .seg — ต้นแบบ .act-tabs)   2) ชิปกรอง (.nf-chip)
   3) หน้าการแจ้งเตือน (.nf-*)              4) ปฏิทิน (.ecal-*)
   5) หน้าต่างกำลังโหลด (.ld-* หนูแฮมสเตอร์วิ่งในวงล้อ)
   ========================================================================== */

/* ---------- 1) แท็บ ---------- */
.tabs, .seg {
  display: inline-flex; flex-wrap: nowrap; align-items: center; gap: 4px;
  width: auto; max-width: 100%; overflow-x: auto; scrollbar-width: none;
  padding: 4px; border-radius: 14px;
  background: color-mix(in srgb, var(--leaf) 8%, var(--paper-2));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--leaf) 14%, transparent);
}
.seg { flex-wrap: wrap; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button, .seg span {
  display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0; white-space: nowrap;
  padding: .46rem 1rem; margin: 0; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: .88rem; font-weight: 600; line-height: 1.25; text-decoration: none; cursor: pointer;
  transition: background .2s cubic-bezier(.16,1,.3,1), color .2s, box-shadow .2s;
}
.tabs a:hover, .tabs button:hover, .seg label:hover span { color: var(--ink); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.tabs .on, .tabs .on:hover, .seg input:checked + span {
  background: var(--surface); color: var(--leaf-700); font-weight: 700;
  box-shadow: 0 1px 2px rgba(20, 60, 35, .10), 0 4px 12px rgba(20, 60, 35, .08);
}
.tabs a:focus-visible, .tabs button:focus-visible, .seg input:focus-visible + span { outline: 2px solid var(--leaf); outline-offset: 1px; }
/* ตัวเลขในแท็บ */
.tabs .n {
  display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 7px;
  border-radius: 999px; font-size: .74rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1;
  background: color-mix(in srgb, var(--muted) 15%, transparent); color: var(--muted);
}
.tabs .on .n { background: var(--leaf-600); color: #fff; }
html[data-theme="dark"] .tabs .on, html[data-theme="dark"] .seg input:checked + span {
  background: color-mix(in srgb, var(--leaf) 26%, var(--surface)); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.35);
}
html[data-theme="dark"] .tabs .on .n { background: #fff; color: #1e3a2b; }

/* ---------- 2) ชิปกรอง ---------- */
.nf-chip {
  --cf: #23663f; --ct: var(--leaf-600);
  display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0; white-space: nowrap;
  min-height: 34px; padding: .32rem .9rem; border-radius: 999px;
  background: color-mix(in srgb, var(--ct) 7%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ct) 16%, transparent);
  color: var(--ink); font-size: .86rem; font-weight: 600; line-height: 1.2; text-decoration: none;
  transition: background .18s cubic-bezier(.16,1,.3,1), color .18s, box-shadow .18s, transform .18s;
}
.nf-chip .ic { color: var(--ct); width: 16px; height: 16px; }
.nf-chip:hover { background: color-mix(in srgb, var(--ct) 14%, var(--surface)); color: var(--ink); transform: translateY(-1px); }
.nf-chip > b {
  display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 7px; margin-right: -.35rem;
  border-radius: 999px; font-size: .74rem; font-weight: 800; font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--ct) 16%, transparent); color: var(--ct);
}
.nf-chip.on, .nf-chip.on:hover { background: var(--cf); color: #fff; font-weight: 700; box-shadow: 0 2px 10px color-mix(in srgb, var(--cf) 35%, transparent); }
.nf-chip.on .ic { color: rgba(255,255,255,.88); }
.nf-chip.on > b { background: rgba(255,255,255,.22); color: #fff; }
.nf-chip.t-warn { --cf: #8a5a05; --ct: var(--st-late); }
.nf-chip.t-ok   { --cf: #1f6b3a; --ct: var(--st-ok); }

/* สีประจำประเภทการแจ้งเตือน (--nt = สีทึบ ใช้ทั้งชิป ไอคอน และแถบซ้ายของรายการที่ยังไม่อ่าน) */
.nt-task_new  { --nt: #6b8a12; }
.nt-submitted { --nt: #2f8051; }
.nt-returned  { --nt: #3f7fa5; }
.nt-approved  { --nt: #1f6b3a; }
.nt-reminder  { --nt: #b07812; }
.nt-announce  { --nt: #7c5cc4; }
.nt-extended  { --nt: #178a7e; }
.nt-reset_req { --nt: #c8452f; }
.nf-chip[class*="nt-"] { --cf: var(--nt); --ct: var(--nt); }
html[data-theme="dark"] .nf-chip:not(.on) .ic, html[data-theme="dark"] .nf-chip:not(.on) > b { color: color-mix(in srgb, var(--ct) 55%, #fff); }

/* ---------- 3) หน้าการแจ้งเตือน ---------- */
.nf-stats { margin-bottom: 18px; }
.nf-stat { color: inherit; text-decoration: none; padding: 14px 18px; align-items: center; transition: transform .15s, box-shadow .15s; }
a.nf-stat:hover { color: inherit; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.nf-stat .val { font-size: 26px; }
.nf-filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.nf-filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nf-filter-lb { font-size: .8rem; font-weight: 700; color: var(--muted); min-width: 3.6rem; }
.nf-list { --nt: var(--leaf); display: flex; flex-direction: column; gap: 9px; }
.nf-item {

  display: flex; align-items: flex-start; gap: 13px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, opacity .18s;
}
.nf-item:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.nf-item.unread { border-left: 4px solid var(--nt); background: linear-gradient(90deg, color-mix(in srgb, var(--nt) 6%, var(--surface)), var(--surface) 45%); }
.nf-item.going { opacity: 0; transform: translateX(28px); }
.nf-ic { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--nt) 14%, var(--surface)); color: var(--nt); }
.nf-ic .ic { width: 19px; height: 19px; }
.nf-main { flex: 1; min-width: 0; display: block; color: inherit; text-decoration: none; }
.nf-main:hover { color: inherit; }
.nf-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.nf-type { font-size: .7rem; font-weight: 700; letter-spacing: .02em; padding: 1px 8px; border-radius: 6px;
  background: color-mix(in srgb, var(--nt) 14%, transparent); color: var(--nt); }
.nf-time { font-size: .74rem; color: var(--muted); }
.nf-title { display: block; font-weight: 600; font-size: .93rem; color: var(--ink); line-height: 1.45; overflow-wrap: anywhere; }
.nf-item.unread .nf-title { font-weight: 700; }
.nf-main:hover .nf-title { color: var(--leaf-700); }
.nf-body { display: block; font-size: .82rem; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.nf-actions { flex: none; display: flex; gap: 4px; }
.nf-btn { width: 32px; height: 32px; padding: 0; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); display: grid; place-items: center; cursor: pointer; transition: .15s; }
.nf-btn .ic { width: 16px; height: 16px; }
.nf-btn:hover { background: var(--leaf-600); border-color: var(--leaf-600); color: #fff; }
.nf-btn.danger:hover { background: #c8452f; border-color: #c8452f; }
html[data-theme="dark"] .nf-type, html[data-theme="dark"] .nf-ic { color: color-mix(in srgb, var(--nt) 55%, #fff); }
.pager { display: flex; justify-content: center; gap: 6px; margin: 22px 0 6px; }
.pager a { min-width: 38px; height: 38px; padding: 0 10px; display: inline-grid; place-items: center; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-weight: 700; font-family: var(--font-display); }
.pager a:hover { border-color: var(--leaf); color: var(--leaf-700); }
.pager a.on { background: var(--leaf-600); border-color: var(--leaf-600); color: #fff; }
.pager a.off { opacity: .4; pointer-events: none; }
@media (max-width: 760px) {
  .nf-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .nf-item { padding: 11px 12px; gap: 10px; }
  .nf-ic { width: 34px; height: 34px; }
  .nf-filter-lb { min-width: 100%; }
  .nf-actions { flex-direction: column; }
}

/* ---------- 4) ปฏิทิน ---------- */
.ecal-missing   { --ec: #d1624c; --ec-ink: #b5462f; }
.ecal-submitted { --ec: #3e9b63; --ec-ink: #23663f; }
.ecal-late      { --ec: #d39a22; --ec-ink: #8a5a05; }
.ecal-returned  { --ec: #4f8fb3; --ec-ink: #2f6d91; }
.ecal-approved  { --ec: #178a7e; --ec-ink: #0f645b; }
.ecal-manage    { --ec: #7c5cc4; --ec-ink: #5b3fa3; }
[class*="ecal-"] { --ec-wash: color-mix(in srgb, var(--ec, var(--leaf)) 13%, var(--surface)); }
html[data-theme="dark"] [class*="ecal-"] { --ec-wash: color-mix(in srgb, var(--ec, var(--leaf)) 22%, transparent); }
html[data-theme="dark"] .ecal-missing   { --ec-ink: #ffb4a3; }
html[data-theme="dark"] .ecal-submitted { --ec-ink: #9be6b8; }
html[data-theme="dark"] .ecal-late      { --ec-ink: #ffd671; }
html[data-theme="dark"] .ecal-returned  { --ec-ink: #a9d5f0; }
html[data-theme="dark"] .ecal-approved  { --ec-ink: #8ee6d9; }
html[data-theme="dark"] .ecal-manage    { --ec-ink: #d6c2ff; }

.ecal-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ecal-h { display: flex; align-items: center; gap: 10px; font-size: 24px; }
.ecal-viewsw { display: inline-flex; gap: 2px; padding: 3px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; }
.ecal-viewsw a { padding: 6px 18px; border-radius: 999px; font-size: .86rem; font-weight: 700; color: var(--muted); line-height: 1.4; }
.ecal-viewsw a:hover { color: var(--leaf-700); background: color-mix(in srgb, var(--leaf) 10%, transparent); }
.ecal-viewsw a.on { background: linear-gradient(135deg, var(--leaf), #1f6b3a); color: #fff; }

.ecal-filterbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px; border-radius: 16px; }
.ecal-filterbar-label { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: .82rem; color: var(--muted); margin-right: 2px; }
.ecal-filter { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: inherit; font-size: .8rem; font-weight: 600; transition: .15s; }
.ecal-filter:hover { border-color: var(--ec); }
.ecal-filter.is-on { background: var(--ec-wash); border-color: var(--ec); color: var(--ec-ink); }
.ecal-filter:not(.is-on) { opacity: .55; }
.ecal-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--ec); }
.ecal-filter:not(.is-on) .ecal-dot { filter: grayscale(1); }

.ecal-layout { align-items: start; }
.ecal-navbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px; border-radius: 16px; }
.ecal-navbar .btn { margin-bottom: 3px; }
.ecal-title { font-size: 19px; }
.ecal-card { overflow: hidden; border-radius: 20px; }

.ecal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.ecal-dow { text-align: center; padding: 10px 0; font-family: var(--font-display); font-weight: 800; font-size: .76rem; letter-spacing: .04em;
  color: var(--leaf-700); background: color-mix(in srgb, var(--leaf) 7%, var(--surface)); border-bottom: 1px solid var(--line); }
.ecal-dow.is-sun { color: #c8452f; }
.ecal-cell { min-height: 108px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 3px; overflow: hidden; min-width: 0; cursor: pointer; transition: background .12s; }
.ecal-cell:nth-child(7n) { border-right: 0; }
.ecal-cell:hover { background: color-mix(in srgb, var(--leaf) 5%, transparent); }
.ecal-cell:focus-visible { outline: 2px solid var(--leaf); outline-offset: -2px; }
.ecal-out { background: var(--paper-2); opacity: .5; cursor: default; }
.ecal-out:hover { background: var(--paper-2); }
.ecal-today { background: color-mix(in srgb, var(--leaf) 7%, transparent); }
.ecal-cell.sel { box-shadow: inset 0 0 0 2px var(--leaf); border-radius: 10px; }
.ecal-daynum-wrap { display: flex; align-items: center; justify-content: space-between; }
.ecal-daynum { font-family: var(--font-display); font-weight: 700; font-size: .84rem; width: 26px; height: 26px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--ink-2); }
.ecal-cell.is-past .ecal-daynum { color: var(--faint); }
.ecal-daynum.is-sun { color: #c8452f; }
.ecal-daynum.is-today { background: linear-gradient(135deg, var(--leaf), #1f6b3a); color: #fff; box-shadow: 0 3px 10px color-mix(in srgb, var(--leaf) 45%, transparent); }
.ecal-hasdot { width: 6px; height: 6px; border-radius: 50%; background: var(--leaf); }
.ecal-evs { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.ecal-pill { display: block; font-size: .7rem; font-weight: 600; padding: 2px 6px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--ec-wash); color: var(--ec-ink); border-left: 3px solid var(--ec); }
.ecal-pill:hover { color: var(--ec-ink); filter: brightness(.97); }
.ecal-pill b { font-weight: 800; }
.ecal-pill.is-closed, .ecal-wev.is-closed, .ecal-day-row.is-closed { opacity: .6; }
.ecal-more { font-size: .66rem; font-weight: 800; color: var(--muted); text-align: right; padding-right: 2px; }

/* แผงกำหนดการของวันที่เลือก / มุมมองรายวัน */
.ecal-agenda, .ecal-dayview { margin-top: 14px; padding: 18px 20px; border-radius: 20px; }
.ecal-dayview { margin-top: 0; }
.ecal-agenda-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.ecal-agenda-head h3 { font-size: 17px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ecal-agenda-label { font-size: .72rem; letter-spacing: .06em; color: var(--leaf-600); font-weight: 700; }
.ecal-day-row { display: flex; align-items: stretch; gap: 10px; padding: 12px; margin-bottom: 8px; border-radius: 14px; background: var(--surface-2); border-left: 4px solid var(--ec); }
html[data-theme="dark"] .ecal-day-row { background: rgba(255,255,255,.04); }
.ecal-day-time { flex: 0 0 74px; font-family: var(--font-display); font-weight: 800; font-size: .84rem; color: var(--ec-ink); padding-top: 2px; }
.ecal-day-bar { width: 3px; border-radius: 3px; background: var(--ec); flex-shrink: 0; opacity: .5; }
.ecal-ag-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.ecal-ag-tag { display: inline-flex; align-items: center; gap: 4px; font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 20px; background: var(--ec-wash); color: var(--ec-ink); }
.ecal-ag-tag2 { font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 20px; background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.ecal-day-title { display: block; font-weight: 700; font-size: .96rem; color: var(--ink); }
.ecal-day-title:hover { color: var(--ec-ink); text-decoration: underline; }
.ecal-ag-go { align-self: center; color: var(--leaf-600); }

/* มุมมองรายสัปดาห์ */
.ecal-weekcard { overflow-x: auto; }
.ecal-weekgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.ecal-wcol { border-right: 1px solid var(--line); min-height: 340px; display: flex; flex-direction: column; min-width: 0; }
.ecal-wcol:last-child { border-right: 0; }
.ecal-wcol.is-today { background: color-mix(in srgb, var(--leaf) 6%, transparent); }
.ecal-whead { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 10px 4px; border-bottom: 1px solid var(--line); color: var(--ink); }
.ecal-whead:hover { background: color-mix(in srgb, var(--leaf) 8%, transparent); color: var(--ink); }
.ecal-wdow { font-size: .72rem; font-weight: 800; color: var(--muted); }
.ecal-wdow.is-sun { color: #c8452f; }
.ecal-wnum { font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 50%; }
.ecal-wnum.is-today { background: linear-gradient(135deg, var(--leaf), #1f6b3a); color: #fff; box-shadow: 0 3px 10px color-mix(in srgb, var(--leaf) 45%, transparent); }
.ecal-wmon { font-size: .68rem; color: var(--muted); font-weight: 700; }
.ecal-wevs { display: flex; flex-direction: column; gap: 6px; padding: 8px 6px; }
.ecal-wev { display: block; padding: 6px 8px; border-radius: 8px; border-left: 3px solid var(--ec); background: var(--ec-wash); color: var(--ec-ink); transition: transform .12s; }
.ecal-wev:hover { color: var(--ec-ink); filter: brightness(.97); transform: translateX(1px); }
.ecal-wev-time { display: flex; align-items: center; gap: 3px; font-size: .68rem; font-weight: 800; }
.ecal-wev-title { display: block; font-size: .76rem; font-weight: 600; color: var(--ink); line-height: 1.35; overflow-wrap: anywhere; }
.ecal-wempty { text-align: center; color: var(--faint); font-size: .8rem; padding: 6px 0; }

/* งานที่ใกล้ถึงกำหนด */
.ecal-upcard { border-radius: 20px; }
.ecal-upcard .card-head h2 { display: flex; align-items: center; gap: 7px; font-size: 16px; }
.ecal-upcoming { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.ecal-up-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--ec-wash); border-left: 4px solid var(--ec); color: var(--ink); transition: transform .12s, filter .12s; }
.ecal-up-item:hover { color: var(--ink); filter: brightness(.97); transform: translateX(2px); }
.ecal-up-ico { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 10px; background: var(--ec); color: #fff; display: grid; place-items: center; }
.ecal-up-ico .ic { width: 17px; height: 17px; }
.ecal-up-title { display: block; font-weight: 700; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ecal-up-meta { display: block; font-size: .72rem; color: var(--muted); }
.ecal-up-code { display: inline-block; padding: 0 6px; margin-right: 5px; border-radius: 6px; background: var(--ec); color: #fff; font-weight: 800; font-size: .66rem; }
.ecal-up-chip { flex: none; display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .7rem; font-weight: 800; white-space: nowrap;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.ecal-up-chip.is-ok { background: #1f6b3a; color: #fff; border-color: transparent; }
.ecal-up-chip.is-now { background: #c8452f; color: #fff; border-color: transparent; }
.ecal-up-chip.is-soon { background: #f2c14b; color: #3d2a02; border-color: transparent; }
.ecal-count-badge { min-width: 28px; height: 28px; padding: 0 9px; border-radius: 999px; background: linear-gradient(135deg, var(--leaf), #1f6b3a); color: #fff;
  font-family: var(--font-display); font-weight: 800; font-size: .84rem; display: inline-grid; place-items: center; }
.ecal-empty { display: none; flex-direction: column; align-items: center; gap: 6px; padding: 28px 10px; text-align: center; color: var(--muted); font-size: .88rem; }
.ecal-empty .ic { color: var(--sage); width: 30px; height: 30px; }
.is-empty > .ecal-empty { display: flex; }
.ecal-wevs > .ecal-wempty { display: none; }
.ecal-wevs.is-empty > .ecal-wempty { display: block; }

/* ชิปกรองที่ปิดไว้ = ซ่อนรายการประเภทนั้นทุกมุมมอง (JS เติมคลาส no-<type> ที่ .ecal) */
.ecal.no-missing [data-type="missing"]:not(.ecal-filter), .ecal.no-submitted [data-type="submitted"]:not(.ecal-filter),
.ecal.no-late [data-type="late"]:not(.ecal-filter), .ecal.no-returned [data-type="returned"]:not(.ecal-filter),
.ecal.no-approved [data-type="approved"]:not(.ecal-filter), .ecal.no-manage [data-type="manage"]:not(.ecal-filter),
.ecal-pill.is-extra { display: none; }

@media (max-width: 760px) {
  .ecal-h { font-size: 20px; }
  .ecal-viewsw a { padding: 5px 12px; font-size: .8rem; }
  .ecal-cell { min-height: 62px; padding: 3px; }
  .ecal-daynum { width: 22px; height: 22px; font-size: .76rem; }
  .ecal-pill { font-size: 0; height: 6px; padding: 0; border-left: 0; background: var(--ec); }
  .ecal-pill b { display: none; }
  .ecal-more { font-size: .6rem; }
  .ecal-day-time { flex-basis: 58px; font-size: .76rem; }
  .ecal-weekgrid { grid-template-columns: repeat(7, minmax(118px, 1fr)); }
  .ecal-wcol { min-height: 220px; }
}

/* ---------- 5) หน้าต่างกำลังโหลด (หนูแฮมสเตอร์วิ่งในวงล้อ · ต้นแบบ loading.css ของ Gradebook) ----------
   โผล่หลังทำงานไปแล้ว 2 วินาที (กันกะพริบตอนบันทึกเร็ว ๆ) · % มาจากความคืบหน้าจริงเท่านั้น
   วัดไม่ได้ = แถบวิ่งไม่มีตัวเลข · ย่อลงมุมจอได้ · เงียบเกิน 12 วินาทีบอกตรง ๆ */
.ld-overlay { position: fixed; inset: 0; z-index: 5000; display: none; align-items: center; justify-content: center; padding: 20px;
  background: rgba(14, 30, 20, .38); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); opacity: 0; transition: opacity .2s; }
.ld-overlay.show { opacity: 1; }
.ld-pop { position: relative; min-width: 320px; max-width: 420px; padding: 34px 30px 22px; border-radius: 24px; background: var(--surface);
  box-shadow: 0 30px 80px -20px rgba(10, 30, 18, .5), 0 0 0 1px rgba(30, 58, 43, .06);
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  transform: translateY(10px) scale(.97); transition: transform .25s cubic-bezier(.2, 1.2, .4, 1); }
.ld-overlay.show .ld-pop { transform: none; }
.ld-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; }
.ld-btn { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.ld-btn .ic { width: 16px; height: 16px; }
.ld-btn:hover { background: var(--leaf-50); color: var(--ink); }
.ld-pct { font-family: var(--font-display); font-size: 30px; font-weight: 800; color: var(--leaf-600); font-variant-numeric: tabular-nums; line-height: 1; }
.ld-label { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--ink); }
.ld-bar { width: 100%; height: 10px; border-radius: 99px; background: var(--leaf-50); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.06); }
.ld-bar > i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #9cd67a, var(--leaf), #1f6b3a); transition: width .3s ease; }
.ld-sub { min-height: 1.2em; font-size: 13px; color: var(--muted); }
.ld-pop.is-indeterminate .ld-pct { display: none; }
.ld-pop.is-indeterminate .ld-bar > i { width: 38% !important; animation: ldSlide 1.15s cubic-bezier(.45,.05,.55,.95) infinite; }
@keyframes ldSlide { from { transform: translateX(-105%); } to { transform: translateX(275%); } }
.ld-pop.is-stuck .ld-sub { color: #8a5a05; font-weight: 600; }
.ld-pop.is-stuck .ld-bar > i { background: linear-gradient(90deg, #f2c14b, #8a5a05); }
.ld-pop.is-fail .wheel-and-hamster, .ld-pop.is-fail .ld-pct, .ld-pop.is-fail .ld-bar { display: none; }
.ld-pop.is-fail .ld-label { color: #c8452f; }
.ld-pop.is-fail .ld-sub { color: var(--ink); max-width: 34ch; }
.ld-fail-ic { display: none; width: 46px; height: 46px; color: #c8452f; }
.ld-pop.is-fail .ld-fail-ic { display: block; }

.ld-chip { position: fixed; right: 18px; bottom: 18px; z-index: 5001; display: none; align-items: center; gap: 10px;
  padding: 8px 16px 8px 8px; border: 0; border-radius: 999px; cursor: pointer; background: var(--surface); color: var(--ink);
  box-shadow: 0 10px 30px rgba(10,30,18,.24), 0 0 0 1px rgba(10,30,18,.06); font: inherit; font-size: .84rem; font-weight: 700; }
.ld-chip.show { display: flex; animation: ldChipIn .24s cubic-bezier(.2,1.2,.4,1); }
@keyframes ldChipIn { from { transform: translateY(12px); opacity: 0; } }
.ld-ring { --p: 0; position: relative; width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--leaf) calc(var(--p) * 1%), var(--leaf-50) 0); }
.ld-ring > b { width: 22px; height: 22px; border-radius: 50%; background: var(--surface); }
.ld-ring::after { content: ""; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--leaf); animation: ldPulse 1.4s ease-in-out infinite; }
@keyframes ldPulse { 50% { opacity: .35; transform: scale(.7); } }
.ld-chip-tx { font-variant-numeric: tabular-nums; min-width: 3ch; }
html[data-theme="dark"] .ld-overlay { background: rgba(0, 0, 0, .5); }

/* หนูแฮมสเตอร์ในวงล้อ — เรขาคณิตคัดลอกจากต้นแบบตรงตัว เปลี่ยนแค่สีวงล้อเป็นเขียว */
.wheel-and-hamster {
  --dur: 1s;
  position: relative;
  width: 12em;
  height: 12em;
  font-size: 12px;
}
.wheel,
.hamster,
.hamster div,
.spoke { position: absolute; }
.wheel,
.spoke { border-radius: 50%; top: 0; left: 0; width: 100%; height: 100%; }
.wheel {
  background: radial-gradient(100% 100% at center,hsla(0,0%,60%,0) 47.8%,#3e9b63 48%);
  z-index: 2;
}
.hamster {
  animation: hamster var(--dur) ease-in-out infinite;
  top: 50%;
  left: calc(50% - 3.5em);
  width: 7em;
  height: 3.75em;
  transform: rotate(4deg) translate(-0.8em,1.85em);
  transform-origin: 50% 0;
  z-index: 1;
}
.hamster__head {
  animation: hamsterHead var(--dur) ease-in-out infinite;
  background: hsl(30,90%,55%);
  border-radius: 70% 30% 0 100% / 40% 25% 25% 60%;
  box-shadow: 0 -0.25em 0 hsl(30,90%,80%) inset, 0.75em -1.55em 0 hsl(30,90%,90%) inset;
  top: 0; left: -2em; width: 2.75em; height: 2.5em;
  transform-origin: 100% 50%;
}
.hamster__ear {
  animation: hamsterEar var(--dur) ease-in-out infinite;
  background: hsl(0,90%,85%);
  border-radius: 50%;
  box-shadow: -0.25em 0 hsl(30,90%,55%) inset;
  top: -0.25em; right: -0.25em; width: 0.75em; height: 0.75em;
  transform-origin: 50% 75%;
}
.hamster__eye {
  animation: hamsterEye var(--dur) linear infinite;
  background-color: hsl(0,0%,0%);
  border-radius: 50%;
  top: 0.375em; left: 1.25em; width: 0.5em; height: 0.5em;
}
.hamster__nose {
  background: hsl(0,90%,75%);
  border-radius: 35% 65% 85% 15% / 70% 50% 50% 30%;
  top: 0.75em; left: 0; width: 0.2em; height: 0.25em;
}
.hamster__body {
  animation: hamsterBody var(--dur) ease-in-out infinite;
  background: hsl(30,90%,90%);
  border-radius: 50% 30% 50% 30% / 15% 60% 40% 40%;
  box-shadow: 0.1em 0.75em 0 hsl(30,90%,55%) inset, 0.15em -0.5em 0 hsl(30,90%,80%) inset;
  top: 0.25em; left: 2em; width: 4.5em; height: 3em;
  transform-origin: 17% 50%;
  transform-style: preserve-3d;
}
.hamster__limb--fr,
.hamster__limb--fl {
  clip-path: polygon(0 0,100% 0,70% 80%,60% 100%,0% 100%,40% 80%);
  top: 2em; left: 0.5em; width: 1em; height: 1.5em;
  transform-origin: 50% 0;
}
.hamster__limb--fr {
  animation: hamsterFRLimb var(--dur) linear infinite;
  background: linear-gradient(hsl(30,90%,80%) 80%,hsl(0,90%,75%) 80%);
  transform: rotate(15deg) translateZ(-1px);
}
.hamster__limb--fl {
  animation: hamsterFLLimb var(--dur) linear infinite;
  background: linear-gradient(hsl(30,90%,90%) 80%,hsl(0,90%,85%) 80%);
  transform: rotate(15deg);
}
.hamster__limb--br,
.hamster__limb--bl {
  border-radius: 0.75em 0.75em 0 0;
  clip-path: polygon(0 0,100% 0,100% 30%,70% 90%,70% 100%,30% 100%,40% 90%,0% 30%);
  top: 1em; left: 2.8em; width: 1.5em; height: 2.5em;
  transform-origin: 50% 30%;
}
.hamster__limb--br {
  animation: hamsterBRLimb var(--dur) linear infinite;
  background: linear-gradient(hsl(30,90%,80%) 90%,hsl(0,90%,75%) 90%);
  transform: rotate(-25deg) translateZ(-1px);
}
.hamster__limb--bl {
  animation: hamsterBLLimb var(--dur) linear infinite;
  background: linear-gradient(hsl(30,90%,90%) 90%,hsl(0,90%,85%) 90%);
  transform: rotate(-25deg);
}
.hamster__tail {
  animation: hamsterTail var(--dur) linear infinite;
  background: hsl(0,90%,85%);
  border-radius: 0.25em 50% 50% 0.25em;
  box-shadow: 0 -0.2em 0 hsl(0,90%,75%) inset;
  top: 1.5em; right: -0.5em; width: 1em; height: 0.5em;
  transform: rotate(30deg) translateZ(-1px);
  transform-origin: 0.25em 0.25em;
}
.spoke {
  animation: spoke var(--dur) linear infinite;
  background: radial-gradient(100% 100% at center,#3e9b63 4.8%,hsla(0,0%,60%,0) 5%),
    linear-gradient(hsla(0,0%,55%,0) 46.9%,#9cc3a6 47% 52.9%,hsla(0,0%,65%,0) 53%) 50% 50% / 99% 99% no-repeat;
}

@keyframes hamster {
  from, to { transform: rotate(4deg) translate(-0.8em,1.85em); }
  50% { transform: rotate(0) translate(-0.8em,1.85em); }
}
@keyframes hamsterHead {
  from, 25%, 50%, 75%, to { transform: rotate(0); }
  12.5%, 37.5%, 62.5%, 87.5% { transform: rotate(8deg); }
}
@keyframes hamsterEye {
  from, 90%, to { transform: scaleY(1); }
  95% { transform: scaleY(0); }
}
@keyframes hamsterEar {
  from, 25%, 50%, 75%, to { transform: rotate(0); }
  12.5%, 37.5%, 62.5%, 87.5% { transform: rotate(12deg); }
}
@keyframes hamsterBody {
  from, 25%, 50%, 75%, to { transform: rotate(0); }
  12.5%, 37.5%, 62.5%, 87.5% { transform: rotate(-2deg); }
}
@keyframes hamsterFRLimb {
  from, 25%, 50%, 75%, to { transform: rotate(50deg) translateZ(-1px); }
  12.5%, 37.5%, 62.5%, 87.5% { transform: rotate(-30deg) translateZ(-1px); }
}
@keyframes hamsterFLLimb {
  from, 25%, 50%, 75%, to { transform: rotate(-30deg); }
  12.5%, 37.5%, 62.5%, 87.5% { transform: rotate(50deg); }
}
@keyframes hamsterBRLimb {
  from, 25%, 50%, 75%, to { transform: rotate(-60deg) translateZ(-1px); }
  12.5%, 37.5%, 62.5%, 87.5% { transform: rotate(20deg) translateZ(-1px); }
}
@keyframes hamsterBLLimb {
  from, 25%, 50%, 75%, to { transform: rotate(20deg); }
  12.5%, 37.5%, 62.5%, 87.5% { transform: rotate(-60deg); }
}
@keyframes hamsterTail {
  from, 25%, 50%, 75%, to { transform: rotate(30deg) translateZ(-1px); }
  12.5%, 37.5%, 62.5%, 87.5% { transform: rotate(10deg) translateZ(-1px); }
}
@keyframes spoke {
  from { transform: rotate(0); }
  to { transform: rotate(-1turn); }
}

@media (max-width: 575px) {
  .wheel-and-hamster { font-size: 9px; }
  .ld-pop { min-width: 0; width: calc(100vw - 40px); padding: 30px 20px 18px; }
  .ld-chip { right: 12px; bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .wheel-and-hamster, .wheel-and-hamster * { animation: none !important; }
  .ld-pop.is-indeterminate .ld-bar > i, .ld-ring::after { animation: none; }
  .nf-chip, .nf-item, .ecal-wev, .ecal-up-item { transition: none; }
}

/* ปฏิทินต้องการพื้นที่ 7 คอลัมน์ — แผงด้านข้างย้ายลงล่างเมื่อจอไม่กว้างพอ */
.ecal-layout.grid { grid-template-columns: minmax(0, 1fr) 340px; }
@media (max-width: 1280px) { .ecal-layout.grid { grid-template-columns: minmax(0, 1fr); } }
.ecal-weekgrid { grid-template-columns: repeat(7, minmax(104px, 1fr)); }
.ecal-wev-time { white-space: nowrap; }
.ecal-wev-title { overflow-wrap: break-word; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 6) ปุ่มลบแบบ Gradebook (.sg-del) ----------
   ปุ่มถังขยะที่มีแต่ไอคอน = วงกลมสีแดงอ่อน · ชี้แล้วกางเป็นแคปซูลสีแดง คำว่า "ลบ" เลื่อนลงมา ถังขยะเลื่อนลง
   app.js แปลงปุ่มให้เองทั้งเว็บ (ปุ่มเดิมไม่ถูกแตะ type/name/data-* ใด ๆ) */
.del-pill {
  width: 34px; height: 34px; flex: none; position: relative; display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 0; border: 0; border-radius: 999px; cursor: pointer; vertical-align: middle;
  background: #fdeae5; color: #c8452f; box-shadow: 0 1px 6px rgba(0, 0, 0, .1);
  transition: width .3s, border-radius .3s, background .3s, box-shadow .25s, transform .1s;
}
.del-pill .ic { width: 15px; height: 15px; transition: width .3s, height .3s, transform .3s, color .3s; }
.del-pill .dp-tx { position: absolute; top: -14px; left: 0; right: 0; color: #fff; font: 700 2px/1 var(--font-body);
  opacity: 0; text-align: center; white-space: nowrap; transition: font-size .3s, opacity .3s, transform .3s; }
.del-pill:hover, .del-pill:focus-visible { width: 72px; background: #c8452f; color: #fff; box-shadow: 0 6px 16px rgba(200, 69, 47, .42); }
.del-pill:hover .ic, .del-pill:focus-visible .ic { width: 20px; height: 20px; transform: translateY(58%); }
.del-pill:hover .dp-tx, .del-pill:focus-visible .dp-tx { font-size: .78rem; opacity: 1; transform: translateY(19px); }
.del-pill:focus-visible { outline: 3px solid rgba(200, 69, 47, .35); outline-offset: 2px; }
.del-pill:active { transform: scale(.94); }
html[data-theme="dark"] .del-pill:not(:hover):not(:focus-visible) { background: #3d211b; color: #f39a85; }
@media (prefers-reduced-motion: reduce) { .del-pill, .del-pill * { transition: none; } }
@media print { .del-pill { display: none !important; } }

/* ---------- 7) ปุ่มออกจากระบบ (กางออกเป็นปุ่มมีข้อความตอนชี้ · สีแดง) ---------- */
.logout-btn {
  display: flex; align-items: center; justify-content: flex-start; flex: none;
  width: 42px; height: 42px; border-radius: 10px; position: relative; overflow: hidden;
  background: #d9412c; color: #fff; text-decoration: none; cursor: pointer;
  box-shadow: 2px 2px 10px rgba(160, 40, 20, .25); transition-duration: .3s;
}
.logout-btn .lo-sign { width: 100%; display: flex; align-items: center; justify-content: center; transition-duration: .3s; }
.logout-btn .lo-sign .ic { width: 18px; height: 18px; color: #fff; }
.logout-btn .lo-text { position: absolute; right: 0; width: 0; opacity: 0; color: #fff; font: 700 14px/1 var(--font-display);
  white-space: nowrap; transition-duration: .3s; }
.logout-btn:hover, .logout-btn:focus-visible { width: 142px; color: #fff; background: #c8341f; }
.logout-btn:hover .lo-sign, .logout-btn:focus-visible .lo-sign { width: 30%; padding-left: 14px; }
.logout-btn:hover .lo-text, .logout-btn:focus-visible .lo-text { opacity: 1; width: 70%; padding-right: 10px; }
.logout-btn:active { transform: translate(2px, 2px); }
.logout-btn:focus-visible { outline: 3px solid rgba(217, 65, 44, .35); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .logout-btn, .logout-btn * { transition: none; } }
/* ---------- 8) สถานะ "ส่งไม่ครบ" (งานหลายช่อง) ---------- */
.st-partial { background: #fdf0d8; color: #a8660b; }
html[data-theme="dark"] .st-partial { background: #3a2d12; color: #f0b450; }
.mc.partial { background: #fdf0d8; color: #a8660b; border: 1.6px dashed #e2b25c; }
.ecal-partial { --ec: #e08a1e; --ec-ink: #9a5a06; }
html[data-theme="dark"] .ecal-partial { --ec-ink: #ffc56b; }
.ecal.no-partial [data-type="partial"]:not(.ecal-filter) { display: none; }
/* ---------- 9) งานหลายช่อง: การ์ดช่องในหน้าส่งงาน + ป้ายช่องในตาราง ---------- */
.slot-list { display: flex; flex-direction: column; gap: 12px; }
.slot { border: 1.5px dashed var(--line-2); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.slot.is-ok { border-style: solid; border-color: color-mix(in srgb, var(--leaf) 45%, var(--line)); background: color-mix(in srgb, var(--leaf) 5%, var(--surface)); }
.slot-head { display: flex; align-items: center; gap: 9px; }
.slot-head b { font-family: var(--font-display); font-size: 14.5px; }
.slot-no { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; font: 800 13px/1 var(--font-display);
  background: var(--paper-2); color: var(--muted); }
.slot.is-ok .slot-no { background: var(--leaf); color: #fff; }
.slot-no .ic { width: 15px; height: 15px; }
.slot .dd.is-compact { margin: 0 auto; }
.slot-tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700;
  background: var(--leaf-50); color: var(--leaf-700); }
.slot-tag.miss { background: #fdf0d8; color: #a8660b; }
.slot-prog { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
/* ตัวแก้ช่องส่งงานในหน้าสั่งงาน */
.slot-editor { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 10px; }
.slot-rows { display: flex; flex-direction: column; gap: 8px; padding-left: 4px; }
.slot-rows[hidden] { display: none; }
.slot-row { display: flex; align-items: center; gap: 8px; }
.slot-row .input { flex: 1; }
.slot-rows > .btn { align-self: flex-start; }
/* ---------- 10) ขึ้นปีการศึกษาใหม่ ---------- */
.ny-now { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-radius: 16px; background: var(--paper-2); }
.ny-now > div { display: flex; flex-direction: column; }
.ny-now b { font: 800 20px/1.3 var(--font-display); color: var(--ink); }
.ny-now .is-next b { color: var(--leaf-700); }
.ny-now > .ic { color: var(--muted); }
.ny-preview { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; border: 1.5px solid color-mix(in srgb, var(--leaf) 35%, var(--line)); background: color-mix(in srgb, var(--leaf) 4%, var(--surface)); }
.ny-preview h3 { display: flex; align-items: center; gap: 6px; font-size: 15px; }
.ny-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ny-stats > div { padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.ny-stats b { display: block; font: 800 24px/1.1 var(--font-display); color: var(--ink); }
.ny-stats .bad b { color: #c8452f; }
.ny-list { margin: 0; padding-left: 18px; font-size: 13.5px; display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 560px) { .ny-stats { grid-template-columns: 1fr; } .ny-now { flex-wrap: wrap; } }
/* ---------- 11) แจ้งความคืบหน้า / ตัวเลือกส่งกลับ ---------- */
.modal.wide { width: min(860px, calc(100vw - 24px)); }
.pg-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.pg-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pg-stats > div { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.pg-stats b { display: block; font: 800 18px/1.25 var(--font-display); color: var(--ink); }
.pg-stats .bad b { color: #c8452f; }
.sub-opt { margin-left: 30px; transition: opacity .15s; }
.sub-opt.off, .pg-phone.off { opacity: .45; }
.pg-phone { padding: 14px 12px; border-radius: 18px; background: #8fb3d4; max-height: 420px; overflow: auto; transition: opacity .15s; }
html[data-theme="dark"] .pg-phone { background: #2b3e52; }
.pg-phone .line-bubble { white-space: pre-line; font-size: 13px; }
@media (max-width: 760px) { .pg-grid { grid-template-columns: minmax(0, 1fr); } .pg-stats b { font-size: 15px; } }/* แผนดำเนินงาน สมศ. ในปฏิทิน */
.ecal-onesqa    { --ec: #0f8b8d; --ec-ink: #0b6a6c; }
html[data-theme="dark"] .ecal-onesqa { --ec-ink: #8fe3e4; }
