/* ============================================================================
   design-system.css — ระบบส่งประมวลรายวิชาและแผนการสอน โรงเรียนสาธิตมหาวิทยาลัยพะเยา
   ดีไซน์ใหม่ทั้งระบบ (ทิศทาง B: อัตลักษณ์ม่วง-ทอง ทำใหม่ให้เป็นทางการ)

   ไฟล์นี้เป็น "drop-in" สำหรับ style.css + unified.css:
   ใช้ชื่อคลาสเดิมทั้งหมดของระบบ (card, panel, filter-select, drop-zone, ...)
   โดยโหลดต่อท้ายไฟล์เดิม จึงทับค่าที่ไม่ต้องการได้ทันที และถอยกลับได้ง่าย

   กติกาหลัก: เส้นคั่น 1px แทนเงา · มุมโค้ง 2-4px · ไม่มี gradient ·
             ตัวเลขในตาราง tabular-nums · ฟอนต์ Sarabun
   Token ทั้งหมดนิยามใน DESIGN.md (โฟลเดอร์เดียวกับไฟล์นี้)
   ============================================================================ */

/* ---------- 1. Tokens ------------------------------------------------------ */
:root {
    --brand: #5B2A86;
    --brand-strong: #431F63;
    --brand-soft: #F4F1F8;
    --primary-light: #F4F1F8;
    --success-soft: #EAF4EF;
    --warning-soft: #FBF3E4;
    --danger-soft: #FBECEC;
    --gold: #C4996C;
    --gold-strong: #A97C4B;

    --ink: #1B1726;
    --ink-soft: #3D3648;
    --muted: #6C6A7C;
    --muted-2: #8A8797;

    --rule: #E4E0EC;
    --rule-strong: #D2CBDE;
    --canvas: #F6F5F9;
    --surface: #FFFFFF;

    --success: #0F6B4A;
    --success-bg: #EAF4EF;
    --warning: #9A6212;
    --warning-bg: #FBF3E4;
    --danger: #9B2C2C;
    --danger-bg: #FBECEC;
    --info: #2A4E86;
    --info-bg: #EEF2F9;

    --r-sm: 2px;
    --r-md: 4px;
    --r-lg: 6px;

    --shadow-pop: 0 8px 24px rgba(27, 23, 38, .14);
    --font: "Sarabun", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
    --font-num: "Sarabun", "Noto Sans Thai", sans-serif;

    /* ชื่อตัวแปรเดิมของระบบ — ชี้ไปที่โทเคนใหม่เพื่อให้โค้ดเก่ายังทำงาน */
    --primary: var(--brand);
    --primary-color: var(--brand);
    --primary-hover: var(--brand-strong);
    --text-color: var(--ink);
    --text-light: var(--muted);
    --bg-color: var(--canvas);
    --border-color: var(--rule);
    --border-radius: var(--r-sm);
    --font-family: var(--font);
    --shadow-sm: none;
    --shadow-md: none;
    --gray-border: var(--rule);
    --gray-light: var(--canvas);
    --white: #FFFFFF;
    --status-not-submitted: var(--muted-2);
    --status-submitted: var(--warning);
    --status-approved: var(--success);
    --status-rejected: var(--danger);
}

/* ---------- 2. Base ------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

html body h1, html body h2, html body h3, html body h4, html body h5 {
    font-family: var(--font);
    color: var(--ink);
    margin: 0 0 .5rem;
    line-height: 1.35;
    font-weight: 600;
}
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }
p { margin: 0 0 .75rem; }

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

small, .text-sm { font-size: 13px; }
.muted, .text-muted, .dim { color: var(--muted); }
.num, td.num, .c-num { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ตัวเลข/วันที่ในตารางให้กว้างเท่ากัน */
table, .stat-details p, .num { font-variant-numeric: tabular-nums; }

