
@import url('https://fonts.googleapis.com/css2?family=Mitr:wght@300;400;500;600;700&family=Prompt:wght@300;400;500;600;700&display=swap');

/* 2. กำหนดเงื่อนไขดึงฟอนต์ Prompt มาแสดงผลเฉพาะตัวเลข (unicode-range) */
@font-face {
  font-family: 'PromptNumbers';
  src: local('Prompt');
  unicode-range: U+0030-0039, U+0E50-0E59;
}

/* ===================== Design Tokens (Clean Light Mode) ===================== */
:root {
  --bg: #F0F2F5;
  --surface: #FFFFFF;
  --surface-alt: #F7F8FA;
  --surface-hover: #E4E6EB;
  
  --ink: #050505;
  --ink-soft: #65676B;
  --ink-faint: #8A8D91;
  --line: #CED0D4;
  --line-light: #E4E6EB;

  /* Facebook Core Blue Palette */
  --fb-blue: #1877F2;
  --fb-blue-hover: #166FE5;
  --fb-blue-soft: #E7F3FF;
  --fb-blue-line: #AAC9FF;

  /* Accent Status Colors */
  --green: #2ECC71;      --green-soft: #E8F8F0;
  --orange: #F39C12;     --orange-soft: #FEF5E7;
  --red: #E74C3C;        --red-soft: #FCEAE9;
  --purple: #9B59B6;     --purple-soft: #F4ECF7;
  --teal: #1ABC9C;       --teal-soft: #E8F6F3;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.15);

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --sidebar-w: 260px;
  --fast: .15s ease; --med: .25s cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }
html, body, button, input, select, textarea, table, th, td, label, span, div, p, h1, h2, h3, h4, h5, h6, a {
  font-family: 'PromptNumbers', 'Mitr', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--fb-blue-soft); color: var(--fb-blue); }

/* ===================== Print Font Rule ===================== */
@media print {
  body, * {
    font-family: 'TH Sarabun New', 'TH Sarabun PSK', sans-serif !important;
  }
}

/* ===================== Pixel Art Icon Rendering ===================== */
.px-icon {
  display: inline-block;
  vertical-align: middle;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  flex-shrink: 0;
}
.px-icon svg {
  display: block;
  shape-rendering: crispEdges;
}

