/* =========================================================
   ระบบนิเทศติดตามการเปิดภาคเรียน — ธีมม่วงพาสเทล (แดชบอร์ด)
   ========================================================= */
:root {
  --app-primary: #6c4ee6;      /* ใช้ร่วมกับหน้าอื่น */
  --app-primary-2: #8b6cff;
  --app-accent: #ffc83d;
  --app-bg: #f5f3fd;
  --ink: #2b2750;
  --muted: #7b789a;
  --line: #ece9f7;
  --sb-w: 270px;
  --radius: 18px;
  --shadow: 0 4px 18px rgba(88, 66, 180, .07), 0 1px 3px rgba(88, 66, 180, .05);
}
html, body { font-family: 'Sarabun', Tahoma, sans-serif; }
body { background: var(--app-bg); color: var(--ink); font-size: .97rem; font-weight: 400; }
a { color: var(--app-primary); }

/* ---------- Sidebar ---------- */
.app-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sb-w); z-index: 1040;
  background: #fff; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 2px 0 18px rgba(88, 66, 180, .07);
  transition: transform .25s ease;
}
.app-sidebar::before {
  content: ''; position: absolute; left: -40px; right: -40px; top: -60px; height: 250px;
  background: radial-gradient(ellipse at 50% 30%, #e7ddff 0%, #f1ecff 55%, rgba(255,255,255,0) 72%);
  border-radius: 0 0 50% 50%; z-index: 0;
}
.sb-brand { position: relative; z-index: 1; display: block; text-align: center; padding: 18px 16px 10px; text-decoration: none; }
.sb-logo { width: 104px; height: 86px; }
.sb-title { font-weight: 600; font-size: 1.25rem; line-height: 1.25; color: #4a35b8; margin-top: 4px; }
.sb-sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.sb-nav { position: relative; z-index: 1; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; flex: 1 1 auto; }
.sb-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 14px;
  color: var(--ink); text-decoration: none; font-weight: 500; font-size: 1.02rem; transition: background .15s;
}
.sb-link:hover { background: #f3efff; color: var(--ink); }
.sb-link.active { background: linear-gradient(90deg, #7a56f0, #9a7bff); color: #fff; box-shadow: 0 6px 16px rgba(122, 86, 240, .32); }
.sb-ico { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; flex: none; }
.sb-link.active .sb-ico { background: rgba(255,255,255,.22) !important; color: #fff !important; }
.sb-label { flex: 1; }
.sb-arrow { font-size: .8rem; opacity: .45; }
.sb-badge { background: #f0445a; color: #fff; font-size: .78rem; min-width: 24px; height: 24px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; font-weight: 600; }
.sb-scene { position: relative; z-index: 1; flex: none; height: 200px; margin-top: auto; background: linear-gradient(180deg, rgba(255,255,255,0), #e8f4ff 40%); }
.sb-scene svg { width: 100%; height: 100%; display: block; }
@media (max-height: 880px) { .sb-scene { display: none; } }
.sb-nav { min-height: 0; }

/* สีไอคอนเมนู */
.ico-violet { background: #efe9ff; color: #7a56f0; }
.ico-green  { background: #e3f7e8; color: #2fa84f; }
.ico-blue   { background: #e4f1ff; color: #2f86e6; }
.ico-indigo { background: #e9ebff; color: #4f5bd5; }
.ico-amber  { background: #fff4d6; color: #f0a500; }
.ico-orange { background: #ffeedd; color: #f07a1a; }
.ico-pink   { background: #ffe6ee; color: #e8457a; }
.ico-purple { background: #f3e6ff; color: #a14ee6; }
.ico-violet-t { color: #7a56f0; } .ico-pink-t { color: #f0446e; }

/* ---------- Shell / Topbar ---------- */
.app-shell { margin-left: var(--sb-w); min-height: 100vh; display: flex; flex-direction: column; }
.app-topbar {
  position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: 14px;
  padding: 12px 24px; background: rgba(245, 243, 253, .88); backdrop-filter: blur(10px);
}
.tb-burger { font-size: 1.5rem; padding: 2px 8px; color: var(--ink); }
.tb-search { flex: 1 1 360px; max-width: 460px; position: relative; }
.tb-search i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.tb-search input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 10px 16px 10px 44px; font-family: inherit; color: var(--ink); outline: none; box-shadow: var(--shadow); }
.tb-search input:focus { border-color: #b9a6ff; box-shadow: 0 0 0 4px rgba(123, 92, 240, .12); }
.tb-date { align-items: center; gap: 8px; font-weight: 500; padding: 0 18px; border-left: 1px solid #dcd6f0; border-right: 1px solid #dcd6f0; white-space: nowrap; }
.tb-date i { color: #7a56f0; font-size: 1.2rem; }
.tb-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.tb-btn { border-radius: 12px; color: #fff !important; font-weight: 500; padding: 8px 16px; display: inline-flex; gap: 8px; align-items: center; border: 0; white-space: nowrap; }
.tb-btn-violet { background: linear-gradient(90deg, #7a56f0, #9671ff); box-shadow: 0 6px 14px rgba(122, 86, 240, .3); }
.tb-btn-green  { background: linear-gradient(90deg, #2fb457, #46c86a); box-shadow: 0 6px 14px rgba(47, 180, 87, .28); }
.tb-btn:hover { filter: brightness(1.06); }
.tb-bell { position: relative; font-size: 1.45rem; color: #7a56f0; padding: 4px 10px; border: 0; }
.tb-dot { position: absolute; top: 0; right: 2px; background: #f0445a; color: #fff; font-size: .66rem; min-width: 18px; height: 18px; line-height: 18px; border-radius: 9px; padding: 0 4px; font-weight: 600; border: 2px solid var(--app-bg); }
.tb-user { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); padding-left: 12px; border-left: 1px solid #dcd6f0; }
.tb-avatar { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, #ffb08a, #f06a9b); color: #fff; font-weight: 600; font-size: 1.15rem; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 3px #fff, 0 3px 10px rgba(240, 106, 155, .35); }
.tb-uname { flex-direction: column; line-height: 1.2; max-width: 190px; }
.tb-uname b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-uname small { color: var(--muted); font-size: .8rem; }
.tb-menu { border: 0; border-radius: 14px; box-shadow: 0 12px 32px rgba(60, 40, 140, .16); min-width: 240px; }
.app-main { flex: 1; padding: 6px 24px 24px; }
.app-footer { color: var(--muted); }

/* จอใหญ่: ย่อเมนูซ้ายเหลือไอคอน */
.app-shell { transition: margin-left .25s ease; }
.app-sidebar { transition: transform .25s ease, width .25s ease; }
@media (min-width: 1200px) {
  .sidebar-mini { --sb-w: 80px; }
  .sidebar-mini .sb-brand { padding: 14px 6px 6px; }
  .sidebar-mini .sb-logo { width: 54px; height: 45px; }
  .sidebar-mini .sb-title, .sidebar-mini .sb-sub, .sidebar-mini .sb-label,
  .sidebar-mini .sb-arrow, .sidebar-mini .sb-scene { display: none; }
  .sidebar-mini .sb-nav { padding: 10px 8px; }
  .sidebar-mini .sb-link { justify-content: center; padding: 9px 0; position: relative; }
  .sidebar-mini .sb-badge { position: absolute; top: 2px; right: 6px; min-width: 18px; height: 18px; font-size: .66rem; padding: 0 4px; }
}

/* บุคคลทั่วไป: ไม่มี sidebar เนื้อหาเต็มจอ + โลโก้เล็กบนแถบด้านบน */
.no-sidebar .app-shell { margin-left: 0 !important; }
.tb-brand-mini { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: #4a35b8; font-weight: 600; font-size: .9rem; line-height: 1.15; white-space: nowrap; }
.tb-brand-mini svg { width: 44px; height: 36px; flex: none; }
/* โลโก้ + ช่องค้นหา + วันที่ อยู่กึ่งกลางแถบบน ส่วนปุ่มเข้าสู่ระบบชิดขวา */
.tb-center { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; flex: 1 1 auto; min-width: 0; }
.no-sidebar .tb-actions { flex: none; margin-left: 12px; }
@media (min-width: 992px) {
  .tb-center { justify-content: center; }
  .no-sidebar .tb-search { flex: 0 1 460px; min-width: 200px; }
}

/* มือถือ / แท็บเล็ต */
.sb-backdrop { display: none; }
@media (max-width: 1199.98px) {
  .app-sidebar { transform: translateX(-100%); max-width: 85vw; }
  .sidebar-open .app-sidebar { transform: none; }
  .sidebar-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(30, 20, 70, .35); z-index: 1035; }
  .app-shell { margin-left: 0; }
}
@media (max-width: 575.98px) {
  .app-topbar { padding: 10px 12px; gap: 8px; }
  .app-main { padding: 4px 12px 16px; }
  .tb-btn { padding: 8px 11px; }
  .tb-user { padding-left: 6px; border: 0; }
}

/* ---------- Card พื้นฐาน (ใช้ทุกหน้า) ---------- */
.card { border: 0; box-shadow: var(--shadow); border-radius: var(--radius); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 600; border-radius: var(--radius) var(--radius) 0 0 !important; }
.btn-primary { --bs-btn-bg: #6c4ee6; --bs-btn-border-color: #6c4ee6; --bs-btn-hover-bg: #5a3dd4; --bs-btn-hover-border-color: #5a3dd4; --bs-btn-active-bg: #4f33c4; }
.btn-outline-primary { --bs-btn-color: #6c4ee6; --bs-btn-border-color: #6c4ee6; --bs-btn-hover-bg: #6c4ee6; --bs-btn-hover-border-color: #6c4ee6; }
.btn-violet { background: linear-gradient(90deg, #7a56f0, #9671ff); color: #fff; border: 0; }
.btn-violet:hover, .btn-violet:disabled { color: #fff; }
.btn-add-doc { background: #fff; border: 1px solid #f0a35a; color: #c9600a; }
.btn-add-doc:hover { background: #fff6ee; border-color: #f07a1a; color: #c9600a; }
.form-control, .form-select { border-color: #e1dcf2; }
.form-control:focus, .form-select:focus { border-color: #b9a6ff; box-shadow: 0 0 0 .2rem rgba(123, 92, 240, .15); }
.alert { border-radius: 14px; border: 0; }
.breadcrumb a { text-decoration: none; }

/* ---------- Dashboard: Hero ---------- */
.dash-hero {
  position: relative; overflow: hidden; border-radius: 22px; min-height: 196px; margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px; padding: 10px 24px 0 6px;
  background:
    radial-gradient(circle at 78% 12%, rgba(255,255,255,.9) 0 26px, transparent 27px),
    radial-gradient(circle at 82% 16%, rgba(255,255,255,.9) 0 20px, transparent 21px),
    radial-gradient(ellipse at 20% 120%, #dccdff 0%, transparent 55%),
    linear-gradient(100deg, #e9e0ff 0%, #f3edff 42%, #eef3ff 70%, #e6f2ff 100%);
  box-shadow: var(--shadow);
}
.hero-teachers { width: 270px; height: 190px; flex: none; align-self: flex-end; }
.hero-text { position: relative; z-index: 2; padding: 14px 0 22px; max-width: 640px; }
.hero-hello { display: inline-block; background: #fff6d8; color: #4a3a12; font-weight: 600; padding: 4px 16px; border-radius: 999px; box-shadow: 0 3px 10px rgba(240, 180, 40, .25); margin-bottom: 8px; }
.dash-hero h1 { font-size: clamp(1.35rem, 2.15vw, 2.15rem); font-weight: 600; line-height: 1.28; color: #2a2160; margin: 0 0 6px; position: relative; }
.dash-hero h1 .hl { color: #2a2160; }
.hero-swoosh { width: 130px; height: 16px; vertical-align: middle; margin-left: 10px; }
.dash-hero p { color: #4f4a78; margin: 0 0 8px; font-size: 1rem; }
.hero-chip { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.75); padding: 3px 12px; border-radius: 999px; font-size: .85rem; color: #5b4bb8; }
.hero-school { position: absolute; right: 150px; bottom: -6px; width: 300px; height: 212px; z-index: 1; }
.hero-clip { position: absolute; right: 8px; top: 12px; width: 170px; height: 162px; z-index: 2; filter: drop-shadow(0 8px 14px rgba(80, 60, 180, .2)); }
.hero-spark { position: absolute; width: 18px; height: 18px; }
.hero-spark.s1 { left: 270px; top: 28px; } .hero-spark.s2 { right: 480px; top: 22px; width: 12px; }
@media (max-width: 1599.98px) { .hero-school { right: 130px; width: 250px; } .hero-teachers { width: 220px; } }
@media (max-width: 1399.98px) { .hero-school { display: none; } .hero-spark.s2 { display: none; } }
@media (max-width: 991.98px)  { .hero-teachers, .hero-spark { display: none; } .dash-hero { padding: 6px 20px 0; } .hero-text { max-width: calc(100% - 150px); } .hero-clip { width: 130px; right: 4px; top: auto; bottom: 8px; } }
@media (max-width: 575.98px)  { .hero-clip { display: none; } .hero-text { max-width: 100%; } .hero-swoosh { display: none; } }

/* ---------- Dashboard: KPI ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.kpi { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-radius: var(--radius); box-shadow: var(--shadow); min-height: 98px; }
.kpi-ico { width: 64px; height: 64px; border-radius: 50%; background: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 2.1rem; flex: none; box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.kpi-ico svg { width: 52px; height: 40px; }
.kpi-main { flex: 1; min-width: 0; }
.kpi-lbl, .kpi-side .kpi-lbl { white-space: nowrap; }
.kpi-lbl { font-weight: 500; color: #3a355f; font-size: .98rem; }
.kpi-num { font-size: 2rem; font-weight: 600; line-height: 1.1; color: #221d4a; white-space: nowrap; }
.kpi-num small { font-size: 1.25rem; font-weight: 500; }
.kpi-side { padding-left: 16px; border-left: 1px solid rgba(0,0,0,.08); text-align: center; }
.kpi-side .kpi-lbl { font-size: .85rem; font-weight: 400; }
.kpi-pct { font-size: 1.6rem; font-weight: 600; }
.kpi-blue   { background: linear-gradient(110deg, #e2f0ff, #eef6ff); }
.kpi-green  { background: linear-gradient(110deg, #ddf6e4, #ecfaef); } .kpi-green .kpi-ico { color: #2fb457; } .kpi-green .kpi-pct { color: #26a14c; }
.kpi-pink   { background: linear-gradient(110deg, #ffe3ea, #fff0f3); } .kpi-pink .kpi-ico { color: #ef5a7a; }  .kpi-pink .kpi-pct { color: #e8456b; }
.kpi-yellow { background: linear-gradient(110deg, #fff1cf, #fff8e6); } .kpi-yellow .kpi-ico { color: #f3a712; }
.kpi-yellow .kpi-side { border: 0; padding-left: 0; }
.kpi-trend { display: inline-flex; align-items: center; gap: 4px; background: #e3f7e8; color: #22984a; font-weight: 600; font-size: .85rem; padding: 2px 10px; border-radius: 999px; }
.kpi-note { color: var(--muted); font-size: .8rem; margin-top: 6px; white-space: nowrap; }
@media (max-width: 1599.98px) { .kpi { padding: 14px 16px; gap: 12px; } .kpi-ico { width: 54px; height: 54px; font-size: 1.75rem; } .kpi-num { font-size: 1.7rem; } .kpi-pct { font-size: 1.35rem; } }
@media (max-width: 1399.98px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 575.98px)  { .kpi-row { grid-template-columns: 1fr; gap: 10px; } }

/* ---------- Dashboard: Grid ---------- */
.dash-grid {
  display: grid; gap: 16px;
  grid-template-columns: 1.45fr 1.05fr 1.05fr;
  grid-template-areas: "check donut alert" "table table table";
}
.g-check { grid-area: check; } .g-donut { grid-area: donut; } .g-alert { grid-area: alert; }
.g-table { grid-area: table; align-self: start; }
.dash-grid.list-only { grid-template-columns: 1fr; grid-template-areas: "table"; }
@media (max-width: 1599.98px) {
  .dash-grid { grid-template-columns: 1.3fr 1fr 1fr; }
}
@media (max-width: 1199.98px) {
  .dash-grid { grid-template-columns: 1fr 1fr; grid-template-areas: "check check" "donut alert" "table table"; }
}
@media (max-width: 767.98px) {
  .dash-grid { grid-template-columns: 1fr; grid-template-areas: "check" "donut" "alert" "table"; }
}

.dcard { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; scroll-margin-top: 80px; }
.dcard-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: -16px -18px 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dcard-h > span { font-weight: 600; font-size: 1.02rem; white-space: nowrap; min-width: 0; display: flex; align-items: center; gap: 10px; }
.dcard-h > span i { font-size: 1.35rem; }
.dcard-h a { font-size: .85rem; text-decoration: none; color: #7a56f0; white-space: nowrap; }

/* เช็กลิสต์รายด้าน */
.check-list { display: flex; flex-direction: column; gap: 4px; }
.check-row { display: grid; grid-template-columns: 34px minmax(0, 1.25fr) minmax(70px, 1fr) 44px; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.check-row:hover { background: #f7f5ff; color: var(--ink); }
.ck-ico { width: 32px; height: 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; }
.ck-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .93rem; }
.ck-bar { height: 12px; border-radius: 999px; background: #eef0f6; overflow: hidden; }
.ck-bar span { display: block; height: 100%; border-radius: 999px; min-width: 0; transition: width .6s ease; }
.ck-pct { text-align: right; font-weight: 500; font-size: .93rem; }
.bg-orange { background: #ffeedd; color: #f07a1a; } .fill-orange { background: linear-gradient(90deg, #ffa24c, #f07a1a); }
.bg-blue   { background: #e4f1ff; color: #2f86e6; } .fill-blue   { background: linear-gradient(90deg, #5aaeff, #2f86e6); }
.bg-purple { background: #efe9ff; color: #7a56f0; } .fill-purple { background: linear-gradient(90deg, #a68bff, #7a56f0); }
.bg-amber  { background: #fff4d6; color: #e59a00; } .fill-amber  { background: linear-gradient(90deg, #ffd166, #f5b120); }
.bg-pink   { background: #ffe6ee; color: #e8457a; } .fill-pink   { background: linear-gradient(90deg, #ff8fb1, #ef5a8a); }
.bg-teal   { background: #dcf7f3; color: #17a596; } .fill-teal   { background: linear-gradient(90deg, #4fd8c6, #19b3a2); }
.bg-indigo { background: #e9ebff; color: #4f5bd5; } .fill-indigo { background: linear-gradient(90deg, #8a93ff, #4f5bd5); }
.bg-cyan   { background: #ddf3fb; color: #1592c4; } .fill-cyan   { background: linear-gradient(90deg, #5fd0f5, #1aa3d8); }
.bg-lime   { background: #eef8d9; color: #6a9a10; } .fill-lime   { background: linear-gradient(90deg, #b5e25a, #82bd1d); }
.grp-tag { display: inline-block; font-size: .75rem; font-weight: 500; background: #fff; color: #7a56f0; border: 1px solid #ddd3ff; border-radius: 999px; padding: 0 8px; margin-right: 6px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.bg-green  { background: #e3f7e8; color: #2fa84f; } .fill-green  { background: linear-gradient(90deg, #6fd88a, #2fb457); }

/* โดนัท */
.donut-wrap { display: flex; align-items: center; gap: 14px; height: calc(100% - 46px); }
.donut { width: 160px; height: 160px; flex: none; }
.donut-lbl { font-size: 2.6px; font-weight: 600; fill: #fff; text-anchor: middle; font-family: Sarabun, sans-serif; }
.donut-num { font-size: 7.5px; font-weight: 600; fill: #221d4a; text-anchor: middle; font-family: Sarabun, sans-serif; }
.donut-unit { font-size: 3.2px; fill: #6b6890; text-anchor: middle; font-family: Sarabun, sans-serif; }
.donut-legend { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.donut-legend a { display: grid; grid-template-columns: 14px 1fr; column-gap: 8px; text-decoration: none; color: var(--ink); line-height: 1.25; }
.donut-legend i { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; grid-row: span 2; }
.donut-legend b { font-weight: 500; }
.donut-legend b, .donut-legend small { white-space: nowrap; }
.donut-legend small { color: var(--muted); font-size: .8rem; }
@media (max-width: 1799.98px) { .donut { width: 132px; height: 132px; } .donut-wrap { gap: 10px; } }

/* แจ้งเตือน */
.g-alert { display: flex; flex-direction: column; }
.g-alert .alert-tile { flex: 1; }
.alert-tile { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; text-decoration: none; color: var(--ink); margin-bottom: 10px; transition: transform .12s; }
.alert-tile:last-child { margin-bottom: 0; }
.alert-tile:hover { transform: translateX(3px); color: var(--ink); }
.alert-tile > span { flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.at-t { font-size: .92rem; }
.alert-tile b { font-size: 1.15rem; font-weight: 600; }
.at-ico { font-size: 1.7rem; width: 40px; text-align: center; }
.at-pink   { background: #fff0f3; } .at-pink b, .at-pink .at-ico { color: #e8456b; }
.at-blue   { background: #edf5ff; } .at-blue b, .at-blue .at-ico { color: #2f7fe0; }
.at-yellow { background: #fff7e3; } .at-yellow b { color: #e08a00; } .at-yellow .at-ico { color: #f5b120; }

/* ปฏิทิน */
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cal-head a { color: #7a56f0; padding: 2px 8px; border-radius: 8px; }
.cal-head a:hover { background: #f3efff; }
.cal-head b { font-weight: 500; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 4px; text-align: center; }
.cal-dow { font-weight: 600; font-size: .85rem; padding: 4px 0; color: #3a355f; background: #f6f4fd; }
.cal-dow:first-child { border-radius: 8px 0 0 8px; } .cal-dow:nth-child(7) { border-radius: 0 8px 8px 0; }
.cal-dow.sun { color: #f07a1a; } .cal-dow.sat { color: #7a56f0; }
.cal-d { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; margin: 0 auto; border-radius: 50%; font-size: .92rem; color: var(--ink); text-decoration: none; }
.cal-d.muted { color: #b9b6cc; }
a.cal-d:hover { background: #f3efff; }
.cal-d.today { background: linear-gradient(135deg, #7a56f0, #9a7bff); color: #fff; font-weight: 600; box-shadow: 0 4px 10px rgba(122, 86, 240, .35); }
.cal-d .dot { position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%); width: 6px; height: 6px; border-radius: 50%; }
.cal-d .dot.ok { background: #2fb457; } .cal-d .dot.warn { background: #f5b120; }
.cal-d.today .dot { background: #fff; }
.cal-today { margin-top: 12px; }
.ct-h { background: #f1ecff; color: #4a35b8; font-weight: 500; padding: 7px 12px; border-radius: 10px; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.ct-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; text-decoration: none; color: var(--ink); border-radius: 8px; font-size: .9rem; }
.ct-row:hover { background: #f7f5ff; color: var(--ink); }
.ct-row > i { color: #7a56f0; }
.ct-row span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-row small { color: var(--muted); white-space: nowrap; }
.ct-row small.ct-ok { color: #26a14c; } .ct-row small.ct-warn { color: #e08a00; }
.ct-empty { color: var(--muted); text-align: center; padding: 12px 0; font-size: .9rem; }

/* ตารางตัวชี้วัด */
.tbl-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.seg { display: inline-flex; flex-wrap: wrap; background: #f4f2fb; border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 9px; font-size: .86rem; color: #514c78; font-family: inherit; }
.seg button b { font-weight: 600; margin-left: 2px; }
.seg button.active { background: #fff; color: #5a3dd4; box-shadow: 0 2px 6px rgba(88, 66, 180, .15); }
.tbl-sec { width: auto; min-width: 150px; max-width: 240px; border-radius: 10px; }
.tbl-chip { display: inline-flex; align-items: center; gap: 6px; background: #efe9ff; color: #4a35b8; border-radius: 999px; padding: 3px 6px 3px 12px; font-size: .85rem; max-width: 100%; }
.tbl-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl-chip button { border: 0; background: #fff; border-radius: 50%; width: 20px; height: 20px; line-height: 18px; padding: 0; color: #7a56f0; }
.tbl-scroll { max-height: 560px; overflow: auto; margin: 0 -18px -16px; padding: 0 18px 12px; }
.g-table.expanded .tbl-scroll { max-height: none; }
/* รายการตัวชี้วัด (แบบรายการ) */
.ilist { display: flex; flex-direction: column; gap: 8px; }
.ilist .grp-row { background: linear-gradient(90deg, #7a56f0, #9a7bff); color: #fff; font-weight: 500; font-size: .9rem; padding: 7px 12px; border-radius: 10px; margin-top: 6px; }
.ilist .cat-row { display: flex; justify-content: space-between; align-items: center; background: #f6f3ff; color: #4a35b8; font-weight: 500; padding: 8px 12px; border-radius: 10px; margin-top: 4px; }
.cat-print { color: #7a56f0; }
.ii { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-left: 4px solid #c9bdf5; border-radius: 12px; transition: box-shadow .15s, background .3s; }
.ii:hover { box-shadow: 0 4px 14px rgba(88, 66, 180, .1); }
.ii-practiced { border-left-color: #3dbb5d; }
.ii-not { border-left-color: #f7b928; }
.ii-code { flex: none; min-width: 42px; margin-top: 1px; text-align: center; font-weight: 600; color: #5a3dd4; background: #f3efff; border-radius: 8px; padding: 4px 6px; font-size: .9rem; }
.ii-main { flex: 1; min-width: 0; }
.ii-title { color: var(--ink); text-decoration: none; display: block; line-height: 1.45; }
.ii-title:hover { color: #5a3dd4; }
.ii-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; font-size: .84rem; color: var(--muted); }
.ii-thumbs { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 6px; padding-left: 54px; /* ตรงกับชื่อตัวชี้วัด (รหัส 42px + ช่องว่าง 12px) */ }
.ii-thumbs img { width: 200px; height: 123px; max-width: 100%; object-fit: cover; border-radius: 8px; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(60, 40, 140, .18); cursor: zoom-in; transition: transform .12s; }
.ii-thumbs img:hover { transform: scale(1.05); }
.thumbs-xl .ii-thumbs img { width: 400px; height: 246px; } /* สวิตช์ "ภาพใหญ่" = 2 เท่า */
.tb-switch { align-items: center; gap: 6px; cursor: pointer; color: var(--ink); font-weight: 500; white-space: nowrap; padding-left: 14px; border-left: 1px solid #dcd6f0; }
.tb-switch .form-check-input { width: 2.4em; height: 1.3em; cursor: pointer; margin: 0; }
.tb-switch .form-check-input:checked { background-color: #7a56f0; border-color: #7a56f0; }
.tb-switch i { color: #7a56f0; }
.ii-acts { flex: none; display: flex; align-items: center; gap: 6px; }
.ii-btn { display: inline-flex; align-items: center; gap: 5px; border: 1px solid #e1dcf2; background: #fff; color: #514c78; border-radius: 10px; padding: 6px 10px; font-size: .88rem; font-family: inherit; white-space: nowrap; cursor: pointer; }
span.ii-btn { cursor: default; }
.ii-btn b { font-weight: 600; min-width: 18px; height: 18px; line-height: 18px; text-align: center; border-radius: 9px; background: #f1effa; color: #8a86a8; font-size: .75rem; padding: 0 5px; }
.ii-rec { background: linear-gradient(90deg, #7a56f0, #9671ff); border-color: transparent; color: #fff; }
.ii-rec:hover { filter: brightness(1.07); }
.ii-doc { background: #faf9ff; border-color: #ece9f7; color: #6b6890; } /* แสดงจำนวนอย่างเดียว ไม่ใช่ปุ่ม */
a.ii-print { text-decoration: none; color: #4a35b8; border-color: #c9bdf5; background: #fff; }
a.ii-print:hover { background: #f3efff; border-color: #7a56f0; color: #4a35b8; }
.ii-doc.has b { background: #f07a1a; color: #fff; }
.ii-ico { color: #6b6890; font-size: 1.08rem; padding: 4px 6px; border-radius: 8px; }
.ii-ico:hover { background: #f1ecff; color: #5a3dd4; }
.ii.uploading { opacity: .6; pointer-events: none; }
.ii.flash-row { background: #fffbe6; box-shadow: 0 0 0 2px #ffd666; }
mark.hl { background: #ffe66d; color: inherit; padding: 0 2px; border-radius: 3px; } /* ไฮไลต์คำค้น */
@media (max-width: 991.98px) {
  .ii-acts { width: 100%; padding-left: 54px; flex-wrap: wrap; }
}
@media (max-width: 575.98px) {
  .ii-acts, .ii-thumbs { padding-left: 0; }
  .ii-btn span { display: none; }
  .ii-rec span { display: inline; }
}
.st-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 11px; font-size: .84rem; font-weight: 500; white-space: nowrap; }
.st-ok   { background: #e3f7e8; color: #1f9346; }
.st-warn { background: #fff1d1; color: #b86e00; } .st-warn i { color: #f5a300; }
.st-wait { background: #efe9ff; color: #6a4be0; }

/* อัปโหลดด่วน */
.kind-pick { display: flex; gap: 6px; }
.kind-pick label { flex: 1; text-align: center; border: 1px solid #e1dcf2; border-radius: 10px; padding: 5px 6px; font-size: .86rem; cursor: pointer; color: #514c78; }
.kind-pick .btn-check:checked + label { background: #efe9ff; border-color: #a68bff; color: #4a35b8; font-weight: 500; }
.dz-dash { border: 2px dashed #c9bdf5 !important; background: #fbfaff !important; padding: 16px 12px !important; color: #5b5680; font-size: .9rem; }
.dz-dash > i { font-size: 2.2rem; color: #4f7ff0; line-height: 1; }
.dz-dash b { color: #4a35b8; }
.dz-dash small { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; }
/* ไฟล์ที่แนบแล้วใน popup */
.q-files { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.qf { position: relative; }
.qf.deleting { opacity: .4; }
.qf-img a { display: block; width: 130px; aspect-ratio: 340 / 220; border-radius: 8px; overflow: hidden; border: 1px solid #e1dcf2; background: #f4f2fb; }
.qf-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.qf-dl { position: absolute; top: 50%; right: 32px; transform: translateY(-50%); width: 26px; height: 26px; border-radius: 50%; background: #2f86e6; color: #fff; font-size: .8rem; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; box-shadow: 0 2px 6px rgba(47, 134, 230, .35); }
.qf-dl:hover { background: #1f6fc4; color: #fff; }
.qf-img .qf-dl { top: -7px; right: 22px; transform: none; width: 24px; height: 24px; border: 2px solid #fff; } /* ภาพถ่ายเอกสาร: วางคู่กับปุ่มลบที่มุมบน */
.qf-doc > a:first-child { display: flex; align-items: center; gap: 6px; max-width: 240px; height: 100%; padding: 6px 64px 6px 10px; border: 1px solid #e1dcf2; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: .85rem; background: #fff; }
.qf-doc > a:first-child i { color: #f07a1a; font-size: 1.1rem; }
.qf-doc > a:first-child span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qf-del { position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: #f0445a; color: #fff; font-size: .7rem; display: inline-flex; align-items: center; justify-content: center; padding: 0; box-shadow: 0 2px 6px rgba(240, 68, 90, .35); }
.qf-del:hover { background: #d6303f; }
.qf-doc .qf-del { top: 50%; right: 4px; transform: translateY(-50%); }
/* popup เลือกเอกสาร */
.doc-pick-list li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; font-size: .9rem; background: #fff; }
.doc-pick-list li span { min-width: 0; }
/* ครอบภาพ 750×460 */
.crop-pick { position: relative; aspect-ratio: 750 / 460; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.crop-pick > i { font-size: 2.4rem; color: #7a56f0; }
.crop-pick .cp-steps { margin-top: 6px; color: #7a56f0; font-size: .74rem; }
.cp-corner { position: absolute; width: 18px; height: 18px; border: 0 solid #7a56f0; }
.cp-corner.tl { top: 8px; left: 8px; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 4px; }
.cp-corner.tr { top: 8px; right: 8px; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 4px; }
.cp-corner.bl { bottom: 8px; left: 8px; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 4px; }
.cp-corner.br { bottom: 8px; right: 8px; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 4px; }
.crop-editor { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.crop-main { flex: 1 1 380px; min-width: 0; }
.crop-side { flex: 0 0 210px; }
.crop-area { position: relative; display: inline-block; max-width: 100%; line-height: 0; border-radius: 10px; overflow: hidden; background: #1d1838; user-select: none; touch-action: none; }
.crop-area img { display: block; max-width: 100%; max-height: 440px; pointer-events: none; }
.crop-frame { position: absolute; box-sizing: border-box; border: 2px solid #fff; cursor: move; box-shadow: 0 0 0 9999px rgba(20, 10, 50, .55);
  background-image: linear-gradient(to right, rgba(255,255,255,.35) 1px, transparent 1px), linear-gradient(to bottom, rgba(255,255,255,.35) 1px, transparent 1px);
  background-size: 33.34% 100%, 100% 33.34%; background-position: -1px 0, 0 -1px; }
.crop-tag { position: absolute; left: 6px; top: 6px; background: rgba(122, 86, 240, .9); color: #fff; font-size: .7rem; line-height: 1; padding: 3px 6px; border-radius: 6px; pointer-events: none; }
.ch { position: absolute; width: 18px; height: 18px; background: #fff; border: 3px solid #7a56f0; border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.ch[data-h="nw"] { top: -9px; left: -9px; cursor: nwse-resize; }
.ch[data-h="ne"] { top: -9px; right: -9px; cursor: nesw-resize; }
.ch[data-h="sw"] { bottom: -9px; left: -9px; cursor: nesw-resize; }
.ch[data-h="se"] { bottom: -9px; right: -9px; cursor: nwse-resize; }
.crop-preview { display: block; width: 100%; aspect-ratio: 750 / 460; border-radius: 8px; border: 1px solid var(--line); background: #f4f2fb; }
.crop-done { border: 2px solid #3dbb5d; border-radius: 12px; padding: 10px; background: #f3fbf5; }
.crop-result { display: block; width: 100%; max-width: 390px; margin: 0 auto; aspect-ratio: 750 / 460; border-radius: 8px; background: #fff; box-shadow: 0 2px 8px rgba(60, 40, 140, .15); }
@media (max-width: 575.98px) { .crop-side { flex: 1 1 100%; } }
.recent-imgs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.ri { position: relative; display: block; border-radius: 12px; overflow: hidden; border: 3px solid #fff; box-shadow: 0 3px 10px rgba(60, 40, 140, .15); aspect-ratio: 4 / 3; background: #f1effa; }
.ri img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ri-ok { position: absolute; right: 4px; bottom: 4px; width: 22px; height: 22px; border-radius: 50%; background: #2fb457; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; border: 2px solid #fff; }
.ri-code { position: absolute; left: 4px; top: 4px; background: rgba(43, 39, 80, .7); color: #fff; font-size: .72rem; padding: 0 6px; border-radius: 6px; }

/* ---------- หน้าอื่น ๆ (เดิม) ---------- */
.brand-icon { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; background: var(--app-accent); color: #1f1f1f; border-radius: .5rem; font-size: 1.1rem; }
.stat-card { border-left: 5px solid var(--app-primary-2); }
.stat-card .stat-num { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.section-title { background: linear-gradient(90deg, #6c4ee6, #8b6cff); color: #fff; padding: .55rem 1rem; border-radius: .8rem; font-weight: 500; }
.cat-title { background: #f1ecff; color: #4a35b8; font-weight: 600; }
.table-indicators td, .table-indicators th { vertical-align: middle; }
.table-indicators .code { white-space: nowrap; font-weight: 600; color: var(--app-primary); }
.table-indicators tr.pending td { background: #fffdf4; }

.login-bg { min-height: 100vh; background: linear-gradient(135deg, #6c4ee6 0%, #8b6cff 55%, #b9a6ff 100%); display: flex; align-items: center; }
.login-card { max-width: 440px; width: 100%; margin: auto; border-radius: 1.25rem; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .9rem; }
.gallery .g-item { position: relative; background: #fff; border: 1px solid #e7e3f5; border-radius: .8rem; overflow: hidden; }
.gallery .g-item img { width: 100%; height: 150px; object-fit: cover; display: block; cursor: zoom-in; }
.gallery .g-item .g-cap { font-size: .85rem; padding: .4rem .5rem; border-top: 1px solid var(--line); min-height: 2.2rem; }
.gallery .g-item .g-del { position: absolute; top: .35rem; right: .35rem; }
.doc-list .doc-item { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border: 1px solid #e7e3f5; border-radius: .8rem; background: #fff; margin-bottom: .5rem; }
.doc-list .doc-item .doc-ico { font-size: 1.8rem; }
.doc-list .doc-item .doc-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: .35rem; border: 1px solid #e7e3f5; }
.doc-list .doc-item .doc-name { flex: 1; min-width: 0; }
.doc-list .doc-item .doc-name .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dropzone { border: 2px dashed #c9bdf5; border-radius: .9rem; padding: 1.2rem; text-align: center; background: #fbfaff; cursor: pointer; transition: .15s; }
.dropzone:hover, .dropzone.drag { border-color: #7a56f0; background: #f3efff; }
.dropzone .dz-list { text-align: left; font-size: .88rem; margin-top: .6rem; }

.status-pick .form-check { padding: .6rem .9rem .6rem 2.2rem; border: 1px solid #e1dcf2; border-radius: .8rem; margin-right: .6rem; background: #fff; }
.status-pick .form-check:has(input:checked) { border-color: #8b6cff; background: #f3efff; }

.sortable-handle { cursor: grab; color: #9aa5b1; }
.table-manage td { vertical-align: middle; }

.lightbox { position: fixed; inset: 0; background: rgba(20, 14, 50, .88); z-index: 2000; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.lightbox img { max-width: 95vw; max-height: 85vh; border-radius: .4rem; box-shadow: 0 0 30px rgba(0,0,0,.6); }
.lightbox .lb-cap { color: #fff; margin-top: .75rem; font-size: 1.05rem; }
.lightbox .lb-close { position: absolute; top: 1rem; right: 1.2rem; color: #fff; font-size: 2rem; cursor: pointer; }

@media (max-width: 575px) {
  .gallery { grid-template-columns: repeat(2, 1fr); }
}
