/* Smart Office — premium modern, ยึดมาตรฐาน UI แบบไทย: Noto Sans Thai (ตามระบบ OPC) · Primary #0D6EFD · Navbar 60px · Sidebar 260px · การ์ดโค้ง 12px+
   ใช้ตัวแปรสีทั้งหมด (รองรับโหมดมืดผ่าน data-bs-theme) */
:root {
  --so-primary: #0d6efd; --so-primary-2: #0a58ca; --so-primary-soft: rgba(13, 110, 253, .10);
  --so-success: #198754; --so-warning: #ffc107; --so-danger: #dc3545; --so-info: #0dcaf0; --so-secondary: #6c757d;
  --so-bg: #f3f6fb; --so-surface: #ffffff; --so-surface-2: #f8fafd; --so-text: #172033; --so-muted: #667085; --so-border: #e4e9f2;
  --so-side-1: #0b2f6b; --so-side-2: #08224f; --so-side-text: #e8efff;
  --so-shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --so-shadow: 0 4px 12px rgba(16, 24, 40, .06), 0 12px 32px rgba(16, 24, 40, .06);
  --so-radius: 14px;
  --bs-font-sans-serif: 'Noto Sans Thai', 'Sarabun', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --bs-body-font-family: var(--bs-font-sans-serif);
  --bs-primary: #0d6efd; --bs-primary-rgb: 13, 110, 253; --bs-link-color: #0d6efd;
}
[data-bs-theme='dark'] {
  --so-primary-soft: rgba(91, 156, 255, .16);
  --so-bg: #0b1220; --so-surface: #121b2e; --so-surface-2: #172238; --so-text: #e6ecf8; --so-muted: #9aa8c2; --so-border: #25324d;
  --so-side-1: #0a1630; --so-side-2: #070f22;
  --so-shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --so-shadow: 0 8px 28px rgba(0, 0, 0, .45);
  --bs-body-bg: #0b1220; --bs-body-color: #e6ecf8; --bs-border-color: #25324d;
}
* { -webkit-tap-highlight-color: transparent; }
html, body { font-family: var(--bs-font-sans-serif); }
body { background: var(--so-bg); color: var(--so-text); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body::before { /* แสงนุ่มด้านบนให้พื้นหลังมีมิติ */
  content: ''; position: fixed; inset: 0 0 auto 0; height: 420px; z-index: -1; pointer-events: none;
  background: radial-gradient(900px 320px at 80% -80px, rgba(13, 110, 253, .13), transparent 70%), radial-gradient(700px 300px at 10% -100px, rgba(111, 66, 193, .08), transparent 70%);
}
h1, h2, h3, h4, h5 { letter-spacing: -.01em; }
h1 { font-size: 21px; font-weight: 700; } h2 { font-size: 18px; font-weight: 600; } h3 { font-size: 16px; font-weight: 600; }
.small, small { font-size: 12.5px; }
.text-muted { color: var(--so-muted) !important; }
a { text-decoration: none; }

/* ---------- Navbar 60px ---------- */
.so-nav {
  position: fixed; inset: 0 0 auto 0; height: 60px; z-index: 1030; color: #fff; display: flex; align-items: center; gap: .6rem; padding: 0 1rem 0 .9rem;
  background: linear-gradient(100deg, #0d6efd 0%, #0b5ed7 55%, #0a4fb8 100%); box-shadow: 0 1px 0 rgba(255, 255, 255, .14) inset, 0 6px 20px rgba(13, 110, 253, .28);
}
.so-nav .brand { display: flex; align-items: center; gap: .65rem; color: #fff; font-weight: 600; min-width: 0; }
.so-nav .brand img, .so-nav .brand .logo-ph { height: 38px; width: 38px; border-radius: 11px; flex: none; }
.so-nav .brand img { object-fit: contain; background: #fff; padding: 3px; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
.so-nav .brand .logo-ph { display: grid; place-items: center; font-size: 1.25rem; background: rgba(255, 255, 255, .18); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }
.so-nav .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; line-height: 1.15; }
.so-nav .sys { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; padding: .15rem .6rem; border-radius: 999px; background: rgba(255, 255, 255, .16); white-space: nowrap; }
.so-nav .grow { flex: 1; }
.so-nav .btn-nav { color: #fff; background: transparent; border: 0; padding: 0; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; position: relative; transition: background .15s; }
.so-nav .btn-nav:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.so-nav .badge-dot { position: absolute; top: 3px; right: 1px; font-size: 10.5px; border: 2px solid #0b5ed7; }
.so-nav .who { display: flex; align-items: center; gap: .6rem; padding-left: .5rem; margin-left: .2rem; border-left: 1px solid rgba(255, 255, 255, .25); }
.so-nav .who .av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: #fff; color: var(--so-primary); box-shadow: 0 2px 8px rgba(0, 0, 0, .18); }
.so-nav .who .tx { font-size: 13px; line-height: 1.15; font-weight: 600; }
.so-nav .who .tx small { display: block; font-weight: 400; opacity: .82; font-size: 12px; }

/* ---------- Sidebar 260px ---------- */
.so-side {
  position: fixed; top: 60px; bottom: 0; left: 0; width: 260px; z-index: 1020; overflow-y: auto; padding: .9rem .7rem 2rem; color: var(--so-side-text);
  background: radial-gradient(420px 260px at 0 0, rgba(13, 110, 253, .35), transparent 70%), linear-gradient(180deg, var(--so-side-1), var(--so-side-2));
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .25) transparent;
}
.so-side .grp { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; opacity: .55; padding: 1.1rem .8rem .4rem; font-weight: 600; }
.so-side a, .so-side .off { display: flex; align-items: center; gap: .75rem; padding: .55rem .7rem; margin: 2px 0; color: var(--so-side-text); font-size: 13.5px; border-radius: 11px; position: relative; transition: background .15s, transform .15s; }
.so-side a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.so-side a.active { background: linear-gradient(90deg, rgba(13, 110, 253, .95), rgba(13, 110, 253, .55)); color: #fff; font-weight: 600; box-shadow: 0 6px 16px rgba(13, 110, 253, .35); }
.so-side .off { opacity: .42; cursor: not-allowed; }
.so-side .off em { margin-left: auto; white-space: nowrap; flex: none; font-style: normal; font-size: 10.5px; padding: .05rem .5rem; border-radius: 999px; background: rgba(255, 255, 255, .12); }
.so-side .ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-size: 1rem; background: rgba(255, 255, 255, .09); flex: none; }
.so-side a.active .ic { background: rgba(255, 255, 255, .22); }

.so-main { margin-left: 260px; padding: 84px 1.75rem 2rem; min-height: calc(100vh - 56px); max-width: 1480px; animation: so-fade .35s ease both; }
.so-foot { margin-left: 260px; padding: 0 1.75rem 1.5rem; color: var(--so-muted); font-size: 13px; }
@keyframes so-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 991.98px) {
  .so-side { transform: translateX(-102%); transition: transform .25s ease; box-shadow: 8px 0 30px rgba(0, 0, 0, .35); }
  .so-side.open { transform: none; }
  .so-main, .so-foot { margin-left: 0; padding-left: 14px; padding-right: 14px; }
  .so-nav .who .tx, .so-nav .sys { display: none; }
  h1 { font-size: 19px; }
}
.so-scrim { position: fixed; inset: 60px 0 0 0; background: rgba(8, 16, 36, .5); backdrop-filter: blur(2px); z-index: 1010; display: none; }
.so-scrim.show { display: block; }

/* ---------- ส่วนหัวหน้า ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1.1rem; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--so-muted); margin: .15rem 0 0; font-size: 13px; }
.so-main > h1 { margin-bottom: .35rem; }
.so-main > h1 + p.text-muted { margin-bottom: 1.1rem; max-width: 70ch; }

/* ---------- การ์ด ---------- */
.card { background: var(--so-surface); border: 1px solid var(--so-border); border-radius: var(--so-radius); box-shadow: var(--so-shadow-sm); }
.card .card-body { padding: 1.25rem; }
.card h2.h5 { font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.card h2.h5 > i { width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; background: var(--so-primary-soft); color: var(--so-primary); font-size: 1rem; }

.hero { position: relative; overflow: hidden; border: 0; color: #fff; border-radius: 20px; padding: 1.6rem 1.75rem; margin-bottom: 1.25rem;
  background: radial-gradient(500px 220px at 90% 0, rgba(255, 255, 255, .22), transparent 70%), radial-gradient(420px 260px at 0 110%, rgba(111, 66, 193, .55), transparent 70%), linear-gradient(120deg, #0d6efd 0%, #0b4fb8 55%, #0a3a8a 100%);
  box-shadow: 0 14px 34px rgba(13, 110, 253, .32); }
.hero::after { content: ''; position: absolute; right: -40px; bottom: -70px; width: 260px; height: 260px; border-radius: 50%; border: 36px solid rgba(255, 255, 255, .07); }
.hero h1 { font-size: 21px; margin: 0 0 .2rem; }
.hero p { margin: 0; opacity: .9; }
.hero .chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.hero .chip { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .8rem; border-radius: 999px; background: rgba(255, 255, 255, .16); font-size: 14px; backdrop-filter: blur(6px); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22); }

.stat { display: flex; flex-direction: row; align-items: center; gap: 1rem; padding: 1.1rem 1.2rem; transition: transform .18s, box-shadow .18s; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--so-shadow); }
.stat .ic { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; font-size: 1.5rem; color: #fff; background: linear-gradient(135deg, var(--c1, #0d6efd), var(--c2, #5b9cff)); box-shadow: 0 8px 18px color-mix(in srgb, var(--c1, #0d6efd) 40%, transparent); }
.stat .num { font-size: 24px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }

.mod-card { display: flex; flex-direction: row; align-items: center; gap: .85rem; padding: .85rem 1rem; color: inherit; transition: transform .18s, box-shadow .18s, border-color .18s; height: 100%; }
a.mod-card:hover { transform: translateY(-2px); box-shadow: var(--so-shadow); border-color: color-mix(in srgb, var(--m, #0d6efd) 45%, var(--so-border)); }
.mod-card .mi { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 1.25rem; flex: none; color: var(--m, #0d6efd); background: color-mix(in srgb, var(--m, #0d6efd) 13%, transparent); }
.mod-card .mt { font-weight: 600; line-height: 1.25; }
.mod-card .ms { font-size: 12px; color: var(--so-muted); }
.mod-card.off { opacity: .6; pointer-events: none; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: .05rem .55rem; border-radius: 999px; background: var(--so-primary-soft); color: var(--so-primary); }

.notif { transition: background .15s; }
.notif:hover { background: var(--so-surface-2); }
.notif.unread { background: var(--so-primary-soft); box-shadow: inset 4px 0 0 var(--so-primary); }
.list-group-item { background: transparent; border-color: var(--so-border); }

/* ---------- ฟอร์ม/ปุ่ม ---------- */
.form-label { font-weight: 600; font-size: 14.5px; margin-bottom: .3rem; }
.form-label.req::after { content: ' *'; color: var(--so-danger); }
.form-control, .form-select { min-height: 38px; font-size: 14px; border-radius: 11px; border-color: var(--so-border); background-color: var(--so-surface); color: var(--so-text); }
.form-control:focus, .form-select:focus { border-color: var(--so-primary); box-shadow: 0 0 0 4px rgba(13, 110, 253, .16); }
.form-control:disabled, .form-select:disabled { background: var(--so-surface-2); }
.form-text { color: var(--so-muted); }
.btn { min-height: 36px; font-size: 14px; border-radius: 11px; font-weight: 500; padding-inline: 1rem; transition: transform .12s, box-shadow .15s, background .15s; }
.btn:active { transform: translateY(1px); }
.btn-sm { min-height: 30px; font-size: 13px; padding-inline: .75rem; border-radius: 9px; }
.btn-save, .btn-edit, .btn-del, .btn-cancel { color: #fff; border: 0; box-shadow: 0 4px 12px rgba(16, 24, 40, .14); }
.btn-save { background: linear-gradient(135deg, #1a9d62, #198754); } .btn-save:hover { color: #fff; filter: brightness(1.07); box-shadow: 0 6px 16px rgba(25, 135, 84, .35); }
.btn-edit { background: linear-gradient(135deg, #2f80ff, #0d6efd); } .btn-edit:hover { color: #fff; filter: brightness(1.07); box-shadow: 0 6px 16px rgba(13, 110, 253, .38); }
.btn-del { background: linear-gradient(135deg, #e5484d, #dc3545); } .btn-del:hover { color: #fff; filter: brightness(1.07); }
.btn-cancel { background: linear-gradient(135deg, #7b8794, #6c757d); } .btn-cancel:hover { color: #fff; filter: brightness(1.07); }
.btn:focus-visible { outline: 3px solid rgba(13, 110, 253, .45); outline-offset: 2px; }
.form-check-input:checked { background-color: var(--so-primary); border-color: var(--so-primary); }
.form-switch .form-check-input { width: 2.4em; height: 1.3em; }

/* ---------- ตาราง ---------- */
.table { --bs-table-bg: transparent; --bs-table-color: var(--so-text); --bs-table-border-color: var(--so-border); margin-bottom: 0; }
.table > thead > tr > th { font-size: 12.5px; font-weight: 600; color: var(--so-muted); background: var(--so-surface-2); border-bottom: 1px solid var(--so-border); white-space: nowrap; padding: .7rem .75rem; }
.table > thead > tr > th:first-child { border-top-left-radius: 10px; } .table > thead > tr > th:last-child { border-top-right-radius: 10px; }
.table > tbody > tr > td { font-size: 13.5px; padding: .6rem .7rem; vertical-align: middle; }
.table-hover > tbody > tr:hover > * { --bs-table-hover-bg: var(--so-primary-soft); }
.table-responsive { -webkit-overflow-scrolling: touch; }
.badge { font-weight: 600; padding: .38em .7em; border-radius: 999px; }
.perm-table th, .perm-table td { text-align: center; }
.perm-table th:first-child, .perm-table td:first-child { text-align: left; }
.perm-table input[type=checkbox] { width: 1.3rem; height: 1.3rem; cursor: pointer; accent-color: var(--so-primary); }
div.dataTables_wrapper div.dataTables_filter input, div.dataTables_wrapper div.dataTables_length select { min-height: 38px; border-radius: 10px; }
.page-link { border-radius: 9px !important; margin: 0 2px; border: 0; color: var(--so-text); background: transparent; }
.page-item.active .page-link { background: var(--so-primary); color: #fff; box-shadow: 0 4px 10px rgba(13, 110, 253, .35); }

.alert { border-radius: 12px; border: 0; }
.swal2-popup { font-family: var(--bs-font-sans-serif); border-radius: 18px; background: var(--so-surface); color: var(--so-text); }
.swal2-title, .swal2-html-container { color: var(--so-text) !important; }
.swal2-styled { border-radius: 11px !important; font-weight: 500 !important; }

/* ---------- ส่วนประกอบเพิ่มเติม (เฟส 1) ---------- */
.lt { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; box-shadow: 0 0 0 3px rgba(0, 0, 0, .06); }
.nav-tabs { border-bottom: 1px solid var(--so-border); gap: .25rem; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.nav-tabs .nav-link { border: 0; border-radius: 10px 10px 0 0; color: var(--so-muted); font-weight: 500; white-space: nowrap; padding: .6rem 1rem; }
.nav-tabs .nav-link.active { color: var(--so-primary); background: var(--so-surface); box-shadow: inset 0 -3px 0 var(--so-primary); font-weight: 600; }
.sum-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.sum-card { background: var(--so-surface); border: 1px solid var(--so-border); border-radius: var(--so-radius); padding: .8rem 1rem; box-shadow: var(--so-shadow-sm); border-left: 5px solid var(--c, var(--so-primary)); }
.sum-card .t { font-size: 13px; color: var(--so-muted); } .sum-card .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.sum-card.click { cursor: pointer; transition: transform .15s; } .sum-card.click:hover { transform: translateY(-2px); }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: .35rem 1rem; } .kv dt { color: var(--so-muted); font-weight: 500; } .kv dd { margin: 0; }
@media (max-width: 575.98px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: .4rem; } }
.bar-wrap { background: var(--so-surface-2); border-radius: 999px; height: 10px; overflow: hidden; min-width: 80px; } .bar-wrap > i { display: block; height: 100%; border-radius: 999px; background: var(--so-primary); }
.chart-box { position: relative; height: 280px; } .chart-box.sm { height: 220px; }
.timeline { list-style: none; margin: 0; padding: 0; } .timeline li { position: relative; padding: 0 0 1rem 2rem; }
.timeline li::before { content: ''; position: absolute; left: 11px; top: 22px; bottom: 0; width: 2px; background: var(--so-border); } .timeline li:last-child::before { display: none; }
.timeline .dotx { position: absolute; left: 0; top: 2px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 13px; background: var(--so-secondary); }
.timeline .ok { background: var(--so-success); } .timeline .no { background: var(--so-danger); } .timeline .wait { background: var(--so-warning); color: #000; } .timeline .ret { background: #fd7e14; }
.money { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.tbl-click tbody tr { cursor: pointer; }
.small-muted { font-size: 13px; color: var(--so-muted); }
.drill a { text-decoration: underline dotted; }

/* ฟอร์มบนมือถือต้องไม่เล็กกว่า 16px (กัน iOS ซูมเอง) */
@media (max-width: 767px) { .form-control, .form-select { font-size: 16px; min-height: 42px; } }
/* ลิงก์กลับหน้าแดชบอร์ด OPC */
.so-nav .poc-link { display: inline-flex; align-items: center; gap: .4rem; color: #fff; font-size: 13px; font-weight: 500; padding: .3rem .8rem; border-radius: 999px; background: rgba(255, 255, 255, .16); white-space: nowrap; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }
.so-nav .poc-link:hover { background: rgba(255, 255, 255, .28); color: #fff; }
.mod-card.live { cursor: pointer; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; } .mod-card.live:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(16, 24, 40, .14); }
.pill.live { background: color-mix(in srgb, #198754 16%, transparent); color: #198754; }


/* =====================================================================================================
   ดีไซน์ใหม่ v2 (อนุมัติจาก Claude Design) — โทนเขียวหยกสะอาด แถบบน/เมนูข้างสีสว่าง ขอบบางแทนเงา รองรับโหมดมืด
   อยู่ท้ายไฟล์เพื่อทับค่าเดิม; ถ้าต้องย้อนกลับให้ลบส่วนนี้ทั้งหมด
   ===================================================================================================== */
:root {
  --so-primary: #0b6b5d; --so-primary-2: #084f45; --so-primary-soft: #e6f3ef;
  --so-bg: #f3f6f5; --so-surface: #ffffff; --so-surface-2: #f9fbfa; --so-text: #14201c; --so-muted: #5c6b66; --so-border: #e1e7e4;
  --so-side-text: #33433e; --so-radius: 16px;
  --so-shadow-sm: none; --so-shadow: 0 10px 28px rgba(10, 30, 25, .10);
  --bs-primary: #0b6b5d; --bs-primary-rgb: 11, 107, 93; --bs-link-color: #0b6b5d; --bs-link-hover-color: #084f45; --bs-link-color-rgb: 11, 107, 93;
}
[data-bs-theme='dark'] {
  --so-primary: #2fb59e; --so-primary-2: #8ee5d3; --so-primary-soft: rgba(52, 211, 153, .14);
  --so-bg: #0e1513; --so-surface: #151e1b; --so-surface-2: #1a2521; --so-text: #e7efec; --so-muted: #93a39d; --so-border: #26332e; --so-side-text: #c3d0cb;
  --so-shadow: 0 12px 32px rgba(0, 0, 0, .5);
  --bs-body-bg: #0e1513; --bs-body-color: #e7efec; --bs-border-color: #26332e; --bs-link-color: #2fb59e; --bs-link-hover-color: #8ee5d3; --bs-link-color-rgb: 47, 181, 158;
  --bs-secondary-bg: #1a2521; --bs-tertiary-bg: #1a2521;
}
body::before { display: none; }
.btn-primary { --bs-btn-bg: var(--so-primary); --bs-btn-border-color: var(--so-primary); --bs-btn-hover-bg: var(--so-primary-2); --bs-btn-hover-border-color: var(--so-primary-2); --bs-btn-active-bg: var(--so-primary-2); --bs-btn-active-border-color: var(--so-primary-2); --bs-btn-disabled-bg: var(--so-primary); --bs-btn-disabled-border-color: var(--so-primary); }
[data-bs-theme='dark'] .btn-primary { --bs-btn-color: #06201b; --bs-btn-hover-color: #06201b; --bs-btn-active-color: #06201b; }
.btn-outline-primary { --bs-btn-color: var(--so-primary); --bs-btn-border-color: var(--so-primary); --bs-btn-hover-bg: var(--so-primary); --bs-btn-hover-border-color: var(--so-primary); --bs-btn-active-bg: var(--so-primary); --bs-btn-active-border-color: var(--so-primary); }
[data-bs-theme='dark'] .btn-outline-primary { --bs-btn-hover-color: #06201b; --bs-btn-active-color: #06201b; }
.text-primary { color: var(--so-primary) !important; } .bg-primary { background-color: var(--so-primary) !important; }
.form-control:focus, .form-select:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--so-primary) 18%, transparent); }
.btn:focus-visible { outline-color: color-mix(in srgb, var(--so-primary) 55%, transparent); }
.btn-save { background: var(--so-primary); box-shadow: none; } .btn-save:hover { box-shadow: 0 6px 16px color-mix(in srgb, var(--so-primary) 35%, transparent); }
[data-bs-theme='dark'] .btn-save, [data-bs-theme='dark'] .btn-save:hover { color: #06201b; }
.btn-edit { background: #1d4ed8; box-shadow: none; } [data-bs-theme='dark'] .btn-edit { background: #3b82f6; }
.btn-del { background: #b42318; box-shadow: none; } [data-bs-theme='dark'] .btn-del { background: #d92d20; }
.btn-cancel { background: #5c6b66; box-shadow: none; }
.page-item.active .page-link { background: var(--so-primary); box-shadow: none; }
.card { box-shadow: none; }
.table-hover > tbody > tr:hover > * { --bs-table-hover-bg: var(--so-surface-2); }
.sum-card { box-shadow: none; }

/* แถบบน */
.so-nav { background: var(--so-surface); color: var(--so-text); box-shadow: none; border-bottom: 1px solid var(--so-border); }
.so-nav .brand { color: var(--so-text); }
.so-nav .brand img { box-shadow: none; border: 1px solid var(--so-border); }
.so-nav .brand .logo-ph { background: var(--so-primary); color: #fff; box-shadow: none; }
[data-bs-theme='dark'] .so-nav .brand .logo-ph { color: #06201b; }
.so-nav .sys { background: var(--so-primary-soft); color: var(--so-primary-2); }
[data-bs-theme='dark'] .so-nav .sys { color: var(--so-primary); }
.so-nav .btn-nav { color: var(--so-text); border: 1px solid var(--so-border); background: var(--so-surface); width: 40px; height: 40px; }
.so-nav .btn-nav:hover { background: var(--so-surface-2); color: var(--so-text); }
#soMenu { border: 0; background: transparent; }
.so-nav .badge-dot { border-color: var(--so-surface); }
.so-nav .poc-link { color: var(--so-primary-2); background: var(--so-primary-soft); box-shadow: none; }
[data-bs-theme='dark'] .so-nav .poc-link { color: var(--so-primary); }
.so-nav .poc-link:hover { background: color-mix(in srgb, var(--so-primary) 22%, transparent); color: var(--so-primary-2); }

/* เมนูข้าง */
.so-side { background: var(--so-surface); border-right: 1px solid var(--so-border); color: var(--so-side-text); scrollbar-color: var(--so-border) transparent; }
.so-side .grp { opacity: 1; color: var(--so-muted); }
.so-side a { color: var(--so-side-text); font-size: 14px; min-height: 44px; }
.so-side a:hover { background: var(--so-surface-2); color: var(--so-text); }
.so-side a.active { background: var(--so-primary-soft); color: var(--so-primary); box-shadow: none; font-weight: 600; }
.so-side .ic { background: var(--so-surface-2); color: inherit; }
.so-side a.active .ic { background: color-mix(in srgb, var(--so-primary) 18%, transparent); }
.so-side .off { opacity: .55; color: var(--so-muted); } .so-side .off em { background: var(--so-surface-2); }
@media (max-width: 991.98px) { .so-side { box-shadow: 8px 0 30px rgba(0, 0, 0, .25); } }

/* โปรไฟล์ผู้ใช้ (รูป + เมนู) */
.so-profile { position: relative; margin-left: .2rem; }
.so-profile > button { display: flex; align-items: center; gap: .6rem; background: var(--so-surface); border: 1px solid var(--so-border); border-radius: 14px; padding: 3px .75rem 3px 3px; min-height: 44px; color: var(--so-text); cursor: pointer; text-align: left; }
.so-profile > button:hover { background: var(--so-surface-2); }
.so-profile .av { position: relative; width: 36px; height: 36px; border-radius: 50%; flex: none; background: var(--so-primary-soft); color: var(--so-primary-2); display: grid; place-items: center; font-weight: 700; }
.so-profile .av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.so-profile .av::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: #12b76a; border: 2px solid var(--so-surface); }
.so-profile .tx { font-size: 13px; line-height: 1.2; font-weight: 600; } .so-profile .tx small { display: block; font-weight: 400; color: var(--so-muted); font-size: 12px; }
.so-pmenu { position: absolute; right: 0; top: calc(100% + 8px); width: 300px; max-width: calc(100vw - 24px); background: var(--so-surface); border: 1px solid var(--so-border); border-radius: 18px; padding: 16px; box-shadow: var(--so-shadow); z-index: 1100; display: none; }
.so-pmenu.show { display: block; }
.so-pmenu .top { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.so-pmenu .big { position: relative; width: 64px; height: 64px; flex: none; }
.so-pmenu .big > span, .so-pmenu .big > img { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--so-primary-soft); color: var(--so-primary-2); font-weight: 700; font-size: 24px; object-fit: cover; border: 3px solid var(--so-primary-soft); }
.so-pmenu .cam { position: absolute; right: -4px; bottom: -4px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--so-surface); background: var(--so-primary); color: #fff; display: grid; place-items: center; padding: 0; cursor: pointer; font-size: 13px; }
.so-pmenu .nm { font-weight: 700; } .so-pmenu .sb { font-size: 13px; color: var(--so-muted); }
.so-pmenu hr { margin: .4rem 0; border-color: var(--so-border); opacity: 1; }
.so-pmenu .it { display: flex; align-items: center; gap: .65rem; width: 100%; min-height: 44px; padding: 0 .4rem; border: 0; background: transparent; color: var(--so-text); font-size: 14.5px; border-radius: 10px; cursor: pointer; text-align: left; }
.so-pmenu .it:hover { background: var(--so-surface-2); color: var(--so-text); } .so-pmenu .it i { color: var(--so-muted); font-size: 1.05rem; width: 20px; text-align: center; }
.so-pmenu .it.danger, .so-pmenu .it.danger i { color: #b42318; font-weight: 600; } [data-bs-theme='dark'] .so-pmenu .it.danger, [data-bs-theme='dark'] .so-pmenu .it.danger i { color: #fda29b; }
.so-pmenu .sw { margin-left: auto; width: 42px; height: 24px; border-radius: 99px; background: #b9c4bf; position: relative; flex: none; transition: background .15s; }
.so-pmenu .sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
[data-bs-theme='dark'] .so-pmenu .sw { background: var(--so-primary); } [data-bs-theme='dark'] .so-pmenu .sw::after { left: 21px; }
@media (max-width: 767.98px) { .so-profile .tx, .so-profile .chev { display: none; } .so-profile > button { padding-right: 3px; border-radius: 50%; } }

/* ฮีโร่/สถิติ/โมดูล ตามดีไซน์ใหม่ */
.hero { background: radial-gradient(500px 220px at 90% 0, rgba(255, 255, 255, .16), transparent 70%), linear-gradient(120deg, #0b6b5d 0%, #0a5a4e 60%, #084f45 100%); box-shadow: none; border-radius: 20px; }
.hero::after { border-color: rgba(255, 255, 255, .06); }
[data-bs-theme='dark'] .hero { background: radial-gradient(500px 220px at 90% 0, rgba(255, 255, 255, .06), transparent 70%), linear-gradient(120deg, #0f3b34 0%, #0c2f2a 100%); }
.stat .ic { box-shadow: none; border-radius: 12px; width: 46px; height: 46px; font-size: 1.3rem; }
.stat:hover, a.mod-card:hover, .mod-card.live:hover { box-shadow: var(--so-shadow); }
.mod-card .mi { border-radius: 12px; }
.pill.live { background: #dcfae6; color: #067647; } [data-bs-theme='dark'] .pill.live { background: rgba(18, 183, 106, .18); color: #6ce9a6; }
.nav-tabs .nav-link.active { color: var(--so-primary); box-shadow: inset 0 -3px 0 var(--so-primary); background: transparent; }

/* ===== เมนูย่อยแทนแท็บ · แถบล่าง/เมนูด่วนบนมือถือ · ปุ่มเปิดหน้าต่างใหม่ ===== */
.so-tabs-hidden { display: none !important; }
.so-side a { padding-right: 2.2rem; }
.so-side a .nw { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; font-size: .8rem; opacity: 0; cursor: pointer; color: inherit; }
.so-side a:hover .nw, .so-side a:focus-within .nw, .so-side a .nw:focus-visible { opacity: .75; }
.so-side a .nw:hover { opacity: 1; background: var(--so-surface-2); }
.so-sub { margin: -2px 0 6px 1.55rem; padding-left: .6rem; border-left: 2px solid var(--so-border); display: flex; flex-direction: column; gap: 1px; }
.so-sub[hidden] { display: none; }
.so-sub.floating { margin-left: 0; padding-left: 0; border-left: 0; margin-bottom: .5rem; }
.so-sub button { text-align: left; background: none; border: 0; color: var(--so-muted); font-size: 13px; padding: .42rem .65rem; border-radius: 9px; min-height: 36px; line-height: 1.25; }
.so-sub button:hover { background: var(--so-surface-2); color: var(--so-text); }
.so-sub button.active { background: var(--so-primary-soft); color: var(--so-primary); font-weight: 600; }
.so-bar, .so-sheet { display: none; }
@media (max-width: 991.98px) {
  .so-side a .nw { display: none; }
  body.has-bar { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .so-bar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040; background: var(--so-surface); border-top: 1px solid var(--so-border); padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); justify-content: space-around; align-items: flex-end; }
  .so-bar a, .so-bar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; background: none; border: 0; color: var(--so-muted); font-size: 11px; padding: 6px 2px; min-height: 52px; border-radius: 12px; text-decoration: none; }
  .so-bar a i, .so-bar button i { font-size: 1.3rem; }
  .so-bar a.active { color: var(--so-primary); font-weight: 600; }
  .so-bar button[hidden] { display: none; }
  .so-bar .fab { flex: none; width: 56px; height: 56px; min-height: 56px; margin: -22px 6px 0; border-radius: 50%; background: var(--so-primary); color: #fff; box-shadow: 0 6px 18px rgba(15, 118, 110, .45); justify-content: center; }
  .so-bar .fab i { font-size: 1.6rem; }
  .so-foot { margin-bottom: 8px; }
  .so-sheet { display: block; position: fixed; inset: 0; z-index: 1060; visibility: hidden; }
  .so-sheet.show { visibility: visible; }
  .so-sheet .sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); opacity: 0; transition: opacity .2s; }
  .so-sheet.show .sheet-bg { opacity: 1; }
  .so-sheet .sheet-body { position: absolute; left: 0; right: 0; bottom: 0; max-height: 82vh; overflow-y: auto; background: var(--so-surface); color: var(--so-text); border-radius: 22px 22px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .25s ease; }
  .so-sheet.show .sheet-body { transform: none; }
  .sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--so-border); margin: 4px auto 10px; }
  .sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
  .sheet-head[hidden], #soQEdit[hidden] { display: none; }
  .grp2 { font-size: 12px; color: var(--so-muted); font-weight: 600; margin: 14px 0 8px; }
  .tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 2px; border-radius: 14px; color: var(--so-text); text-decoration: none; font-size: 11.5px; text-align: center; line-height: 1.25; min-height: 84px; }
  .tile:active { background: var(--so-surface-2); }
  .tile .ti { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35rem; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
  .tile .star { position: absolute; top: 2px; right: 8px; color: var(--so-border); font-size: .95rem; }
  .tile .star.on { color: #f59f00; }
  .sheet-body .list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
  .row-i { text-align: left; background: var(--so-surface-2); border: 0; border-radius: 12px; padding: .8rem 1rem; color: var(--so-text); min-height: 48px; font-size: 15px; }
  .row-i.active { background: var(--so-primary-soft); color: var(--so-primary); font-weight: 600; }
}
@media (max-width: 380px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 991.98px) { body.has-bar #demo-bar { bottom: calc(66px + env(safe-area-inset-bottom)) !important; z-index: 1030 !important; } }

/* แถบเตือน (ค่าสมาชิก/ตั้งค่าไม่ครบ) ใช้คลาส so-main ร่วมกับเนื้อหา — ต้องไม่สูงเต็มจอ ไม่งั้นดันเนื้อหาหน้าลงไปใต้จอ */
.so-sub-banner, .so-setup-banner { min-height: 0; padding-bottom: 0; animation: none; }
.so-sub-banner ~ .so-main, .so-setup-banner ~ .so-main { padding-top: .75rem; }

/* ปุ่มบันทึก/แก้ไข/ลบ/ยกเลิก: กำหนดสีตอนชี้/กดให้ครบ — เดิม Bootstrap ไม่มีค่า --bs-btn-hover-bg ทำให้พื้นโปร่งใส (เห็นเป็นขาว) ขณะตัวหนังสือขาว อ่านไม่ออก */
.btn-save { --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; --bs-btn-bg: var(--so-primary); --bs-btn-hover-bg: var(--so-primary); --bs-btn-active-bg: var(--so-primary); --bs-btn-disabled-bg: var(--so-primary); --bs-btn-disabled-color: #fff; }
.btn-edit { --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; --bs-btn-bg: #1d4ed8; --bs-btn-hover-bg: #1d4ed8; --bs-btn-active-bg: #1d4ed8; --bs-btn-disabled-bg: #1d4ed8; --bs-btn-disabled-color: #fff; }
.btn-del { --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; --bs-btn-bg: #b42318; --bs-btn-hover-bg: #b42318; --bs-btn-active-bg: #b42318; --bs-btn-disabled-bg: #b42318; --bs-btn-disabled-color: #fff; }
.btn-cancel { --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; --bs-btn-bg: #5c6b66; --bs-btn-hover-bg: #5c6b66; --bs-btn-active-bg: #5c6b66; --bs-btn-disabled-bg: #5c6b66; --bs-btn-disabled-color: #fff; }
[data-bs-theme='dark'] .btn-save { --bs-btn-color: #06201b; --bs-btn-hover-color: #06201b; --bs-btn-active-color: #06201b; --bs-btn-disabled-color: #06201b; }
[data-bs-theme='dark'] .btn-edit { --bs-btn-bg: #3b82f6; --bs-btn-hover-bg: #3b82f6; --bs-btn-active-bg: #3b82f6; --bs-btn-disabled-bg: #3b82f6; }
[data-bs-theme='dark'] .btn-del { --bs-btn-bg: #d92d20; --bs-btn-hover-bg: #d92d20; --bs-btn-active-bg: #d92d20; --bs-btn-disabled-bg: #d92d20; }