/* ===================== Layout / Shell ===================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  color: var(--ink);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  border-right: 1px solid var(--line-light);
  box-shadow: var(--shadow-sm);
  transition: transform var(--med);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.sidebar > * { flex-shrink: 0; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 14px;
  border-bottom: 1px solid var(--line-light);
}
.brand-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  background: var(--fb-blue);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(24, 119, 242, 0.3);
}
.brand strong { display: block; font-size: 16px; font-weight: 600; color: var(--ink); }
.brand small { color: var(--ink-soft); font-size: 11.5px; }
.sidebar-close {
  display: none;
  margin-left: auto;
  background: var(--surface-hover);
  border: 0;
  color: var(--ink-soft);
  font-size: 20px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--r-pill);
  line-height: 1;
}

.sidebar nav { display: grid; gap: 4px; }
.nav-btn, .ghost-btn {
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--r-md);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  transition: background var(--fast), color var(--fast);
}
.nav-btn:hover, .ghost-btn:hover { background: var(--surface-hover); }
.nav-btn.active {
  background: var(--fb-blue-soft);
  color: var(--fb-blue);
  font-weight: 600;
}

.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line-light);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 45;
  opacity: 0;
  transition: opacity var(--med);
}
.sidebar-overlay.show { display: block; opacity: 1; }

.hamburger-btn {
  display: none;
  border: 1px solid var(--line);
  background: var(--surface);
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 18px;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  flex: none;
}

.main {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  padding: 20px 28px 60px;
  transition: margin var(--med), padding var(--med);
}

/* ===================== Topbar ===================== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  background: var(--surface);
  padding: 12px 18px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-light);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar h1 { margin: 0; font-size: 22px; font-weight: 600; color: var(--ink); }
.topbar p { margin: 2px 0 0; color: var(--ink-soft); font-size: 12.5px; }

.top-actions {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.top-field-wrap {
  display: flex;
  flex-direction: column;
}
.top-field-wrap label {
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 600;
  margin-bottom: 3px;
}
.term-select-top {
  font-weight: 600 !important;
  color: var(--fb-blue) !important;
  background: var(--fb-blue-soft) !important;
  border-color: var(--fb-blue-line) !important;
  min-width: 130px;
}

/* ===================== Pages ===================== */
.page { display: none; }
.page.active { display: block; animation: pageIn .25s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===================== Hero ===================== */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #1877F2 0%, #0056C6 100%);
  border-radius: var(--r-lg);
  padding: 24px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(24, 119, 242, 0.25);
}
.hero h2 { margin: 4px 0 6px; font-size: 24px; font-weight: 600; }
.hero p { margin: 0; color: rgba(255, 255, 255, 0.9); font-size: 13.5px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 1.2px; color: #AAC9FF; text-transform: uppercase; }

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.hero .primary {
  background: #FFFFFF;
  color: var(--fb-blue);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.hero .primary:hover { background: #F0F2F5; transform: translateY(-1px); }

.tablet-toggle-btn {
  background: rgba(255, 255, 255, 0.18);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  color: #FFFFFF;
  border-radius: var(--r-md);
  padding: 9px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  transition: all var(--fast);
  backdrop-filter: blur(4px);
}
.tablet-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

/* ===================== Cards & Panels ===================== */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card, .panel {
  background: var(--surface);
  border: 1px solid var(--line-light);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--fast), transform var(--fast);
}
.stat-card {
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-card:hover, .panel:hover { box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.stat-card:nth-of-type(1) .stat-icon { background: var(--fb-blue-soft); }
.stat-card:nth-of-type(2) .stat-icon { background: var(--purple-soft); }
.stat-card:nth-of-type(3) .stat-icon { background: var(--green-soft); }
.stat-card:nth-of-type(4) .stat-icon { background: var(--orange-soft); }

.stat-info span { display: block; color: var(--ink-soft); font-size: 13px; font-weight: 500; }
.stat-info b { display: block; font-size: 24px; margin: 2px 0 0; font-weight: 600; color: var(--ink); }
.stat-info small { color: var(--ink-faint); font-size: 12px; }

.panel { padding: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 16.5px; font-weight: 600; }

/* ===================== Large Hero Quick Action Cards ===================== */
.dashboard-big-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.big-action-card {
  border: 1px solid var(--line-light);
  background: var(--surface-alt);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  text-align: left;
  cursor: pointer;
  transition: all var(--fast);
  position: relative;
  overflow: hidden;
}
.big-action-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.big-action-card.card-att {
  border-left: 6px solid var(--green);
}
.big-action-card.card-att:hover {
  background: var(--green-soft);
  border-color: #A3E4D7;
}
.big-action-card.card-task {
  border-left: 6px solid var(--orange);
}
.big-action-card.card-task:hover {
  background: var(--orange-soft);
  border-color: #FAD7A0;
}

.big-action-char {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.card-att .big-action-char { background: #E8F8F0; }
.card-task .big-action-char { background: #FEF5E7; }

.big-action-content { flex: 1; }
.big-action-content h4 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}
.big-action-content p {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.4;
}
.action-btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 600;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.06);
}
.card-att .action-btn-pill { color: #27AE60; }
.card-task .action-btn-pill { color: #D35400; }

/* ===================== Toolbar ===================== */
.toolbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.toolbar h2 { margin: 0; font-size: 20px; font-weight: 600; }
.toolbar p { margin: 2px 0; color: var(--ink-soft); font-size: 13px; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar > div > label, .form-row label { display: block; color: var(--ink-soft); font-size: 12px; margin-bottom: 4px; font-weight: 500; }

/* ===================== Buttons & Inputs ===================== */
button.primary, button.secondary {
  border: 0;
  border-radius: var(--r-md);
  padding: 9px 16px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  min-height: 40px;
  transition: background var(--fast), transform var(--fast), box-shadow var(--fast), color var(--fast);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
.primary {
  background: var(--fb-blue);
  color: #fff;
  box-shadow: 0 2px 6px rgba(24, 119, 242, 0.3);
}
.primary:hover { background: var(--fb-blue-hover); transform: translateY(-1px); }
.secondary {
  background: var(--surface-hover);
  color: var(--ink);
  border: 1px solid var(--line-light);
}
.secondary:hover { background: #D8DADF; }
button.danger.secondary { color: var(--red); }
button.danger.secondary:hover { background: var(--red-soft); }

select, input {
  font: inherit;
  font-size: 13.5px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 8px 12px;
  background: var(--surface);
  outline: none;
  min-height: 40px;
  color: var(--ink);
  transition: border-color var(--fast), box-shadow var(--fast);
}
select:focus, input:focus {
  border-color: var(--fb-blue);
  box-shadow: 0 0 0 3px var(--fb-blue-soft);
}

/* ===================== Tables ===================== */
.table-wrap { overflow: auto; border-radius: var(--r-md); border: 1px solid var(--line-light); }
.table-panel { padding-bottom: 10px; }
table { border-collapse: collapse; width: 100%; min-width: 700px; background: #fff; }
th { background: var(--surface-alt); color: var(--ink-soft); font-size: 12px; font-weight: 600; position: sticky; top: 0; z-index: 1; }
th, td { border-bottom: 1px solid var(--line-light); padding: 10px 12px; text-align: left; white-space: nowrap; }
td { font-size: 13.5px; }
td input.score-input { width: 70px; text-align: center; padding: 6px; min-height: 36px; }
tbody tr:hover td { background: var(--surface-alt); }

.grade { display: inline-flex; min-width: 36px; justify-content: center; border-radius: var(--r-pill); padding: 4px 8px; background: var(--fb-blue-soft); color: var(--fb-blue); font-weight: 600; font-size: 12px; }
.grade.special { background: var(--red-soft); color: var(--red); }

.small-btn {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
  cursor: pointer;
  min-height: 32px;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.small-btn:hover { background: var(--surface-hover); }
.danger { color: var(--red); border: 0; background: none; cursor: pointer; font: inherit; font-weight: 500; }

.status-select { font-size: 12px; padding: 4px 8px; border-radius: var(--r-sm); min-height: 34px; }

/* ===================== Attendance & Tasks ===================== */
.attendance-list { display: flex; flex-direction: column; }
.attendance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line-light);
  flex-wrap: wrap;
}
.attendance-row:last-child { border-bottom: 0; }
.attendance-row:hover { background: var(--surface-alt); }
.attendance-name { min-width: 150px; }
.attendance-name b { display: block; font-size: 14px; font-weight: 600; }
.attendance-name small { color: var(--ink-soft); font-size: 12px; }

.attendance-btns { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; justify-content: flex-end; }
.att-btn {
  --att-color: var(--fb-blue);
  border: 1.5px solid var(--att-color);
  background: #fff;
  color: var(--att-color);
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  min-height: 38px;
  transition: all var(--fast);
}
.att-btn:hover { background: var(--surface-hover); }
.att-btn.active { background: var(--att-color); color: #fff; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15); }

/* ===================== Bottom Save Action Bar ===================== */
.bottom-save-bar {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

.grade.att-good { background: var(--green-soft); color: var(--green); }
.grade.att-ok { background: var(--orange-soft); color: var(--orange); }
.grade.att-low { background: var(--red-soft); color: var(--red); }

/* ===================== Tablet Bottom Navigation Bar ===================== */
.tablet-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 66px;
  background: #FFFFFF;
  border-top: 1px solid var(--line-light);
  box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.08);
  z-index: 90;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
}
.tablet-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ink-soft);
  background: none;
  border: 0;
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 0;
  cursor: pointer;
}
.tablet-nav-item.active {
  color: var(--fb-blue);
  font-weight: 600;
}
.tablet-nav-item .px-icon {
  width: 24px;
  height: 24px;
}

/* ===================== Optimized Tablet View Mode (.tablet-mode) ===================== */
body.tablet-mode .sidebar {
  transform: translateX(-100%) !important;
}
body.tablet-mode .main {
  margin-left: 0 !important;
  width: 100% !important;
  padding: 16px 20px 88px !important;
}
body.tablet-mode .hamburger-btn {
  display: inline-flex !important;
}
body.tablet-mode .tablet-bottom-nav {
  display: grid !important;
}
body.tablet-mode .hero {
  padding: 22px 24px;
}
body.tablet-mode .hero-actions {
  margin-top: 6px;
}
body.tablet-mode .cards {
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
body.tablet-mode .dashboard-big-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
body.tablet-mode .toolbar {
  gap: 10px;
}
body.tablet-mode .attendance-row {
  padding: 14px 10px;
}
body.tablet-mode .att-btn {
  min-height: 44px;
  padding: 9px 18px;
  font-size: 14px;
}
body.tablet-mode td input.score-input {
  width: 78px;
  min-height: 40px;
  font-size: 14.5px;
}
body.tablet-mode .bottom-save-bar {
  position: sticky;
  bottom: 66px;
  z-index: 40;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.07);
}

/* ===================== Modal ===================== */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: grid; place-items: center; padding: 20px; z-index: 60; backdrop-filter: blur(2px); }
.modal.hidden { display: none; }
.modal-card {
  background: #fff;
  width: min(580px, 100%);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow: auto;
  animation: modalIn var(--med);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-head button { border: 0; background: var(--surface-hover); font-size: 18px; cursor: pointer; color: var(--ink-soft); width: 32px; height: 32px; border-radius: var(--r-pill); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row { margin: 10px 0; }
.form-row input, .form-row select { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ===================== Toast & Loading ===================== */
.toast {
  position: fixed; right: 20px; bottom: 20px; background: #242526; color: #fff;
  padding: 12px 18px; border-radius: var(--r-md); opacity: 0; transform: translateY(10px);
  transition: .2s; z-index: 100; box-shadow: var(--shadow-lg); font-size: 13.5px;
}
.toast.show { opacity: 1; transform: none; }

.loading { position: fixed; inset: 0; background: rgba(240, 242, 245, 0.7); display: grid; place-items: center; z-index: 110; }
.loading.hidden { display: none; }
.spinner { width: 36px; height: 36px; border: 3.5px solid var(--fb-blue-soft); border-top-color: var(--fb-blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== Reports & Bars ===================== */
.report-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 14px 0; }
.report-stat { padding: 14px; background: var(--surface-alt); border-radius: var(--r-md); border: 1px solid var(--line-light); }
.report-stat small { display: block; color: var(--ink-soft); font-size: 12px; }
.report-stat b { font-size: 20px; font-weight: 600; color: var(--ink); }

.grade-bars { display: grid; gap: 8px; }
.grade-bar { display: grid; grid-template-columns: 80px 1fr 80px; gap: 8px; align-items: center; font-size: 12.5px; }
.bar { height: 8px; background: var(--surface-hover); border-radius: var(--r-pill); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: var(--r-pill); }

.empty { padding: 40px 20px; text-align: center; color: var(--ink-soft); }

/* ===================== Responsive Normal ===================== */
@media(max-width: 1024px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .report-grid { grid-template-columns: repeat(2, 1fr); }
}

@media(max-width: 880px) {
  .hamburger-btn { display: inline-flex; }
  .sidebar-close { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar { transform: translateX(-100%); width: 280px; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; width: 100%; padding: 14px; }
}

@media(max-width: 700px) {
  .dashboard-big-grid { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: flex-start; padding: 22px; }
  .hero button { width: 100%; }
  .cards, .report-grid { grid-template-columns: 1fr; }
  .attendance-row { flex-direction: column; align-items: stretch; }
  .attendance-btns { justify-content: flex-start; }
}

/* ===== ปุ่มเช็คชื่ออยู่แถวเดียวบนมือถือ ===== */
.att-btn .lbl-short{display:none}
@media(max-width:700px){
  .attendance-row{flex-direction:column;align-items:stretch;gap:8px}
  .attendance-btns{flex-wrap:nowrap;gap:5px;justify-content:stretch}
  .att-btn{flex:1 1 0;min-width:0;padding:8px 2px;font-size:13px;
    white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .att-btn .lbl-full{display:none}
  .att-btn .lbl-short{display:inline}
}
@media(max-width:420px){
  .attendance-btns{gap:4px}
  .att-btn{font-size:12px;padding:8px 1px}
}

/* ===================== Firebase version additions ===================== */
/* สิทธิ์: ซ่อนปุ่มของผู้ดูแลจากครู (ฝั่งเซิร์ฟเวอร์บังคับด้วย firestore.rules อีกชั้น) */
body:not(.is-admin) .admin-only { display: none !important; }
body.is-admin .teacher-only { display: none !important; }
body:not(.has-homeroom) .homeroom-only { display: none !important; }

/* ---------- หน้าเข้าสู่ระบบ ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 200; display: none; place-items: center; padding: 20px;
  background: radial-gradient(120% 120% at 100% 0%, #E7F3FF 0%, #F0F2F5 55%);
}
body.logged-out .login-screen { display: grid; }
body.logged-out .app-shell, body.logged-out .tablet-bottom-nav { display: none !important; }
.login-card {
  width: min(400px, 100%); background: #fff; border-radius: 20px; padding: 32px 28px 24px; text-align: center;
  box-shadow: 0 20px 50px rgba(24, 119, 242, .15); border: 1px solid var(--line-light);
}
.login-logo { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 18px; }
.login-card h1 { margin: 0; font-size: 26px; font-weight: 600; }
.login-sub { margin: 4px 0 22px; color: var(--ink-soft); font-size: 13.5px; }
.google-btn {
  width: 100%; min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; font: inherit; font-size: 15px; font-weight: 500;
  cursor: pointer; transition: box-shadow var(--fast), background var(--fast);
}
.google-btn:hover { background: var(--surface-alt); box-shadow: var(--shadow-md); }
.login-msg { margin-top: 14px; font-size: 13px; color: var(--red); line-height: 1.6; }
.login-msg:empty { display: none; }
.login-foot { margin: 20px 0 0; font-size: 11.5px; color: var(--ink-faint); line-height: 1.6; }

/* ---------- ผู้ใช้ที่มุมล่างของเมนู ---------- */
.me-box { display: flex; align-items: center; gap: 10px; padding: 10px 8px 2px; margin-top: 6px; border-top: 1px solid var(--line-light); }
.me-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--fb-blue-soft); color: var(--fb-blue); display: grid; place-items: center; font-weight: 600; flex: none; }
.me-info { flex: 1; min-width: 0; }
.me-info b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-info small { font-size: 11.5px; color: var(--ink-soft); }
.net-badge { color: var(--green); font-weight: 600; }
.net-badge.off { color: var(--red); }

/* ---------- ปุ่มสลับ รายวิชา | ประจำชั้น ---------- */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line-light); border-radius: 999px; padding: 4px; gap: 4px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.seg-btn { border: 0; background: transparent; border-radius: 999px; padding: 8px 18px; min-height: 40px; font: inherit; font-size: 14px; font-weight: 500; color: var(--ink-soft); cursor: pointer; transition: background var(--fast), color var(--fast); }
.seg-btn.active { background: var(--fb-blue); color: #fff; box-shadow: 0 2px 6px rgba(24, 119, 242, .3); }
@media (max-width: 700px) { .seg { display: flex; } .seg-btn { flex: 1; } }

/* ---------- ป้ายผลเช็คชื่อประจำชั้นตอนเช้า ---------- */
.hr-badge {
  --hr-color: #8A8D91;
  display: inline-flex; align-items: center; margin-top: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500;
  color: var(--hr-color); background: color-mix(in srgb, var(--hr-color) 12%, #fff); border: 1px solid color-mix(in srgb, var(--hr-color) 35%, #fff);
}
.hr-badge.alert { color: #B42318; background: #FEF3F2; border-color: #FDA29B; font-weight: 600; }
.hr-slot:empty { display: none; }

/* ---------- แถบแจ้งเตือนในหน้าเช็คชื่อ ---------- */
.pending-bar { display: none; margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.6; background: var(--fb-blue-soft); color: #0B4FA8; }
.pending-bar.warn { background: #FFF3DF; color: #8A5A00; }

/* ---------- บุคลากร ---------- */
.role-chip, .room-chip, .state-chip { display: inline-flex; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-hover); color: var(--ink-soft); }
.role-chip.admin { background: var(--fb-blue-soft); color: var(--fb-blue); }
.room-chip { background: var(--green-soft); color: #1E8449; }
.state-chip.on { background: var(--green-soft); color: #1E8449; }
.state-chip.off { background: var(--red-soft); color: var(--red); }

.info-box { background: var(--fb-blue-soft); color: #0B4FA8; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.6; margin: 10px 0; }
.legacy-log { white-space: pre-wrap; background: var(--surface-alt); border: 1px solid var(--line-light); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; min-height: 0; margin: 10px 0 0; font-family: inherit; }
.legacy-log:empty { display: none; }

body.no-scroll { overflow: hidden; }
.hr-slot { margin-left: 6px; }
@media (max-width: 700px) {
  .bottom-save-bar button { flex: 1; white-space: nowrap; font-size: 13.5px; padding: 9px 8px; }
}

/* โลโก้ ClassHub (หมวกบัณฑิตพิกเซล) */
.brand-avatar { background: linear-gradient(135deg, #2D8CFF, #1060D8); }
.login-logo { width: 72px; height: 72px; }

/* ---------- นำเข้ารายชื่อนักเรียน ---------- */
.import-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 12px 0 6px; flex-wrap: wrap; }
.import-list { max-height: 320px; overflow: auto; border: 1px solid var(--line-light); border-radius: 12px; }
.import-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line-light); cursor: pointer; }
.import-item:last-child { border-bottom: 0; }
.import-item input { width: 18px; height: 18px; min-height: 0; flex: none; }
.import-item.disabled { opacity: .55; cursor: not-allowed; }
.ii-main { flex: 1; min-width: 0; font-size: 13.5px; }
.ii-main small { color: var(--ink-soft); margin-left: 4px; }
.ii-note { display: block; color: #8A5A00 !important; margin-left: 0 !important; }
.ii-count { font-weight: 600; font-size: 13px; white-space: nowrap; }
.import-sum { font-size: 13.5px; margin: 10px 0 0; }
.import-opts { display: grid; gap: 6px; margin-top: 12px; font-size: 13px; }
.import-opts input { width: auto; min-height: 0; margin-right: 6px; vertical-align: middle; }
.ii-fix { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 12px; color: var(--ink-soft); }
.ii-fix input { width: 56px; min-height: 0; padding: 3px 6px; font-size: 12px; }

/* ---------- นำเข้ารายวิชา ---------- */
.tt-group > summary { list-style: none; }
.tt-group > summary::-webkit-details-marker { display: none; }
.tt-group[open] > summary { background: var(--fb-blue-soft, #EAF3FF); }
.tt-sub { display: flex; align-items: center; gap: 10px; padding: 7px 12px 7px 34px; border-bottom: 1px solid var(--line-light); font-size: 13px; cursor: pointer; }
.tt-sub input { width: 16px; height: 16px; min-height: 0; flex: none; }
.tt-sub small { display: block; color: var(--ink-soft); margin-left: 0; }
.tt-sub .tt-ok { color: #1A7F4B; }
.tt-tag { font-size: 11px; background: #EEF0F4; color: var(--ink-soft); padding: 2px 8px; border-radius: 99px; white-space: nowrap; }

/* ---------- มุมมอง / เมนู ---------- */
body:not(.is-admin-role) .admin-role-only { display: none !important; }
.view-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; background: var(--surface-alt); border: 1px solid var(--line-light); border-radius: 12px; padding: 3px; margin: 0 4px 10px; }
.view-switch button { border: 0; background: transparent; border-radius: 9px; padding: 7px 4px; font: inherit; font-size: 12.5px; font-weight: 500; color: var(--ink-soft); cursor: pointer; min-height: 0; }
.view-switch button.active { background: var(--surface); color: var(--fb-blue); box-shadow: var(--shadow-sm); font-weight: 600; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--ink-faint); padding: 12px 14px 4px; }
nav .nav-label:first-child { padding-top: 2px; }

/* ---------- งานสอนของฉัน ---------- */
#page-mywork .panel, #page-reports .panel.homeroom-only, #unassignedBox .panel { margin-bottom: 16px; }
.mw-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.mw-head h3, .am-h { margin: 0 0 2px; font-size: 16px; }
.mw-head p { margin: 0; color: var(--ink-soft); font-size: 13px; }
.mw-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.mw-tools input { min-width: 200px; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.room-pick { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 10px 12px; border: 1.5px solid var(--line-light); background: var(--surface); border-radius: 12px; font: inherit; text-align: left; cursor: pointer; min-height: 0; transition: border-color var(--fast), background var(--fast); }
.room-pick:hover { border-color: var(--fb-blue-line); }
.room-pick b { font-size: 15px; }
.room-pick small { color: var(--ink-soft); font-size: 12px; }
.room-pick i { font-style: normal; font-size: 11.5px; color: var(--fb-blue); font-weight: 600; }
.room-pick.on { border-color: var(--fb-blue); background: var(--fb-blue-soft); }
.mw-count { margin: 0 0 10px; color: var(--ink-soft); font-size: 13px; }
.mw-group { border: 1px solid var(--line-light); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.mw-group-h { background: var(--surface-alt); padding: 7px 12px; font-weight: 600; font-size: 13.5px; }
.mw-sub { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line-light); }
.mw-sub.on { background: #F2F8FF; }
.mw-sub-main { min-width: 0; }
.mw-sub-main b { font-weight: 500; font-size: 14px; }
.mw-sub-main small { display: block; color: var(--ink-soft); font-size: 12px; }
.mw-sub .small-btn { white-space: nowrap; flex: none; }
.mw-free { color: #8A5A00; }
.am-list { max-height: 46vh; overflow: auto; }

/* ---------- นำเข้า / ส่งออก ---------- */
.io-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.io-card { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; background: var(--surface); border: 1px solid var(--line-light); border-radius: 16px; padding: 18px; font: inherit; cursor: pointer; box-shadow: var(--shadow-sm); min-height: 0; transition: border-color var(--fast), transform var(--fast); }
.io-card:hover { border-color: var(--fb-blue-line); transform: translateY(-1px); }
.io-card b { font-size: 15.5px; }
.io-card span { color: var(--ink-soft); font-size: 13px; line-height: 1.5; }

/* ---------- วิชาที่ยังไม่มีครู ---------- */
.unassigned-list { display: none; max-height: 360px; overflow: auto; border-top: 1px solid var(--line-light); }
#unassignedBox .panel.open .unassigned-list { display: block; }
.ua-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line-light); font-size: 13.5px; }
.ua-row select { max-width: 220px; min-height: 0; padding: 5px 8px; font-size: 13px; }

/* ---------- ผลการเรียนห้องประจำชั้น ---------- */
.hg-table th { font-size: 12px; text-align: center; vertical-align: bottom; min-width: 64px; }
.hg-table th small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 10.5px; white-space: normal; max-width: 90px; margin: 0 auto; }
.hg-table td { text-align: center; }
.hg-table td.hg-name, .hg-table th:nth-child(2) { text-align: left; white-space: nowrap; }
.hg-bad { color: var(--red); font-weight: 600; }
.hg-na { color: var(--ink-faint); }

@media (max-width: 640px) {
  .mw-tools, .mw-tools input, .mw-tools select { width: 100%; min-width: 0; }
  .ua-row { flex-direction: column; align-items: stretch; }
  .ua-row select { max-width: none; }
}

.mw-btn { flex: none; border: 1.5px solid var(--fb-blue); background: var(--surface); color: var(--fb-blue); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; min-height: 0; white-space: nowrap; }
.mw-btn:hover { background: var(--fb-blue-soft); }
.mw-btn.on { background: var(--fb-blue); color: #fff; }
.mw-btn.on:hover { background: var(--red); border-color: var(--red); }
.mw-btn.on:hover::after { content: ' • เลิกสอน'; }

@media (max-width: 640px) { .room-grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; } .room-pick { padding: 8px 9px; } }

.pt-list { max-height: 52vh; overflow: auto; border: 1px solid var(--line-light); border-radius: 12px; }
.pt-row { display: grid; grid-template-columns: 1fr 240px; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line-light); }
.pt-row:last-child { border-bottom: 0; }
.pt-row small { display: block; color: var(--ink-soft); font-size: 12px; }
.pt-row input { min-height: 0; padding: 7px 10px; }
@media (max-width: 640px) { .pt-row { grid-template-columns: 1fr; } }

/* ---------- ระหว่างตรวจสอบการเข้าสู่ระบบ ---------- */
.auth-wait { display: none; align-items: center; justify-content: center; gap: 10px; min-height: 48px; color: var(--ink-soft); font-size: 14px; }
body.auth-pending .auth-wait { display: flex; }
body.auth-pending .google-btn, body.auth-pending .login-foot { display: none; }
.auth-spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--fb-blue-soft); border-top-color: var(--fb-blue); animation: authspin .8s linear infinite; }
@keyframes authspin { to { transform: rotate(360deg); } }

/* ---------- หน้านักเรียน: แยกห้อง ---------- */
.stu-bar { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 8px; }
.stu-rooms { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.stu-room { border: 1.5px solid var(--line-light); background: var(--surface); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; min-height: 0; display: inline-flex; gap: 6px; align-items: center; }
.stu-room small { font-size: 11.5px; color: var(--ink-soft); background: var(--surface-alt); border-radius: 999px; padding: 0 7px; }
.stu-room.on { border-color: var(--fb-blue); background: var(--fb-blue); color: #fff; }
.stu-room.on small { background: rgba(255,255,255,.25); color: #fff; }
#stuSearch { width: 220px; }
.stu-sep td { background: var(--surface-alt); font-weight: 600; font-size: 13px; padding-top: 6px; padding-bottom: 6px; }
@media (max-width: 640px) { #stuSearch { width: 100%; } }

/* ---------- วิชาเรียนรวม ---------- */
.comb-chip { display: inline-block; font-size: 11px; background: var(--purple-soft); color: var(--purple); border-radius: 999px; padding: 1px 8px; margin-left: 4px; font-weight: 600; }
.room-tag { display: inline-block; font-size: 11px; background: var(--fb-blue-soft); color: var(--fb-blue); border-radius: 6px; padding: 0 6px; margin-left: 6px; font-weight: 600; vertical-align: middle; }
.att-roombar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; font-size: 13px; color: var(--ink-soft); }

/* ---------- ตารางบันทึกคะแนน: ตรึงรหัส + ชื่อนักเรียนไว้ด้านซ้าย ---------- */
#scoreTable .sc-id, #scoreTable .sc-name { position: sticky; z-index: 2; background: #fff; }
#scoreTable th.sc-id, #scoreTable th.sc-name { z-index: 4; background: var(--surface-alt); }
#scoreTable .sc-id { left: 0; width: 72px; min-width: 72px; max-width: 72px; }
#scoreTable .sc-name { left: 72px; box-shadow: 6px 0 8px -6px rgba(15, 23, 42, .25); }
#scoreTable tbody tr:hover .sc-id, #scoreTable tbody tr:hover .sc-name { background: #F7F9FC; }
#scoreTable .sc-sid { display: none; }
@media (max-width: 760px) {
  #scoreTable .sc-id { display: none; }
  #scoreTable .sc-name { left: 0; white-space: normal; min-width: 112px; max-width: 132px; padding: 8px 8px; line-height: 1.3; }
  #scoreTable .sc-nm { display: block; font-size: 13px; }
  #scoreTable .sc-sid { display: block; font-size: 11px; color: var(--ink-soft); }
  #scoreTable .sc-rt { display: none; }
  #scoreTable .sc-sid .room-tag { margin-left: 4px; }
}

/* =================== หน้าแรก (Dashboard) =================== */
.dash-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; background: linear-gradient(135deg, #2D8CFF, #1060D8); color: #fff; border-radius: 20px; padding: 22px 24px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.dash-hero .eyebrow { color: rgba(255,255,255,.8); }
.dash-hero h2 { margin: 4px 0 2px; font-size: 24px; color: #fff; }
.dash-hero p { margin: 0; color: rgba(255,255,255,.92); font-size: 14px; }
.dash-hero .hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-refresh { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 12px; padding: 8px 14px; font: inherit; cursor: pointer; min-height: 0; }
.dash-loading { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 40px; color: var(--ink-soft); }
.dash-empty { text-align: center; padding: 30px; }
.dsec { background: var(--surface); border: 1px solid var(--line-light); border-radius: 18px; padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.dsec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.dsec-h h3 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.dmuted { color: var(--ink-soft); font-size: 12px; }
.dcount { display: inline-flex; min-width: 22px; height: 22px; padding: 0 7px; align-items: center; justify-content: center; border-radius: 999px; background: var(--red); color: #fff; font-size: 12px; font-weight: 600; }
.dok { padding: 10px 12px; background: #ECFAF2; color: #11744A; border-radius: 12px; font-size: 14px; }
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tcard { position: relative; border: 1px solid var(--line-light); border-left: 5px solid var(--line-light); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; background: var(--surface); }
.tcard.ok { border-left-color: #0EA968; } .tcard.warn { border-left-color: #F0A020; } .tcard.bad { border-left-color: #E5484D; background: #FFF7F7; }
.tcard-top { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--ink-soft); flex-wrap: wrap; }
.tcard-state { font-weight: 600; }
.tcard.ok .tcard-state { color: #0E8A57; } .tcard.bad .tcard-state { color: #C93439; } .tcard.warn .tcard-state { color: #A86A00; }
.tcard-name { font-size: 15.5px; margin-top: 2px; }
.tcard small { color: var(--ink-soft); }
.tcard-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.tcard-actions button { flex: 1; min-height: 40px; padding: 8px 10px; font-size: 14px; }
.dmore { margin-top: 10px; } .dmore summary { cursor: pointer; color: var(--fb-blue); font-size: 14px; margin-bottom: 10px; }
.hchips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.hchips span { font-size: 12px; padding: 1px 8px; border-radius: 999px; color: var(--c); border: 1px solid var(--c); }
.hwatch { margin-top: 8px; font-size: 13px; background: var(--surface-alt); border-radius: 10px; padding: 8px 10px; }
.hwatch b { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 2px; }
.hwatch small { color: var(--red); margin-left: 4px; }
.hgpa { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; }
.hgpa b { font-size: 22px; color: var(--fb-blue); }
.dlist { border: 1px solid var(--line-light); border-radius: 12px; overflow: hidden; }
.drow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line-light); font-size: 13.5px; }
.drow:first-child { border-top: 0; }
.drow .small-btn { flex: none; white-space: nowrap; }
.dlist .drow.more { display: none; } .dlist.all .drow.more { display: flex; }
.dlink { background: none; border: 0; color: var(--fb-blue); font: inherit; font-size: 13.5px; cursor: pointer; padding: 8px 2px 0; min-height: 0; }
.dchip { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; margin: 3px 4px 0 0; }
.dchip.bad { background: #FDECEC; color: #B4282D; }
.dstate { font-size: 12.5px; font-weight: 600; white-space: nowrap; } .dstate.ok { color: #0E8A57; } .dstate.bad { color: #C93439; }
.dbar { flex: 1; height: 8px; background: var(--surface-alt); border-radius: 99px; overflow: hidden; min-width: 60px; }
.dbar i { display: block; height: 100%; background: var(--fb-blue); border-radius: 99px; }
.dbar.green i { background: #0EA968; } .dbar.red i { background: #E5484D; } .dbar.blue i { background: var(--fb-blue); }
.sgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.scard { border: 1px solid var(--line-light); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.scard > small { color: var(--ink-soft); margin-top: -4px; }
.srow, .dprog > div { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.srow span, .dprog span { width: 74px; color: var(--ink-soft); flex: none; }
.srow em, .dprog em { font-style: normal; font-weight: 600; min-width: 42px; text-align: right; }
.dprog { display: grid; gap: 8px; margin-bottom: 12px; } .dprog em { min-width: 110px; }
.gbar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-alt); }
.glegend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; }
.glegend b { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 3px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line-light); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; }
.kpi span { color: var(--ink-soft); font-size: 13px; } .kpi b { font-size: 28px; line-height: 1.2; } .kpi small { color: var(--ink-faint); font-size: 12px; }
.heat-wrap table { min-width: 0; }
.heat th, .heat td { text-align: center; padding: 6px 8px; font-size: 12.5px; }
.heat td:first-child, .heat th:first-child { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; }
.heat th:first-child { background: var(--surface-alt); z-index: 3; }
.heat .h0, .heat-legend .h0 { background: #E8F7EF; color: #1B7A4D; } .heat .h1, .heat-legend .h1 { background: #FFF4D6; color: #8A6400; }
.heat .h2, .heat-legend .h2 { background: #FFE0B8; color: #9A4D00; } .heat .h3, .heat-legend .h3 { background: #FFC2B3; color: #A12A12; }
.heat .h4, .heat-legend .h4 { background: #F2777A; color: #fff; }
.heat-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--ink-soft); }
.heat-legend span[class] { padding: 1px 8px; border-radius: 6px; }
.shortcuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.shortcuts button { background: var(--surface-alt); border: 1px solid var(--line-light); border-radius: 14px; padding: 14px; font: inherit; font-size: 14px; text-align: left; cursor: pointer; min-height: 0; }
.shortcuts button:hover { border-color: var(--fb-blue-line); }
@media (max-width: 640px) {
  .dash-hero { padding: 18px; border-radius: 16px; } .dash-hero h2 { font-size: 20px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .dsec { padding: 14px; border-radius: 14px; }
  .tgrid, .sgrid { grid-template-columns: 1fr; }
  .drow { flex-wrap: wrap; } .dprog em { min-width: 70px; }
}

.auth-alt { background: none; border: 0; color: var(--ink-soft); font: inherit; font-size: 12.5px; text-decoration: underline; cursor: pointer; margin-top: 10px; min-height: 0; }
body.auth-pending .auth-alt { display: none; }

/* ---------- ตารางสอนของฉัน ---------- */
.tt-wrap { border-radius: 12px; }
.tt-table { min-width: 860px; table-layout: fixed; }
.tt-table th, .tt-table td { text-align: center; padding: 5px; vertical-align: middle; border: 1px solid var(--line-light); white-space: normal; }
.tt-table thead th { font-size: 12px; } .tt-table thead th small { display: block; font-weight: 400; font-size: 10.5px; color: var(--ink-faint); }
.tt-table .tt-day { width: 78px; position: sticky; left: 0; z-index: 2; background: var(--surface-alt); font-size: 13px; }
.tt-table .tt-day small { display: block; font-size: 10.5px; color: var(--fb-blue); font-weight: 600; }
.tt-table thead .tt-day { z-index: 4; }
.tt-today td, .tt-today .tt-day { background: #F2F8FF; }
.tt-free { background: #FCFCFD; }
.tt-sub-btn { display: flex; flex-direction: column; align-items: center; gap: 0; width: 100%; border: 0; border-radius: 10px; background: var(--fb-blue-soft); color: var(--ink); padding: 6px 4px; font: inherit; cursor: pointer; min-height: 0; line-height: 1.25; }
.tt-sub-btn + .tt-sub-btn { margin-top: 4px; }
.tt-sub-btn:hover { background: #D9E9FF; }
.tt-sub-btn b { font-size: 12.5px; color: var(--fb-blue); } .tt-sub-btn span { font-size: 12px; font-weight: 600; }
.tt-sub-btn small { font-size: 10.5px; color: var(--ink-soft); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-now { box-shadow: inset 0 0 0 3px #F0A020; }
.tt-now .tt-sub-btn { background: #FFF1D6; } .tt-now .tt-sub-btn b { color: #A86A00; }
.tt-legend { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--ink-soft); margin-top: 8px; flex-wrap: wrap; }
.tt-legend span { display: inline-block; width: 14px; height: 14px; border-radius: 4px; }
.tt-l-today { background: #F2F8FF; border: 1px solid #CFE2FF; } .tt-l-now { box-shadow: inset 0 0 0 3px #F0A020; margin-left: 8px; }

