/* ============================================================
   หน้าตาของระบบตารางสอนบนเว็บ ict (ไม่ใช่ไฟล์ของผู้พัฒนาเดิม: app.css คงไว้ตามต้นฉบับ)
   - สีและตัวอักษรเข้าชุดกับ ict/assets/css/kkw.css (ฟ้า ชมพู ทอง น้ำเงินเข้มจากโลโก้โรงเรียน)
   - ทุกกฎอยู่ใน @media screen: หน้าพิมพ์ใช้ app.css เดิมทั้งหมด (tools/dev/e2e_timetable.py ตรวจไว้)
   - ใช้คลาสเดิมของระบบ เพิ่มคลาสใหม่เฉพาะโครงหน้า (templates/header.php) และหน้าภาพรวม
   ============================================================ */
@media screen {

:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f1f3f8;
    --ink: #28304a;
    --ink-2: #4d566b;
    --ink-3: #616a80;
    --line: #dfe3ec;
    --line-2: #eef0f5;
    --field: #cfd5e3;
    --accent: #0b78b8;
    --accent-ink: #ffffff;
    --accent-soft: #e4f4fb;
    --accent-dark: #095f92;
    --navy: #1b2559;
    --pink: #e8559a;
    --gold: #f2b300;
    --warn: #8a5a00;
    --warn-soft: #fff5d9;
    --bad: #cc2e3a;
    --bad-soft: #fdecee;
    --good: #16875a;
    --good-soft: #e3f5ec;
    --radius: 10px;
    --f-head: "IBM Plex Sans Thai", "Leelawadee UI", "Sarabun", "Tahoma", sans-serif;
    --sidebar: 268px;
    --topbar: 68px;
    --shadow: 0 1px 2px rgba(27, 37, 89, .04), 0 4px 14px rgba(27, 37, 89, .05);
    /* คาบที่ลงไม่ได้ (ลายทแยง) และคาบที่ล็อกไว้ (ทึบ): เทาเข้ม ตัวอักษรขาว อ่านง่ายกว่าเหลืองอ่อนเดิม */
    --off-a: #4b5262;
    --off-b: #5c6577;
    --off-lock: #3f4656;
    --off-ink: #ffffff;
    --off-stripes: repeating-linear-gradient(135deg, var(--off-a) 0 5px, var(--off-b) 5px 10px);
}