/* ---------- 3. แถบหัวระบบ (Navbar) --------------------------------------- */
html body .syllabus-navbar {
    background: var(--brand-strong);
    border-bottom: 3px solid var(--gold);
    position: relative;
    z-index: 60;
    font-family: var(--font);
}
html body .syllabus-navbar-inner {
    max-width: 1360px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.syllabus-navbar-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.syllabus-navbar-brand:hover { text-decoration: none; }
html body .brand-icon {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    background: #FFFFFF;
    color: var(--brand-strong);
    border-radius: var(--r-sm);
    font-size: 17px;
}
.brand-text { display: flex; flex-direction: column; }
.brand-title { color: #FFFFFF; font-size: 15px; font-weight: 600; line-height: 1.25; }
.brand-subtitle { color: #CDBEE0; font-size: 12px; line-height: 1.3; }

html body .navbar-toggler {
    margin-left: auto;
    background: transparent;
    border: 1px solid rgba(255,255,255,.35);
    color: #FFFFFF;
    border-radius: var(--r-sm);
    padding: 7px 11px;
    cursor: pointer;
    display: none;
}
.syllabus-navbar-collapse { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.syllabus-nav-links { list-style: none; display: flex; align-items: center; gap: 2px; margin: 0; padding: 0; }
html body .syllabus-nav-links > li > a {
    display: inline-flex; align-items: center; gap: 7px;
    color: #E7DEF1;
    font-size: 13.5px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--r-sm);
    text-decoration: none;
    min-height: 38px;
}
.syllabus-nav-links > li > a:hover { background: rgba(255,255,255,.10); color: #FFFFFF; text-decoration: none; }
.syllabus-nav-links > li > a.active { background: #FFFFFF; color: var(--brand-strong); font-weight: 600; }
.syllabus-nav-links > li > a i { font-size: 13px; }

.nav-dropdown { position: relative; }
html body .nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 232px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-pop);
    list-style: none;
    margin: 0; padding: 6px;
    z-index: 70;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
html body .nav-dropdown-menu a {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 11px;
    color: var(--ink);
    font-size: 13.5px;
    border-radius: var(--r-sm);
    text-decoration: none;
}
.nav-dropdown-menu a:hover { background: var(--brand-soft); color: var(--brand-strong); text-decoration: none; }

.syllabus-navbar-user { display: flex; align-items: center; gap: 12px; }
.user-badge { display: flex; align-items: center; gap: 9px; padding-left: 18px; border-left: 1px solid rgba(255,255,255,.22); }
html body .user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    background: rgba(255,255,255,.14);
    color: #FFFFFF; font-size: 14px;
}
.user-details { display: flex; flex-direction: column; }
.user-name { color: #FFFFFF; font-size: 13px; font-weight: 600; line-height: 1.25; }
.user-role { color: #CDBEE0; font-size: 11.5px; line-height: 1.3; }
html body .btn-logout {
    display: inline-flex; align-items: center; gap: 7px;
    color: #FFFFFF; font-size: 13px; font-weight: 500;
    border: 1px solid rgba(255,255,255,.32);
    border-radius: var(--r-sm);
    padding: 8px 13px; min-height: 38px;
    text-decoration: none;
}
.btn-logout:hover { background: rgba(255,255,255,.12); text-decoration: none; color: #fff; }
html body .btn-nav-login, html body .btn-nav-register {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 13px; font-weight: 600;
    padding: 9px 15px; min-height: 38px;
    border-radius: var(--r-sm);
    text-decoration: none;
}
.btn-nav-login { background: #FFFFFF; color: var(--brand-strong); }
.btn-nav-register { border: 1px solid rgba(255,255,255,.4); color: #FFFFFF; }

/* ---------- 4. โครงหน้า ------------------------------------------------ */
.main-content { flex: 1; width: 100%; }
.container { max-width: 1280px; margin: 0 auto; padding: 24px 20px 40px; }
.content-wrapper, .page-wrap { max-width: 1280px; margin: 0 auto; padding: 24px 20px 40px; }

html body .page-info-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--rule);
    padding: 16px 24px;
}
.page-info-bar .user-info h2 { margin: 0 0 3px; font-size: 19px; color: var(--ink); }
.page-info-bar .user-info p { margin: 0; color: var(--muted); font-size: 13.5px; }
html body .role-badge {
    display: inline-block;
    margin-top: 8px;
    background: var(--brand-soft);
    color: var(--brand-strong);
    border: 1px solid #E1D6EE;
    border-radius: var(--r-sm);
    padding: 3px 10px;
    font-size: 12.5px;
    font-weight: 600;
}

/* หัวข้อหน้า */
html body .section-title, html body .page-title {
    display: flex; align-items: center; gap: 9px;
    font-size: 16px; font-weight: 600; color: var(--ink);
    margin: 0 0 14px;
    padding-bottom: 9px;
    border-bottom: 2px solid var(--gold);
}
.section-title i { color: var(--brand); font-size: 14px; }
.dashboard-title { font-size: 19px; font-weight: 600; margin: 0 0 14px; }

/* ---------- 5. แผง/การ์ด ----------------------------------------------- */
html body .card, html body .panel {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: none;
}
html body .card-header, html body .panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    font-size: 15px; font-weight: 600; color: var(--ink);
    margin: -18px -18px 15px;
    padding: 12px 18px;
    background: var(--canvas);
    border-bottom: 1px solid var(--rule);
    border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.card-header i { color: var(--brand); margin-right: 6px; }
.card-header .badge-count { font-size: 12.5px; color: var(--muted); font-weight: 500; }

/* ---------- 6. ตาราง -------------------------------------------------- */
html body table, html body table.display {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 13.5px;
}
html body th, html body table.dataTable thead th {
    background: var(--canvas) !important;
    color: var(--ink-soft);
    font-size: 12.5px;
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--rule-strong);
    white-space: nowrap;
}
html body td, html body table.dataTable tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--rule);
    color: var(--ink);
    vertical-align: middle;
}
tbody tr:hover td, table.dataTable tbody tr:hover td { background: #FBFAFD; }
tbody tr:last-child td { border-bottom: 0; }

/* DataTables */
.dataTables_wrapper { font-family: var(--font); font-size: 13.5px; }
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { padding: 10px 0; color: var(--muted); }
.dataTables_wrapper .dataTables_filter input,
html body .dataTables_wrapper .dataTables_length select {
    font: inherit; padding: 7px 10px;
    border: 1px solid var(--rule-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
}
html body .dataTables_wrapper .dataTables_paginate .paginate_button {
    border: 1px solid var(--rule) !important;
    border-radius: var(--r-sm) !important;
    background: var(--surface) !important;
    color: var(--ink-soft) !important;
    margin-left: 3px;
}
html body .dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--brand) !important;
    border-color: var(--brand) !important;
    color: #FFFFFF !important;
    font-weight: 600;
}
.dataTable tbody tr.selected td, .dataTable tbody tr.selected:hover td { background: var(--brand-soft) !important; }

/* ---------- 7. ป้ายสถานะ ------------------------------------------------ */
html body .status-badge, html body .badge, html body .chip {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; font-weight: 600;
    padding: 3px 9px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    white-space: nowrap;
    line-height: 1.5;
}
.badge-not-submitted { background: #F1F0F5; color: var(--muted); border-color: var(--rule); }
.badge-submitted     { background: var(--warning-bg); color: var(--warning); border-color: #F0E0C4; }
.badge-hod_approved  { background: var(--info-bg); color: var(--info); border-color: #D8E0EE; }
.badge-hoc_approved  { background: var(--success-bg); color: var(--success); border-color: #CFE6DC; }
.badge-director_approved { background: var(--success-bg); color: var(--success); border-color: #CFE6DC; }
.badge-approved      { background: var(--success-bg); color: var(--success); border-color: #CFE6DC; }
.badge-rejected      { background: var(--danger-bg); color: var(--danger); border-color: #F0D2D2; }
.badge-draft         { background: #F1F0F5; color: var(--muted); border-color: var(--rule); }

/* ป้ายแบบเก่า (คลาสสถานะตรง ๆ ที่ใช้ในหน้า public/stat) */
.badge.not_submitted { background: #F1F0F5; color: var(--muted); }
.badge.submitted     { background: var(--warning-bg); color: var(--warning); }
.badge.approved      { background: var(--success-bg); color: var(--success); }
.badge.rejected      { background: var(--danger-bg); color: var(--danger); }
.badge.draft         { background: #F1F0F5; color: var(--muted); }
.badge.hod_approved  { background: var(--info-bg); color: var(--info); }
.badge.hoc_approved  { background: var(--success-bg); color: var(--success); }
.badge.director_approved { background: var(--success-bg); color: var(--success); }

/* ---------- 8. ปุ่ม ---------------------------------------------------- */
.btn, .btn-submit, .btn-view, .btn-action, .btn-download-pdf,
.btn-reset, .btn-approve, .btn-reject, .btn-edit, .btn-submit-edit,
html body .btn-save-log, html body .btn-primary, html body .btn-ghost, html body .btn-save {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font-family: var(--font);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.2;
    padding: 10px 16px;
    min-height: 40px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease;
}
html body .btn-primary, html body .btn-submit, html body .btn-approve, html body .btn-view, html body .btn-save-log, html body .btn-submit-edit, html body .btn-save {
    background: var(--brand);
    color: #FFFFFF;
    border-color: var(--brand);
}
.btn-primary:hover, .btn-submit:hover, .btn-approve:hover, .btn-view:hover,
html body .btn-save-log:hover, html body .btn-submit-edit:hover, html body .btn-save:hover {
    background: var(--brand-strong);
    border-color: var(--brand-strong);
    color: #FFFFFF;
    text-decoration: none;
}
html body .btn-ghost, html body .btn-reset {
    background: var(--surface);
    color: var(--ink-soft);
    border-color: var(--rule-strong);
}
.btn-ghost:hover, .btn-reset:hover { background: var(--canvas); color: var(--ink); border-color: var(--muted-2); }
html body .btn-reject {
    background: var(--surface);
    color: var(--danger);
    border-color: #E7C9C9;
}
.btn-reject:hover { background: var(--danger-bg); color: var(--danger); }
html body .btn-edit {
    background: var(--surface);
    color: var(--warning);
    border-color: #EBD9B6;
}
.btn-edit:hover { background: var(--warning-bg); color: var(--warning); }
html body .btn-download-pdf {
    background: var(--surface); color: var(--brand);
    border-color: var(--rule-strong);
}
.btn-download-pdf:hover { background: var(--brand-soft); color: var(--brand-strong); }
button:disabled, .btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-block, .btn-full { width: 100%; }

/* ปุ่มไอคอนในตาราง (Word/PDF/ดู/แก้ไข) */
.file-actions, .c-act, td .icon-link { white-space: nowrap; }
html body .file-actions a, html body td .icon-link, html body .icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 30px; min-height: 30px;
    margin-right: 4px;
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink-soft);
    font-size: 12.5px;
    text-decoration: none;
}
.file-actions a:hover, td .icon-link:hover, .icon-btn:hover { background: var(--canvas); border-color: var(--rule-strong); }

/* ---------- 9. ฟอร์ม --------------------------------------------------- */
.form-group { margin-bottom: 15px; }
.form-label, label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-soft); margin-bottom: 6px; }
.form-control, .filter-select, .inp, select, input[type="text"], input[type="email"],
html body input[type="password"], html body input[type="number"], html body input[type="date"], html body textarea {
    font-family: var(--font);
    font-size: 14px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--rule-strong);
    border-radius: var(--r-sm);
    padding: 9px 11px;
    min-height: 40px;
    width: 100%;
    max-width: 100%;
}
textarea { min-height: 110px; line-height: 1.6; resize: vertical; }
select { cursor: pointer; }
html body input:focus, html body select:focus, html body textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(91, 42, 134, .12);
}
input[type="radio"], input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--brand); }
label > input[type="radio"], label > input[type="checkbox"] { display: inline-block; margin-right: 6px; vertical-align: -1px; }
::placeholder { color: var(--muted-2); }

/* แถบตัวกรอง */
html body .filter-bar, html body .filter-group, html body .page-act, html body .filter-dropdowns {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.filter-bar { justify-content: space-between; margin-bottom: 14px; }
.filter-group label { margin: 0; font-size: 13px; }
.filter-select { width: auto; min-width: 170px; }
html body .toggle-group {
    display: inline-flex; gap: 2px; padding: 3px;
    background: var(--canvas);
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
}
html body .toggle-btn {
    font-family: var(--font); font-size: 13.5px; font-weight: 600;
    color: var(--muted);
    background: transparent; border: 0;
    padding: 9px 16px; min-height: 38px;
    border-radius: var(--r-sm);
    cursor: pointer;
}
.toggle-btn.active { background: var(--brand); color: #FFFFFF; }
.search-box, .search-input { max-width: 320px; }

/* ---------- 10. พื้นที่อัปโหลดไฟล์ -------------------------------------- */
.upload-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
html body .drop-zone {
    border: 1px dashed var(--rule-strong);
    border-radius: var(--r-sm);
    background: #FCFBFE;
    padding: 22px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}
.drop-zone:hover { border-color: var(--brand); background: var(--brand-soft); }
.drop-zone.dragover-word, .drop-zone.dragover-pdf { border-color: var(--brand); background: var(--brand-soft); }
.drop-zone .drop-icon { font-size: 30px; margin-bottom: 8px; }
.drop-zone h4 { font-size: 14px; font-weight: 600; margin: 0 0 6px; color: var(--ink); }
.drop-zone p { margin: 0 0 4px; font-size: 12.5px; color: var(--muted); }
html body .file-name-display {
    margin-top: 10px;
    font-size: 12.5px;
    color: var(--success);
    font-weight: 600;
    word-break: break-all;
    display: none;
}
.file-name-display.has-file { display: block; }
.file-name-display::before { content: "\f15b"; font-family: "Font Awesome 6 Free"; font-weight: 900; margin-right: 6px; }

/* ---------- 11. สถิติ -------------------------------------------------- */
html body .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
html body .stat-card, html body .stat-mini-card {
    display: flex; align-items: center; gap: 13px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-left: 3px solid var(--rule-strong);
    border-radius: var(--r-sm);
    padding: 14px 16px;
    box-shadow: none;
}
.stat-card.pending, .stat-mini-card.pending { border-left-color: var(--warning); }
.stat-card.approved, .stat-mini-card.approved { border-left-color: var(--success); }
.stat-card.returned, .stat-mini-card.returned { border-left-color: var(--danger); }
html body .stat-icon {
    width: 42px; height: 42px; flex: 0 0 42px;
    display: grid; place-items: center;
    background: var(--canvas);
    border-radius: var(--r-sm);
    color: var(--brand);
    font-size: 17px;
}
.pending .stat-icon { background: var(--warning-bg); color: var(--warning); }
.approved .stat-icon { background: var(--success-bg); color: var(--success); }
.returned .stat-icon { background: var(--danger-bg); color: var(--danger); }
.stat-details h3, .stat-details .stat-label { margin: 0; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.stat-details p, .stat-details .stat-value { margin: 0; font-size: 22px; font-weight: 700; color: var(--ink); line-height: 1.2; }

/* ---------- 12. ประกาศ/แจ้งเตือน --------------------------------------- */
html body .notice-box, html body .notice, html body .alert {
    background: var(--brand-soft);
    border: 1px solid #E1D6EE;
    border-radius: var(--r-sm);
    padding: 13px 15px;
    font-size: 13.5px;
    color: var(--ink-soft);
    line-height: 1.7;
}
.alert-success { background: var(--success-bg); border-color: #CFE6DC; color: var(--success); }
.alert-danger, .alert-error { background: var(--danger-bg); border-color: #F0D2D2; color: var(--danger); }
.alert-warning { background: var(--warning-bg); border-color: #F0E0C4; color: var(--warning); }
.alert-info { background: var(--info-bg); border-color: #D8E0EE; color: var(--info); }

/* ---------- 13. หน้าตรวจเอกสาร (Inspect) ------------------------------- */
html body .topbar {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    background: var(--surface);
    border-bottom: 1px solid var(--rule);
    padding: 11px 20px;
}
html body .topbar .back-btn {
    display: inline-flex; align-items: center; gap: 7px;
    color: var(--brand); font-size: 13.5px; font-weight: 600;
    text-decoration: none;
    min-height: 38px;
}
.topbar .back-btn:hover { color: var(--brand-strong); text-decoration: underline; }
.topbar h2, .topbar .pdf-title { margin: 0; font-size: 14.5px; font-weight: 600; color: var(--ink); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
html body .btn-dl-sm {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 600;
    padding: 8px 12px; min-height: 36px;
    border: 1px solid var(--rule-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink-soft);
    text-decoration: none;
}
.btn-dl-sm:hover { background: var(--canvas); text-decoration: none; }
.btn-dl-pdf { color: var(--danger); border-color: #E7C9C9; }
.btn-dl-word { color: var(--info); border-color: #D8E0EE; }

.main-layout { display: flex; align-items: stretch; gap: 0; height: calc(100vh - 130px); }
.pdf-section { flex: 7; display: flex; flex-direction: column; background: #2A2733; min-width: 0; }
html body .pdf-toolbar {
    background: #221F2B; color: #FFFFFF;
    padding: 10px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.pdf-toolbar .pdf-title { color: #FFFFFF; font-size: 13px; }
.pdf-frame { flex: 1; width: 100%; border: 0; background: #FFFFFF; }

html body .info-panel, html body .approval-section {
    flex: 3;
    min-width: 340px;
    background: var(--surface);
    border-left: 1px solid var(--rule);
    overflow-y: auto;
    display: flex; flex-direction: column;
    padding: 0;
}
html body .info-section, html body .info-card {
    padding: 16px 18px;
    border-bottom: 1px solid var(--rule);
    background: transparent;
}
.info-card { margin: 16px 18px; padding: 14px 16px; background: var(--canvas); border: 1px solid var(--rule); border-radius: var(--r-sm); }
html body .info-section .section-title, html body .info-card h3 {
    font-size: 14.5px; font-weight: 600;
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--gold);
    display: flex; align-items: center; gap: 7px;
}
.info-card h3 { border-bottom: 1px solid var(--rule); border-bottom-width: 1px; }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 13.5px; }
.info-row span:first-child { color: var(--muted); }
.info-row span:last-child { color: var(--ink); font-weight: 600; text-align: right; }
.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.meta-item { font-size: 12.5px; }
.meta-item .label { color: var(--muted); display: block; margin-bottom: 2px; }
.meta-item .value { color: var(--ink); font-weight: 600; word-break: break-word; }

/* กรอบความคิดเห็น */
html body .comment-box {
    background: var(--warning-bg);
    border: 1px solid #F0E0C4;
    border-radius: var(--r-sm);
    padding: 12px 14px;
    font-size: 13.5px;
    color: #6E4610;
    line-height: 1.7;
}
.comment-box .source { display: block; font-weight: 600; color: #5C390C; margin-bottom: 4px; font-size: 12.5px; }
.no-comment { color: var(--muted-2); font-size: 13.5px; }
html body .view-only-banner {
    background: var(--info-bg); border: 1px solid #D8E0EE; color: var(--info);
    border-radius: var(--r-sm); padding: 11px 13px; font-size: 13px; margin: 0 18px 14px;
}

/* ป้ายสถานะรวม */
html body .overall-badge {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 13.5px; font-weight: 600;
    padding: 6px 12px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
}
.overall-not_submitted { background: #F1F0F5; color: var(--muted); border-color: var(--rule); }
.overall-submitted { background: var(--warning-bg); color: var(--warning); border-color: #F0E0C4; }
.overall-in_progress { background: var(--info-bg); color: var(--info); border-color: #D8E0EE; }
.overall-approved, .overall-director_approved, .overall-hoc_approved { background: var(--success-bg); color: var(--success); border-color: #CFE6DC; }
.overall-rejected { background: var(--danger-bg); color: var(--danger); border-color: #F0D2D2; }
.overall-returned { background: var(--warning-bg); color: #7A4A08; border-color: #F0E0C4; }

/* ---------- 14. ขั้นตอนการอนุมัติ (Timeline) --------------------------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 1px; background: var(--rule-strong); }
.tl-step { position: relative; padding-bottom: 16px; }
.tl-step:last-child { padding-bottom: 0; }
html body .tl-dot {
    position: absolute; left: -26px; top: 3px;
    width: 15px; height: 15px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 8px; color: #FFFFFF;
    background: var(--muted-2);
    border: 2px solid var(--surface);
}
.tl-dot.approved { background: var(--success); }
.tl-dot.pending { background: var(--warning); }
.tl-dot.waiting { background: #CBC6D6; }
.tl-dot.rejected { background: var(--danger); }
.tl-dot.returned { background: #B26A12; }
.tl-label { font-size: 13.5px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
html body .tl-status {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; font-weight: 600;
    padding: 3px 9px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
}
.tl-status.approved { background: var(--success-bg); color: var(--success); border-color: #CFE6DC; }
.tl-status.pending { background: var(--warning-bg); color: var(--warning); border-color: #F0E0C4; }
.tl-status.waiting { background: #F1F0F5; color: var(--muted); border-color: var(--rule); }
.tl-status.rejected { background: var(--danger-bg); color: var(--danger); border-color: #F0D2D2; }
.tl-status.returned { background: var(--warning-bg); color: #7A4A08; border-color: #F0E0C4; }

/* บันทึกการสอน */
.teaching-log-section { padding: 16px 18px; border-top: 1px solid var(--rule); background: var(--canvas); }
.teaching-log-section textarea { min-height: 160px; background: var(--surface); }
.log-saved-info { font-size: 12.5px; color: var(--muted); }

/* ไฟล์ Word ที่แสดงในเบราว์เซอร์ไม่ได้ */
html body .word-fallback {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; padding: 30px 20px; text-align: center;
    background: var(--surface); color: var(--ink);
}
.word-fallback i { font-size: 44px; color: var(--muted-2); margin-bottom: 12px; }
.word-fallback h3 { font-size: 16px; margin-bottom: 6px; }
.word-fallback p { color: var(--muted); font-size: 13.5px; margin-bottom: 16px; }
html body .btn-dl-big {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--brand); color: #FFFFFF;
    font-size: 13.5px; font-weight: 600;
    padding: 11px 20px; min-height: 42px;
    border-radius: var(--r-sm);
    text-decoration: none; margin: 4px;
}
.btn-dl-big:hover { background: var(--brand-strong); color: #FFFFFF; text-decoration: none; }

/* ---------- 15. Modal -------------------------------------------------- */
html body .modal, html body #editSubjectModal {
    background: rgba(27, 23, 38, .48) !important;
    backdrop-filter: none !important;
}
html body .modal > div, html body #editSubjectModal > div {
    border-radius: var(--r-md) !important;
    border: 1px solid var(--rule);
    box-shadow: var(--shadow-pop) !important;
    background: var(--surface);
}
html body .modal > div > div:first-child, html body #editSubjectModal > div > div:first-child {
    background: var(--brand-strong) !important;
    color: #FFFFFF;
}
.swal2-popup { font-family: var(--font) !important; border-radius: var(--r-md) !important; }
.swal2-title { font-size: 18px !important; }
.swal2-styled.swal2-confirm { background: var(--brand) !important; border-radius: var(--r-sm) !important; }

/* ---------- 16. หน้าผู้ดูแลระบบ (Admin) -------------------------------- */
.admin-body { display: flex; flex: 1; align-items: stretch; min-height: calc(100vh - 62px); }
html body .sidebar {
    width: 244px; flex: 0 0 244px;
    background: var(--brand-strong);
    background-image: none;            /* ยกเลิก gradient เดิม */
    border-right: 1px solid #38204F;
    display: flex; flex-direction: column;
}
html body .sidebar-header {
    padding: 18px 18px 14px;
    border-bottom: 1px solid rgba(255,255,255,.14);
    text-align: left;
}
.sidebar-header h2 { margin: 0; font-size: 15px; color: #FFFFFF; font-weight: 600; }
.sidebar-header p { margin: 3px 0 0; font-size: 12.5px; color: #C7B5DA; }
.sidebar-menu { list-style: none; margin: 0; padding: 10px 0; flex: 1; }
html body .sidebar-menu li a {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 18px;
    color: #DCD0E8; font-size: 13.5px; font-weight: 500;
    text-decoration: none;
    border-left: 3px solid transparent;
    min-height: 42px;
}
.sidebar-menu li a:hover { background: rgba(255,255,255,.08); color: #FFFFFF; text-decoration: none; }
.sidebar-menu li a.active { background: rgba(255,255,255,.12); color: #FFFFFF; border-left-color: var(--gold); font-weight: 600; }
.sidebar-menu li a i { width: 18px; text-align: center; color: var(--gold); font-size: 13px; }
html body .sidebar .badge {
    margin-left: auto;
    background: #FFFFFF; color: var(--brand-strong);
    border-radius: var(--r-sm);
    font-size: 11.5px; font-weight: 700;
    padding: 2px 7px;
}
.admin-body > .main-content { flex: 1; padding: 22px 24px 36px; overflow-y: auto; background: var(--canvas); }

/* ---------- 17. หน้าเข้าสู่ระบบ ---------------------------------------- */
html body .auth-card, html body .login-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    padding: 22px;
    max-width: 420px;
}
.auth-card h3, .login-card h3 { font-size: 17px; margin-bottom: 14px; }
.auth-note { font-size: 12.5px; color: var(--muted); }

/* ---------- 18. หน้าสาธารณะ (สืบค้นประมวลรายวิชา) ---------------------- */
html body .syllabus-header {
    background: var(--brand-strong);
    border-bottom: 3px solid var(--gold);
    color: #FFFFFF;
    padding: 34px 0 30px;
    text-align: center;
    margin-bottom: 22px;
}
.syllabus-header h1 { color: #FFFFFF; font-size: 24px; margin-bottom: 6px; }
.syllabus-header p { color: #DCCEEA; margin: 0; font-size: 14px; }
.search-container { max-width: 1180px; margin: 0 auto 34px; padding: 0 18px; }
html body .filter-card, html body .table-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    padding: 16px;
    box-shadow: none;
    margin-bottom: 18px;
}
.filter-card { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter-card .filter-group { flex: 1; min-width: 200px; }
.table-card { overflow-x: auto; }
html body .badge-level {
    display: inline-block;
    background: var(--brand-soft); color: var(--brand-strong);
    border: 1px solid #E1D6EE;
    border-radius: var(--r-sm);
    padding: 2px 9px;
    font-size: 12px; font-weight: 600;
}
html body .btn-download {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--surface); color: var(--brand);
    border: 1px solid var(--rule-strong);
    border-radius: var(--r-sm);
    padding: 8px 13px; min-height: 38px;
    font-size: 13px; font-weight: 600;
    text-decoration: none;
}
.btn-download:hover { background: var(--brand-soft); color: var(--brand-strong); text-decoration: none; }

/* ---------- 19. ฟุตเตอร์ (แบน ไม่มีคลื่น) ------------------------------ */
.syllabus-footer { margin-top: auto; background: var(--brand-strong); color: #E3D9EE; }
.footer-wave { display: none; }
.footer-body { max-width: 1360px; margin: 0 auto; padding: 26px 20px 18px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
.footer-brand { display: flex; align-items: center; gap: 9px; color: #FFFFFF; font-size: 14.5px; font-weight: 600; margin-bottom: 8px; }
.footer-brand i { color: var(--gold); }
.footer-desc { font-size: 13px; color: #C7B5DA; margin: 0; }
.footer-heading { font-size: 13px; font-weight: 600; color: #FFFFFF; margin: 0 0 10px; }
.footer-links, .footer-contact { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.footer-links li, .footer-contact li { margin-bottom: 7px; color: #C7B5DA; }
.footer-links a, .footer-contact a { color: #E3D9EE; text-decoration: none; }
.footer-links a:hover, .footer-contact a:hover { color: #FFFFFF; text-decoration: underline; }
.footer-links i, .footer-contact i { color: var(--gold); margin-right: 6px; width: 14px; }
html body .footer-bottom {
    max-width: 1360px; margin: 20px auto 0; padding: 14px 20px 0;
    border-top: 1px solid rgba(255,255,255,.16);
    display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    font-size: 12.5px; color: #C7B5DA;
}
.footer-bottom p { margin: 0; }

/* ---------- 20. สถานะว่าง / โหลด -------------------------------------- */
html body .empty-state, html body .loading-spinner {
    padding: 34px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 13.5px;
}
.empty-state i { display: block; font-size: 34px; color: var(--muted-2); margin-bottom: 10px; }

/* ---------- 21. Responsive ------------------------------------------- */
@media (max-width: 1100px) {
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .info-panel, .approval-section { min-width: 300px; }
}
@media (max-width: 992px) {
    .navbar-toggler { display: inline-flex; }
html body .syllabus-navbar-collapse {
        display: none; width: 100%; flex-direction: column; align-items: stretch;
        gap: 10px; padding-top: 12px;
    }
    .syllabus-navbar-collapse.show { display: flex; }
    .syllabus-nav-links { flex-direction: column; align-items: stretch; }
    .syllabus-nav-links > li > a { width: 100%; }
    .nav-dropdown-menu { position: static; box-shadow: none; border: 1px solid var(--rule); margin-top: 4px; }
    .syllabus-navbar-user { border-top: 1px solid rgba(255,255,255,.2); padding-top: 12px; }
    .user-badge { border-left: 0; padding-left: 0; }
    .main-layout { flex-direction: column; height: auto; }
    .pdf-section { flex: none; height: 460px; }
    .info-panel, .approval-section { flex: none; min-width: 0; border-left: 0; border-top: 1px solid var(--rule); }
    .admin-body { flex-direction: column; }
    .sidebar, .sidebar-menu { width: 100%; flex: none; }
    .sidebar-menu { flex-direction: row; flex-wrap: wrap; padding: 8px; }
    .sidebar-menu li { flex: 1 1 46%; }
    .sidebar-menu li a { border-left: 0; border-bottom: 3px solid transparent; }
    .sidebar-menu li a.active { border-left: 0; border-bottom-color: var(--gold); }
    .meta-grid { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .container, .content-wrapper, .page-wrap { padding: 16px 14px 30px; }
    .card, .panel { padding: 14px; }
    .card-header, .panel-head { margin: -14px -14px 12px; padding: 11px 14px; }
    h1 { font-size: 21px; }
    .stats-grid { grid-template-columns: 1fr; }
    .filter-bar, .filter-group { flex-direction: column; align-items: stretch; }
    .filter-select, .inp, .search-box { width: 100%; max-width: none; }
    .btn, .btn-submit, .btn-action { width: 100%; }
    .topbar-actions { width: 100%; }
}

/* ---------- 22. พิมพ์เอกสาร ------------------------------------------ */
@media print {
    .syllabus-navbar, .syllabus-footer, .topbar-actions, .btn, .sidebar { display: none !important; }
    body { background: #FFFFFF; font-size: 12pt; }
    .card, .panel { border-color: #999; box-shadow: none; page-break-inside: avoid; }
}

/* ---------- 23. ลดการเคลื่อนไหว -------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================================
   24. คอมโพเนนต์ที่เหลือของหน้าภาพรวม/หน้าอื่น ๆ
   (กราฟวงกลม, แถบสถานะรายวิชา, accordion, รายการแผนการสอน, ฟุตเตอร์/เมนูชิ้นเล็ก)
   ทำเป็นดีไซน์ใหม่ให้ครบ เพื่อไม่ให้เหลือชิ้นส่วนที่ยังใช้สไตล์เดิม
   ============================================================================ */

/* --- ตัวสลับประเภทข้อมูล + กราฟ --- */
html body .type-toggle { display: flex; justify-content: center; margin: 22px 0 16px; }
html body .type-toggle .toggle-btn { border: 1px solid var(--rule-strong); background: var(--surface); color: var(--muted); }
html body .type-toggle .toggle-btn + .toggle-btn { margin-left: -1px; }
html body .type-toggle .toggle-btn.active { background: var(--brand); color: #FFFFFF; border-color: var(--brand); }

html body .chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}
html body .chart-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    padding: 14px 16px 8px;
    box-shadow: none;
}
html body .chart-card:hover { border-color: var(--rule-strong); }
html body .chart-card h3 {
    font-size: 13.5px; font-weight: 600; color: var(--ink);
    margin: 0 0 10px; padding-bottom: 8px;
    border-bottom: 1px solid var(--rule);
}
html body .chart-container { position: relative; height: 210px; }
html body .chart-summary { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; padding: 10px 0 4px; font-size: 12.5px; color: var(--muted); }

/* --- แถบสถานะรายวิชาใน accordion --- */
html body .status-section { margin: 0 0 30px; }
html body .accordion-item { border: 1px solid var(--rule); border-radius: var(--r-sm); margin-bottom: 8px; background: var(--surface); overflow: hidden; }
html body .accordion-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px;
    background: var(--canvas);
    font-size: 14px; font-weight: 600; color: var(--ink);
    cursor: pointer;
}
html body .accordion-header:hover { background: var(--brand-soft); }
html body .accordion-header .indicator { color: var(--brand); font-size: 12px; transition: transform .15s ease; }
html body .accordion-item.active .indicator { transform: rotate(180deg); }
html body .accordion-content { display: none; padding: 4px 16px 12px; }
html body .accordion-item.active .accordion-content { display: block; }

html body .subject-item { padding: 12px 0; border-bottom: 1px solid var(--rule); }
html body .subject-item:last-child { border-bottom: 0; padding-bottom: 0; }
html body .subject-header { font-size: 13.5px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
html body .status-bar-container { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
html body .status-bar-label { flex: 0 0 92px; font-size: 12.5px; color: var(--muted); }
html body .status-bar {
    flex: 1 1 auto;
    height: 7px;
    background: #EDEAF3;
    border-radius: var(--r-sm);
    overflow: hidden;
}
html body .status-fill { height: 100%; width: 0; background: var(--muted-2); }
html body .status-not_submitted .status-fill { width: 0; background: var(--muted-2); }
html body .status-draft .status-fill { width: 15%; background: var(--muted-2); }
html body .status-submitted .status-fill { width: 50%; background: var(--warning); }
html body .status-hod_approved .status-fill { width: 75%; background: var(--info); }
html body .status-hoc_approved .status-fill { width: 100%; background: var(--success); }
html body .status-director_approved .status-fill { width: 100%; background: var(--success); }
html body .status-approved .status-fill { width: 100%; background: var(--success); }
html body .status-rejected .status-fill { width: 100%; background: var(--danger); }

/* --- รายการแผนการสอนในหน้าแก้ไข/ดูเอกสาร --- */
html body .lesson-plans-list { list-style: none; margin: 0; padding: 0; }
html body .lesson-plan-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 11px 14px; margin-bottom: 8px;
    border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--surface);
    font-size: 13.5px;
}
html body .btn-outline {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 38px; padding: 9px 15px;
    border: 1px solid var(--rule-strong); border-radius: var(--r-sm);
    background: var(--surface); color: var(--brand);
    font-size: 13.5px; font-weight: 600; text-decoration: none;
}
html body .btn-outline:hover { background: var(--brand-soft); color: var(--brand-strong); text-decoration: none; }

/* --- เมนู/ปุ่มชิ้นเล็กในแถบหัวระบบ (ให้ hover ตรงกันทุกรูปแบบ selector) --- */
html body .navbar-toggler:hover { background: rgba(255,255,255,.14); }
html body .syllabus-nav-links li a { color: #E7DEF1; }
html body .syllabus-nav-links li a:hover { background: rgba(255,255,255,.10); color: #FFFFFF; }
html body .syllabus-nav-links li a.active { background: #FFFFFF; color: var(--brand-strong); }
html body .syllabus-nav-links li a i { font-size: 13px; }
html body .nav-dropdown-menu li a { color: var(--ink); }
html body .nav-dropdown-menu li a:hover { background: var(--brand-soft); color: var(--brand-strong); }
html body .nav-dropdown-menu li a i { color: var(--brand); width: 16px; }
html body .btn-nav-login:hover { background: #F0EBF7; text-decoration: none; }
html body .btn-nav-register:hover { background: rgba(255,255,255,.14); text-decoration: none; }

/* --- ฟุตเตอร์ชิ้นเล็ก --- */
html body .footer, html body .footer-container { background: transparent; }
html body .footer-links li a, html body .footer-contact li a { color: #E3D9EE; text-decoration: none; }
html body .footer-links li a:hover, html body .footer-contact li a:hover { color: #FFFFFF; text-decoration: underline; }
html body .footer-links li a i, html body .footer-contact li i { color: var(--gold); margin-right: 6px; }
html body .footer-version { font-size: 12px; color: #B7A6CB; }