body { font-size: 16px; }
h1, h2, h3, h4 { color: var(--navy); font-weight: 600; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
:focus-visible { outline: 3px solid #2bb5e5; outline-offset: 2px; }

/* ---------- แถบบน ---------- */
.topbar { min-height: var(--topbar); padding: 10px 24px; gap: 10px 16px; border-bottom: 1px solid var(--line); }
.brand { gap: 12px; }
.brand img { width: 46px; height: 46px; }
.brand b { font-family: var(--f-head); font-size: 16.5px; font-weight: 600; color: var(--navy); }
.brand-t > span { color: var(--ink-3); }
.term-switch select {
    appearance: none; -webkit-appearance: none; min-width: 0; border: 1.5px solid transparent; border-radius: 999px;
    padding: 8px 36px 8px 16px; background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23095f92' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center;
    color: var(--accent-dark); font-weight: 700; font-size: 14.5px; cursor: pointer;
}
.term-switch select:hover { border-color: #9fd2ee; }
.user-box.user-menu { display: block; position: relative; }
.user-menu > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 999px; cursor: pointer; user-select: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover, .user-menu[open] > summary { background: var(--surface-2); }
.user-menu > summary::after { content: ''; width: 7px; height: 7px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg); margin: -4px 2px 0 2px; }
.user-menu .ob { width: 38px; height: 38px; border: 0; box-shadow: none; font-size: 16px; }
.um-t { display: flex; flex-direction: column; line-height: 1.25; }
.um-t b { font-size: 14.5px; font-weight: 600; color: var(--navy); }
.um-t small { font-size: 12.5px; color: var(--ink-3); margin: 0; }
.um-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px rgba(27, 37, 89, .16); display: flex; flex-direction: column; }
.um-pop a, .um-pop .linklike { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 500; font-size: 14.5px; text-align: left; }
.um-pop a:hover, .um-pop .linklike:hover { background: var(--surface-2); color: var(--navy); }
.um-pop .linklike { color: var(--bad); }
.um-pop form { margin: 0; }
.um-pop .ic { width: 17px; height: 17px; }

/* ---------- เมนูซ้าย: ขั้นตอนการทำงาน ---------- */
.layout { min-height: calc(100vh - var(--topbar)); }
.sidebar { top: var(--topbar); height: calc(100vh - var(--topbar)); padding: 14px 12px 22px; gap: 4px; border-right: 1px solid var(--line); }
.nav-search { position: relative; margin: 0 2px 6px; }
.sidebar .nav-search input {
    width: 100%; padding: 8px 12px 8px 34px; border-radius: 10px; border: 1.5px solid transparent; font-size: 14px;
    background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23616a80' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 11px center;
}
.sidebar .nav-search input:focus { background-color: var(--surface); border-color: var(--accent); outline: none; }
.nav-empty { padding: 6px 12px; font-size: 13.5px; color: var(--ink-3); }
.sidebar [hidden] { display: none !important; }
.sidebar a, .sidebar .soon { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 9px; font-size: 14.5px; color: var(--ink-2); }
.sidebar a:hover { background: var(--surface-2); color: var(--navy); }
.sidebar a.on { background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; }
.nav-home a { font-weight: 600; color: var(--navy); }
.nav-home .ic { width: 19px; height: 19px; }
/* สีประจำขั้น: ใช้ทั้งเมนู แถบบอกตำแหน่ง และหน้าภาพรวม (.nav-sec.nav-* ทับค่าเดิมใน app.css) */
.nav-pink, .nav-sec.nav-pink { --nc: #b0336a; --nc-bar: #e8559a; --nc-bg: #fde9f1; --nc-soft: #fbd9e7; }
.nav-sky, .nav-sec.nav-sky { --nc: #095f92; --nc-bar: #2bb5e5; --nc-bg: #e4f4fb; --nc-soft: #cdeaf8; }
.nav-yellow, .nav-sec.nav-yellow { --nc: #7a5200; --nc-bar: #f2b300; --nc-bg: #fff5d9; --nc-soft: #ffebb3; }
.nav-navy, .nav-sec.nav-navy { --nc: #1b2559; --nc-bar: #4a5aa8; --nc-bg: #e9ebf6; --nc-soft: #d8dcf0; }
.nav-green, .nav-sec.nav-green { --nc: #11693f; --nc-bar: #16875a; --nc-bg: #e3f5ec; --nc-soft: #cdeedd; }
.nav-slate, .nav-sec.nav-slate { --nc: #4d566b; --nc-bar: #8a92a6; --nc-bg: #f1f3f8; --nc-soft: #e2e5ee; }
.nav-c { margin-top: 6px; padding: 0; background: none; border: 0; border-radius: 0; }
.nav-c .nav-group, details.nav-sec > summary.nav-group {
    display: flex; align-items: center; gap: 10px; padding: 7px 8px; margin: 0; border-radius: 10px;
    font-family: var(--f-head); font-size: 14.5px; font-weight: 600; letter-spacing: 0; color: var(--nc);
}
.nav-no { display: inline-grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--nc, var(--accent)); color: #fff; font-family: var(--f-body); font-size: 12.5px; font-weight: 700; }
.nav-no .ic { width: 14px; height: 14px; }
.nav-gt { flex: 1; min-width: 0; }
.nav-c .nav-items { margin: 2px 0 4px 19px; padding-left: 9px; border-left: 2px solid var(--nc-soft); gap: 1px; }
.nav-c a { padding: 6px 10px; font-size: 14px; }
.nav-c a:hover { background: var(--nc-bg); color: var(--nc); }
.nav-c a.on { background: var(--nc-bg); color: var(--nc); font-weight: 700; box-shadow: inset 3px 0 0 var(--nc-bar); }
details.nav-sec > summary:hover { background: var(--nc-bg); }
.nav-foot { padding: 16px 10px 0; }
.nav-backdrop { display: none; }

/* ---------- เนื้อหา ---------- */
.main { padding: 22px 32px 64px; max-width: 1440px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin: -6px 0 12px; font-size: 13.5px; color: var(--ink-3); }
.crumbs a { color: var(--ink-3); text-decoration: none; font-weight: 500; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs .sep { color: #b8bfd0; }
.crumbs b { color: var(--ink-2); font-weight: 600; }
.crumbs .crumb-g { display: inline-flex; align-items: center; gap: 5px; color: var(--nc); font-weight: 600; }
.crumbs .nav-no { width: 18px; height: 18px; font-size: 11px; }
.crumbs .nav-no .ic { width: 11px; height: 11px; }

.pagehead { margin-bottom: 20px; gap: 12px 24px; align-items: flex-end; }
.pagehead > div:first-child { min-width: 0; flex: 1 1 420px; }
.pagehead h1 { font-size: 27px; font-weight: 600; color: var(--navy); }
.pagehead p { margin-top: 6px; color: var(--ink-3); font-size: 15px; max-width: 82ch; }
.pagehead p.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.more-btn { margin-top: 4px; padding: 2px 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.more-btn:hover { text-decoration: underline; }
.actions { gap: 8px; justify-content: flex-end; }

.flash { border-radius: 12px; padding: 12px 16px; font-size: 15px; border-width: 1px; }
.flash.success { background: var(--good-soft); border-color: #b4e2c9; color: #11693f; }
.flash.error { background: var(--bad-soft); border-color: #f0b3ba; color: #b3202c; }
.flash.info { background: var(--warn-soft); border-color: #f3d98c; color: #6b4800; }

/* ---------- ปุ่มและช่องกรอก ---------- */
.btn { min-height: 40px; padding: 8px 16px; border: 1.5px solid var(--field); border-radius: 10px; background: var(--surface); color: var(--navy); font-weight: 600; font-size: 14.5px; transition: background-color .15s, border-color .15s, color .15s; }
.btn:hover { background: #fafbfd; border-color: #aeb6c9; color: var(--navy); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.pri:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; filter: none; }
.btn.danger { color: #b3202c; border-color: #f0b3ba; }
.btn.danger:hover { background: var(--bad-soft); color: #b3202c; }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 32px; padding: 4px 11px; border-radius: 8px; font-size: 13.5px; }
.btn .ic { width: 17px; height: 17px; }
select, input[type=text], input[type=number], input[type=search], input[type=password], input[type=date], input[type=time], textarea {
    border: 1.5px solid var(--field); border-radius: 9px; padding: 7px 11px; color: var(--ink);
}
select:focus, input[type=text]:focus, input[type=number]:focus, input[type=search]:focus, input[type=password]:focus, input[type=date]:focus, input[type=time]:focus, textarea:focus {
    border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(11, 120, 184, .15);
}
.field { color: var(--ink-2); font-weight: 600; }
.toolbar { gap: 10px 12px; }
.linklike { color: var(--accent); }

/* ---------- กล่องและตาราง ---------- */
.panel { border-color: var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.panel > h2, .panel > h3 { font-size: 17px; color: var(--navy); padding: 14px 20px; border-bottom-color: var(--line-2); }
.panel .pb { padding: 18px 20px; }
.tscroll { border-color: var(--line); border-radius: 14px; }
.panel .tscroll { border-radius: 0 0 14px 14px; }
table.data { font-size: 15px; }
table.data th { background: #f6f7fb; color: var(--ink-2); font-size: 13px; font-weight: 600; padding: 10px 12px; border-bottom-color: var(--line); }
table.data td { padding: 9px 12px; border-bottom-color: var(--line-2); }
table.data tbody tr:hover td { background: #f3f9fd; }
table.data tr.upd td { background: #fff8e3; }
.empty { color: var(--ink-3); }
.pill { font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.pill.warn { color: #7a5200; }
.meter { height: 8px; border-radius: 999px; }
.meter > i { border-radius: 999px; }
.meter.warn > i { background: var(--gold); }
.tabs a { border-radius: 999px; border-width: 1.5px; font-weight: 600; }
.help { border-radius: 12px; border-color: var(--field); }
.checklist li.ok::before { color: var(--good); }

/* ---------- หน้าภาพรวม: 5 ขั้นตอน ---------- */
.dash-next { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-bottom: 18px; padding: 16px 20px; border-radius: 16px; background: linear-gradient(135deg, #0b78b8, #095f92); color: #fff; box-shadow: var(--shadow); }
.dash-next .dn-ic { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; background: rgba(255, 255, 255, .16); }
.dash-next .dn-ic .ic { width: 24px; height: 24px; }
.dash-next .dn-t { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dash-next .dn-t small { font-size: 13px; opacity: .85; }
.dash-next .dn-t b { font-family: var(--f-head); font-size: 19px; font-weight: 600; }
.dash-next .dn-t span { font-size: 14.5px; opacity: .92; }
.dash-next .btn { background: #fff; border-color: #fff; color: var(--accent-dark); }
.dash-next .btn:hover { background: #eef7fd; }
.phases { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.phases > .phase:nth-child(-n+2) { grid-column: 1 / -1; } /* ขั้น 1–2 มีหลายการ์ด เต็มแถว · ขั้น 3–5 มีการ์ดเดียว วางคู่กันในแถวเดียว */
.phase { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--nc-bar, var(--accent)); border-radius: 16px; padding: 14px 16px 16px; box-shadow: var(--shadow); }
.phase-h { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 12px; }
.phase-h h2 { font-size: 18px; color: var(--nc); }
.phase-h .nav-no { width: 28px; height: 28px; font-size: 14px; }
.phase-cnt { font-size: 13.5px; font-weight: 600; color: var(--ink-3); }
.phase-h .meter { flex: 1 1 120px; max-width: 260px; margin-left: auto; }
.phase-h .meter > i { background: var(--nc-bar); }
.phase.done .phase-cnt { color: var(--good); }
.phase .steps { margin: 0; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.step { border-radius: 12px; padding: 12px 14px; border-color: var(--line); gap: 2px; transition: border-color .15s, box-shadow .15s; }
a.step:hover { border-color: var(--nc, var(--accent)); box-shadow: 0 6px 16px rgba(27, 37, 89, .08); }
.step .k { color: var(--ink-2); font-size: 14.5px; }
.step .k i { border-width: 2px; }
.step.ok .k i { background: var(--good); border-color: var(--good); color: #fff; }
.step.todo .k i { border-color: var(--gold); color: #7a5200; background: var(--warn-soft); }
.step.next { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11, 120, 184, .14); }
.step .v { font-size: 25px; color: var(--navy); }
.step .opt { font-size: 11.5px; font-weight: 600; color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; margin-left: auto; }
.alerts > div { padding: 10px 20px; }

/* ---------- ช่องในตารางสอน (บนจอ) ---------- */
.tt-cell { border-color: #d5dae6; }
.tt-cell.empty { background: #f8f9fc; border-color: #d5dae6; }
.tt-e b { color: var(--navy); }
/* ลงไม่ได้: ปิดใช้ พักกลางวัน ครู/ห้องไม่ว่าง และช่องที่ห้ามลงขณะย้ายวิชา */
.tt-cell.blk, .tt-cell.unav, .tt-cell.unav-hidden, table.tt .tt-cell.no:not(.blk):not(.same) { background: var(--off-stripes); color: var(--off-ink); border: 1px solid var(--off-a); opacity: 1; }
.tt-cell.blk *, .tt-cell.unav *, .tt-cell.unav-hidden *, table.tt .tt-cell.no:not(.blk):not(.same) * { color: inherit !important; }
.tt-cell.blk { font-weight: 600; }
/* คาบที่ล็อกไว้ (พัฒนาผู้เรียน ลูกเสือ ชุมนุม ฯลฯ): เทาเข้มทึบ */
.tt-cell.blk.fixed { background: var(--off-lock); color: var(--off-ink); border-color: var(--off-lock); font-weight: 700; }
.tt-legend .lg.no { background: var(--off-stripes); opacity: 1; }
.tm-cell.busy { background: #dfe3ec; color: var(--ink); }
.tm-cell.unav { background: repeating-linear-gradient(135deg, var(--off-a) 0 4px, var(--off-b) 4px 8px); color: var(--off-ink); }
table.tt-matrix td.unav { background: repeating-linear-gradient(135deg, var(--off-a) 0 3px, var(--off-b) 3px 6px); color: var(--off-ink); }
.tt-bar { box-shadow: 0 -8px 24px rgba(27, 37, 89, .1); }
body:has(#chatDock) .tt-bar { padding-right: 150px; } /* ปุ่มแชท (admin) ลอยมุมขวาล่าง: เว้นท้ายแถบแก้ตาราง ไม่ให้บังปุ่มยกเลิก/เสียง */

/* ---------- หน้าเข้าสู่ระบบ ---------- */
.login-wrap { min-height: calc(100vh - var(--topbar)); }
.login-card { width: min(420px, 100%); border-radius: 20px; padding: 32px 30px 26px; border-color: var(--line); box-shadow: 0 10px 30px rgba(27, 37, 89, .08); gap: 16px; }
.login-card h1 { font-size: 24px; }
.login-card .btn { min-height: 48px; font-size: 16px; border-radius: 12px; }
.login-card input[type=text], .login-card input[type=password] { min-height: 46px; font-size: 16px; }

/* ---------- ผู้ใช้กลุ่มสาระ ---------- */
.area-nav { top: var(--topbar); gap: 6px; padding: 8px 24px; }
.area-nav a { border-radius: 999px; font-weight: 600; color: var(--ink-2); }
.area-nav a.on { background: var(--accent); color: #fff; }
.area-card { border-radius: 20px; border-color: var(--line); box-shadow: var(--shadow); }
.area-card b { color: var(--navy); }

/* ---------- จอเล็ก ---------- */
@media (max-width: 900px) {
    .topbar { padding: 8px 14px; }
    .sidebar { top: 0; width: 290px; max-width: 86vw; height: 100vh; z-index: 45; border-right: 0; }
    .nav-toggle:checked ~ .layout .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(27, 37, 89, .4); }
    .nav-btn { border-radius: 10px; border-color: var(--field); padding: 4px 10px; }
    .main { padding: 16px 16px 56px; }
    .area-nav { top: 0; padding: 8px 14px; }
    .phases { grid-template-columns: minmax(0, 1fr); }
    body:has(#chatDock) .tt-bar { padding-right: 18px; padding-bottom: 72px; } /* มือถือ: แถบมีหลายแถว เว้นแถวล่างให้ปุ่มแชทแทน */
}
@media (max-width: 640px) {
    .brand img { width: 40px; height: 40px; }
    /* แถบบนบนมือถือ 2 แถว: เมนู + ชื่อระบบ + คนออนไลน์ + ผู้ใช้ / ภาคเรียน */
    .topbar { gap: 8px 10px; }
    .brand { flex: 1 1 0; }
    .online-bar { order: 0; }
    .online-none { display: none; }
    .um-t { display: none; }
    .pagehead h1 { font-size: 23px; }
    .actions { justify-content: flex-start; }
    .dash-next .btn { width: 100%; justify-content: center; }
    .dash-next .dn-ic { display: none; }
    .phase { padding: 12px; }
    .phase .steps { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
    .step { padding: 10px 12px; }
    .step .v { font-size: 21px; }
}

}
