:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1c1f2e;
  --muted: #6b7280;
  --border: #e6e8f0;
  --primary: #7a1f1f;
  --primary-dark: #5c1616;
  --primary-light: #fbe9e8;
  --success: #059669;
  --success-bg: #ecfdf5;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --radius: 16px;
  --shadow: 0 10px 30px -12px rgba(30, 34, 60, 0.18);
}

body.theme-blue {
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --primary-light: #dbeafe;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Prompt", "Segoe UI", system-ui, sans-serif;
  min-height: 100%;
}

a { color: inherit; text-decoration: none; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
}

.brand-mark {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary-light);
}

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  height: 2px;
  width: 18px;
  margin: 0 auto;
  background: var(--text);
  border-radius: 2px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.nav-link {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  border-color: var(--primary);
}

.nav-user {
  font-size: 0.9rem;
  color: var(--muted);
}

.nav-cta.active { box-shadow: 0 0 0 2px var(--primary-light); }

/* เมนูย่อยแบบเลื่อนเมาส์ชี้ (mega menu) — ใช้กับ "วิชาการ" และ "โครงการ" ในแถบเมนู admin */
.nav-dropdown { position: relative; }
.nav-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
}
.nav-dropdown-trigger:hover,
.nav-dropdown.open .nav-dropdown-trigger { color: var(--text); border-color: var(--primary); }
.nav-dropdown-trigger svg { transition: transform 0.15s ease; }
.nav-dropdown.open .nav-dropdown-trigger svg { transform: rotate(180deg); }

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14);
  z-index: 60;
  padding: 8px 0;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu { display: block; }

.nav-dropdown-item {
  display: block;
  padding: 10px 18px;
  color: var(--text);
  font-size: 0.9rem;
}
.nav-dropdown-item:hover { background: #f8f8fb; }
.nav-dropdown-item-desc {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 2px;
  font-weight: 400;
}

.nav-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}

.notif-wrap { position: relative; }

.notif-bell-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14);
  z-index: 60;
  padding: 6px 0;
}

.notif-dropdown-header {
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.notif-item {
  display: block;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: #f8f8fb; }

.notif-item-message {
  font-size: 0.88rem;
  line-height: 1.4;
}

.notif-item-time {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 3px;
}

.notif-empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.inline-form { display: inline; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: #f3f4f8; color: var(--text); }

.btn-outline {
  background: #fff;
  color: var(--primary);
  border-color: var(--primary-light);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-block { width: 100%; }

/* ---------- Layout ---------- */

.page {
  flex: 1;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.footer-link-school {
  display: inline-block;
  margin-top: 6px;
  color: #1d4ed8;
  font-weight: 600;
}

.footer-link-school:hover { text-decoration: underline; }

/* ---------- Flash ---------- */

.flash-stack {
  max-width: 640px;
  margin: 0 auto 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flash {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 500;
}

.flash-success { background: var(--success-bg); color: var(--success); }
.flash-error { background: var(--error-bg); color: var(--error); }
.flash-warning { background: #fffbeb; color: #b45309; }

/* ---------- Auth pages ---------- */

.auth-hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
  padding-top: 24px;
}

.eyebrow {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

.auth-copy h1 {
  font-size: 2.4rem;
  line-height: 1.25;
  margin: 0 0 16px;
}

.lead {
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.7;
  margin: 0 0 24px;
  max-width: 46ch;
}

.instructor-photo {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.auth-card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px;
  border: 1px solid var(--border);
}

.auth-card h2 {
  margin: 0 0 20px;
  font-size: 1.4rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.field input,
.field select {
  font-family: inherit;
  font-size: 0.98rem;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fbfbfe;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: #fff;
}

.switch-line {
  margin: 18px 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.switch-line a { color: var(--primary); font-weight: 600; }

.field-hint {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.radio-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.radio-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfbfe;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.radio-chip:hover { border-color: var(--primary); }

.radio-chip:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}

.radio-chip input {
  accent-color: var(--primary);
}

.color-swatch-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.color-swatch-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfbfe;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.color-swatch-chip:hover { border-color: var(--primary); }

.color-swatch-chip:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}

.color-swatch-chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.dynamic-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.dynamic-list-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dynamic-list-row input[type="text"] {
  flex: 1;
  font-family: inherit;
  font-size: 0.92rem;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fbfbfe;
}

.dynamic-list-no {
  font-weight: 600;
  color: var(--muted);
  min-width: 20px;
}

.slot-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.slot-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slot-row select,
.slot-row input[type="time"] {
  font-family: inherit;
  font-size: 0.92rem;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fbfbfe;
}

.course-pick-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.course-pick-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfbfe;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.course-pick-chip:hover { border-color: var(--primary); }

.course-pick-chip:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.course-pick-chip.is-full {
  opacity: 0.55;
  cursor: not-allowed;
}

.course-pick-chip input { accent-color: var(--primary); }

.course-pick-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.course-pick-title { font-weight: 600; font-size: 0.95rem; }
.course-pick-meta { font-size: 0.85rem; color: var(--muted); }
.course-pick-seats { font-size: 0.85rem; font-weight: 600; color: var(--primary-dark); white-space: nowrap; }

.schedule-conflict-warning {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--error-bg);
  color: var(--error);
  font-size: 0.88rem;
  font-weight: 500;
}

.color-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

/* ---------- Dashboard / courses ---------- */

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.page-head h1 { margin: 0 0 8px; font-size: 1.9rem; }
.page-head .lead { margin: 0; }

.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.filter-bar .field select { min-width: 180px; }

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.course-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 4px solid var(--primary);
  box-shadow: var(--shadow);
}

.course-card h3 { margin: 4px 0 0; font-size: 1.15rem; }

.course-card-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
}

.course-subject { color: var(--primary); }
.course-level { color: var(--muted); }

.course-desc {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0;
  flex: 1;
}

.course-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0;
  font-size: 0.85rem;
}

.course-meta div { display: flex; justify-content: space-between; gap: 12px; }
.course-meta dt { color: var(--muted); margin: 0; }
.course-meta dd { margin: 0; font-weight: 500; }

.progress-track {
  height: 8px;
  background: #eef0f6;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #b23a3a);
  border-radius: 999px;
}

.progress-label {
  font-size: 0.78rem;
  color: var(--muted);
}

.material-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
}

.material-link:hover { text-decoration: underline; }

.watch-btn { margin-top: 10px; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.status-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.status-pending {
  background: #fff7ed;
  color: #c2410c;
}

.status-approved {
  background: var(--success-bg);
  color: var(--success);
}

.status-draft { background: #f1f5f9; color: #475569; }
.status-published { background: var(--success-bg); color: var(--success); }
.status-closed { background: #f1f5f9; color: #475569; }
.status-graded { background: var(--success-bg); color: var(--success); }
.status-grading_failed { background: #fee2e2; color: #b91c1c; }
.status-dispute-pending { background: #fff7ed; color: #c2410c; }
.status-dispute-resolved { background: #ecfdf5; color: #059669; }

.homework-photo { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); margin: 12px 0; }
.question-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.question-card-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 6px; }

/* Course color accents */
.color-indigo { border-top-color: #4f46e5; }
.color-sky { border-top-color: #0284c7; }
.color-emerald { border-top-color: #059669; }
.color-amber { border-top-color: #d97706; }
.color-rose { border-top-color: #e11d48; }
.color-violet { border-top-color: #7c3aed; }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .auth-hero {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .auth-copy h1 { font-size: 2rem; }
  .instructor-photo { margin: 0 auto; }
}

@media (max-width: 720px) {
  .menu-toggle { display: flex; }

  .nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    padding: 12px 24px 20px;
    gap: 14px;
    display: none;
  }

  .nav.open { display: flex; }

  .nav-cta { text-align: center; }

  .nav-dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    min-width: 0;
    padding: 4px 0 4px 14px;
  }
}

/* ---------- Admin ---------- */

.admin-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 4px;
  vertical-align: middle;
}

.admin-login-wrap {
  max-width: 420px;
  margin: 40px auto 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
}

.admin-card-wide {
  width: 100%;
  margin-bottom: 24px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-table tbody tr:last-child td { border-bottom: none; }

.admin-table td input[type="text"],
.admin-table td input[type="number"],
.admin-table td select {
  width: 100%;
  min-width: 110px;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fbfbfe;
}

.budget-item-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-price-search {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fbfbfe;
  color: var(--muted);
  cursor: pointer;
}

.btn-price-search:hover {
  background: var(--border);
  color: var(--text);
}

.student-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-top: 6px;
}

.student-picker .field { max-width: 200px; margin: 0; }

/* ---------- ระบบแบบฟอร์ม (คล้าย Google Form) ---------- */

.form-field-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
  background: #fbfbfe;
}

.form-field-card-head {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-field-card-head .field-label-input { flex: 1; min-width: 200px; }
.form-field-card-head .field-type-select { min-width: 160px; }

.form-field-card-head input,
.form-field-card-head select {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.form-field-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.field-required-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.form-options-box {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.form-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-option-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-option-row input {
  flex: 1;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.public-form-field {
  margin-bottom: 20px;
}

.public-form-field > .public-form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

.public-form-field .required-mark { color: #e11d48; margin-left: 2px; }

.public-form-field input[type="text"],
.public-form-field input[type="number"],
.public-form-field input[type="date"],
.public-form-field input[type="email"],
.public-form-field textarea,
.public-form-field select {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fbfbfe;
}

.public-form-choice-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}


.form-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.form-stat-card {
  flex: 1;
  min-width: 160px;
  padding: 20px;
  border-radius: 14px;
  background: #fbfbfe;
  border: 1px solid var(--border);
  text-align: center;
}

.form-stat-card-accent {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark, var(--primary)));
  border-color: transparent;
  color: #fff;
}

.form-stat-value {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.2;
}

.form-stat-value-sm { font-size: 1.1rem; }

.form-stat-label {
  font-size: 0.85rem;
  margin-top: 4px;
  opacity: 0.85;
}

.form-summary-card h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-summary-icon { font-size: 1.3rem; }

.form-donut-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 28px;
}

.form-donut-svg { flex: none; }

.form-donut-center-value {
  font-size: 1.4rem;
  font-weight: 700;
  fill: var(--text);
}

.form-donut-center-label {
  font-size: 0.7rem;
  fill: var(--muted);
}

.form-donut-legend {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-donut-legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.form-donut-swatch {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.form-donut-legend-label { flex: 1; }
.form-donut-legend-value { font-weight: 600; color: var(--muted); }

.form-summary-text-answers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.form-summary-text-answer {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfbfe;
  font-size: 0.9rem;
}

.form-square-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.form-square-card {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfbfe;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.form-square-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.admin-actions {
  display: flex;
  gap: 8px;
}

.edit-row { display: none; }
.edit-row.open { display: table-row; }
.edit-row td { white-space: normal; background: #fbfbfe; }

.admin-course-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 16px 0 4px;
}

.admin-course-form .field-wide { grid-column: 1 / -1; }

.admin-course-form textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fbfbfe;
  resize: vertical;
}

.admin-course-form select,
.admin-user-detail select {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fbfbfe;
}

.admin-course-form .btn { grid-column: 1 / -1; justify-self: start; }

.season-create-form {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.season-create-form .field { flex: 1; min-width: 240px; }

.season-block { margin-top: 20px; }

.season-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.season-title-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 240px;
}

.season-title-input {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fbfbfe;
  flex: 1;
  min-width: 200px;
}

.episode-admin-thumb {
  width: 90px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.episode-create-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  font-size: 0.9rem;
  color: var(--muted);
}

.history-list li {
  padding: 8px 12px;
  background: #fbfbfe;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.history-list li.notification-unread {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--text);
  font-weight: 600;
}

.progress-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 140px;
}

.progress-track-sm {
  width: 90px;
  flex-shrink: 0;
}

.progress-cell-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.me-profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.me-profile-info h2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
}

.coin-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3c4 0%, #f4c542 45%, #b8860b 100%);
  border: 1.5px solid #8a6300;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
  color: #6b4a00;
  font-weight: 800;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
  vertical-align: middle;
}

.coin-icon-lg {
  width: 40px;
  height: 40px;
  font-size: 20px;
  border-width: 2px;
}

.tier-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
}

.tier-badge-sm {
  padding: 3px 10px;
  font-size: 0.8rem;
}

.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.subtab {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.subtab:hover { background: var(--primary-light); color: var(--text); }

.subtab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.coin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.coin-stat-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
}

.coin-stat-label {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.coin-stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.coin-stat-sub {
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
}

tr.rank-row-me {
  background: var(--primary-light);
  font-weight: 600;
}

.assign-form {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed var(--border);
}

.assign-form select {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fbfbfe;
  min-width: 280px;
}

@media (max-width: 900px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-course-form { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .admin-course-form { grid-template-columns: 1fr; }
  .assign-form { flex-direction: column; align-items: stretch; }
}

/* ---------- Watch page (Netflix-style course player) ---------- */

.watch-page {
  background: #0b0b0f;
  color: #f2f2f4;
  margin: -40px calc(50% - 50vw) 0;
  padding-bottom: 56px;
}

.watch-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.watch-back {
  padding-top: 20px;
}

.watch-back a {
  color: #b8b8bd;
  font-size: 0.88rem;
}

.watch-back a:hover { color: #fff; }

.watch-player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 16px;
}

.watch-player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.watch-player-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8a8a92;
  font-size: 0.95rem;
}

.watch-hero-info {
  padding: 20px 0 8px;
}

.watch-course-subject {
  margin: 0 0 6px;
  color: #e0554f;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.watch-hero-info h1 {
  margin: 0 0 10px;
  font-size: 1.8rem;
  color: #fff;
}

.watch-episode-tag {
  margin: 0 0 8px;
  color: #d6d6da;
  font-weight: 600;
  font-size: 0.92rem;
}

.watch-episode-desc {
  margin: 0;
  color: #a8a8ae;
  font-size: 0.92rem;
  line-height: 1.7;
  max-width: 70ch;
}

.watch-body { padding-top: 8px; }

.watch-meta {
  border-top: 1px solid #232329;
  padding: 20px 0;
  color: #b8b8bd;
  font-size: 0.9rem;
  line-height: 1.7;
}

.watch-meta-row { margin: 8px 0 0; color: #8a8a92; }

.watch-episodes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.watch-episodes-head h2 {
  margin: 0;
  color: #fff;
  font-size: 1.3rem;
}

.season-select-form select {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #2c2c33;
  background: #17171c;
  color: #f2f2f4;
}

.watch-empty {
  color: #8a8a92;
  padding: 24px 0;
}

.episode-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.episode-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border-radius: 10px;
  color: inherit;
  transition: background 0.15s ease;
}

.episode-row:hover { background: #17171c; }
.episode-row.active { background: #1d1d23; }

.episode-num {
  width: 22px;
  flex-shrink: 0;
  text-align: center;
  color: #8a8a92;
  font-weight: 600;
}

.episode-thumb {
  width: 140px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: #1d1d23;
}

.episode-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.episode-title {
  font-weight: 600;
  color: #f2f2f4;
}

.episode-row.active .episode-title { color: #e0554f; }

.episode-desc {
  color: #8a8a92;
  font-size: 0.85rem;
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.episode-duration {
  flex-shrink: 0;
  color: #8a8a92;
  font-size: 0.85rem;
}

@media (max-width: 640px) {
  .episode-thumb { width: 96px; }
  .episode-desc { -webkit-line-clamp: 1; }
  .watch-hero-info h1 { font-size: 1.4rem; }
}

/* ---------- แบ่งหน้า / ฟิลเตอร์ตาราง ---------- */

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-top: 14px;
  font-size: 0.9rem;
}

.pager-size select {
  font-family: inherit;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin: 0 4px;
}

.pager-info { color: var(--muted); }
.pager-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: auto; }
.pager-nav .btn { padding: 6px 12px; }

.table-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}

.table-filters .field { margin: 0; min-width: 150px; }
.table-filters select {
  font-family: inherit;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* ---------- รูปโปรไฟล์ครู ---------- */

.me-avatar {
  flex: none;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--primary-light);
  box-shadow: var(--shadow);
  background: var(--primary-light);
}

.me-avatar-sm { width: 72px; height: 72px; border-width: 3px; box-shadow: none; }

.me-avatar-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--primary);
}

.me-avatar-sm.me-avatar-empty { font-size: 1.6rem; }

.avatar-edit { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar-remove { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-weight: 500; font-size: 0.88rem; }

/* ---------- รายการวัสดุ (ค้นหา real time) ---------- */

.materials-link { margin-left: 8px; font-size: 0.85rem; font-weight: 600; color: var(--primary); }
.materials-link:hover { text-decoration: underline; }

.material-search {
  width: 100%;
  font-family: inherit;
  font-size: 1.05rem;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fbfbfe;
  outline: none;
}

.material-search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.material-status { margin: 12px 0 0; color: var(--muted); font-size: 0.9rem; }
.material-status.material-status-fuzzy { color: #b45309; }
.material-price { font-weight: 600; white-space: nowrap; }
mark.material-hit { background: #fde68a; color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- แบบประเมินแผนการจัดการเรียนรู้ (ผู้ตรวจแผนการสอน) ---------- */

.review-scale-list { list-style: none; margin: 0 0 16px; padding: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.8; }
.review-table .review-item-text { white-space: normal; min-width: 260px; line-height: 1.5; }
.review-table .review-score-col { text-align: center; width: 52px; padding-left: 8px; padding-right: 8px; }
.review-table tbody tr:hover td { background: #fbfbfe; }
.review-table input[type="radio"] { width: 18px; height: 18px; cursor: pointer; }
.review-table tfoot td { background: #fbfbfe; border-top: 2px solid var(--border); }

.review-summary-box {
  margin-top: 18px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfbfe;
  font-size: 0.9rem;
}

.review-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 4px 20px; margin-top: 8px; color: var(--muted); }

.review-history-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-top: 10px; background: #fbfbfe; }
.review-history-item summary { cursor: pointer; font-size: 0.92rem; }
.review-history-scores { margin: 10px 0 0; padding-left: 18px; font-size: 0.88rem; line-height: 1.6; }
.review-history-score { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 6px; background: var(--primary-light); color: var(--primary); font-weight: 700; text-align: center; }

/* ---------- โปรแกรมจัดตารางสอน (วิชาการ) ---------- */

.tt-grid-wrap { overflow-x: auto; margin-top: 14px; border: 1px solid var(--border); border-radius: 12px; }
.tt-grid { border-collapse: collapse; width: 100%; min-width: 900px; font-size: 0.82rem; }
.tt-grid th, .tt-grid td { border: 1px solid var(--border); padding: 4px; text-align: center; vertical-align: middle; }
.tt-grid thead th { background: #fbfbfe; position: sticky; top: 0; z-index: 1; }
.tt-class-col { min-width: 74px; background: #fbfbfe; font-weight: 700; position: sticky; left: 0; z-index: 2; }
.tt-time { font-size: 0.68rem; font-weight: 400; color: var(--muted); }
.tt-cell { min-width: 118px; height: 54px; }
.tt-select { width: 100%; font-family: inherit; font-size: 0.78rem; padding: 6px 2px; border: 1px dashed var(--border); border-radius: 8px; background: #fff; color: var(--muted); cursor: pointer; }
.tt-select:hover { border-color: var(--primary); }
.tt-slot { position: relative; padding: 4px 16px 4px 4px; border-radius: 8px; background: var(--primary-light); color: var(--primary-dark); line-height: 1.25; }
.tt-slot-meta { font-size: 0.68rem; color: var(--muted); }
.tt-slot-del { position: absolute; top: 1px; right: 3px; border: none; background: none; color: var(--muted); font-size: 1rem; line-height: 1; cursor: pointer; padding: 0; }
.tt-slot-del:hover { color: #dc2626; }
.tt-toast { margin-top: 10px; padding: 8px 14px; border-radius: 10px; font-size: 0.9rem; font-weight: 500; }
.tt-toast-ok { background: var(--success-bg); color: var(--success); }
.tt-toast-err { background: var(--error-bg); color: var(--error); }
.tt-remaining-item { border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; margin-top: 8px; background: #fbfbfe; }
.tt-remaining-item summary { cursor: pointer; font-weight: 600; }

/* คาบที่ถูกล็อกไว้ (พักกลางวัน/ลูกเสือ/ชุมนุม/PLC ฯลฯ) ในหน้าลงตาราง — ลงวิชาทับไม่ได้ */
.tt-cell-locked { background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 6px, #e5e7eb 6px, #e5e7eb 12px); }
.tt-lock-label { font-size: 0.72rem; font-weight: 600; color: var(--muted); line-height: 1.2; padding: 2px; }

/* ตารางแสดงผล (เรียน/สอน/ที่ได้): ไม่ใช้สีพื้น — เส้นตารางล้วนทั้งแนวตั้งแนวนอนเพื่อแบ่งวรรค */
.tt-view-table th, .tt-view-table td { white-space: normal; padding: 6px 8px; border: 1px solid var(--border); }
.tt-view-table .tt-cell-center { text-align: center; }
.tt-view-item { padding: 2px 0; font-size: 0.82rem; line-height: 1.3; }
.tt-view-item + .tt-view-item { border-top: 1px dashed var(--border); }
.tt-room { font-size: 0.72rem; color: var(--muted); }
.tt-view-item.tt-locked { background: #f3f4f6; border-radius: 6px; padding: 4px 6px; text-align: center; color: #6b7280; }
.tt-print-head { text-align: center; margin-bottom: 10px; }
.tt-print-school { font-weight: 700; }
.tt-signatures { display: flex; justify-content: space-around; gap: 24px; margin-top: 28px; text-align: center; font-size: 0.9rem; }
.tt-sign-line { margin-bottom: 4px; }

@media print {
  .topbar, .footer, .flash-stack, .no-print { display: none !important; }
  .page { padding: 0; max-width: none; }
  .auth-card { box-shadow: none; border: none; padding: 0; }
  .tt-print-page { page-break-after: always; page: tt-landscape; }
  .auth-card > .tt-print-page:last-child { page-break-after: auto; }
  .tt-view-table th, .tt-view-table td { border: 1px solid #999; }
  body { background: #fff; }
}
/* ตารางสอน (เรียน/สอน/ที่ได้) พิมพ์แนวนอน — คอลัมน์คาบเยอะ ตั้งตรงแล้วล้นหน้า */
@page tt-landscape { size: landscape; margin: 10mm; }

/* ตัวเลือกเลขห้อง 1-10 แบบกะทัดรัด (ตารางสอน) */
.course-pick-list.room-no-list {
  flex-direction: row;
  flex-wrap: wrap;
}
.room-no-list .course-pick-chip { padding: 8px 14px; gap: 8px; }

/* ลงทะเบียนผู้สอน: ตารางรายวิชา x ห้องเรียน */
.reg-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.reg-search input { padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; font: inherit; min-width: 220px; }
.reg-tab-count { font-size: 0.78rem; opacity: 0.8; margin-left: 4px; }
.reg-admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-top: 20px; align-items: start; }
.reg-mini-form { align-content: start; }
.reg-mini-form .btn { align-self: end; justify-self: start; }
.reg-mini-form h3 { grid-column: 1 / -1; margin: 0; }
.reg-inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reg-inline-form select, .reg-inline-form input[type="text"] { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.reg-wrap { margin-top: 8px; }
.reg-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 0.9rem; }
.reg-table th, .reg-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; text-align: left; }
.reg-table thead th { background: #f4f5fb; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.reg-col-code { white-space: nowrap; }
.reg-col-name { min-width: 200px; }
.reg-col-credit { text-align: center !important; white-space: nowrap; }
.reg-col-class { text-align: center !important; min-width: 130px; }
.reg-col-class small { display: block; font-weight: 400; color: var(--muted, #6b7280); font-size: 0.72rem; }
.reg-cat-row td { background: #eef1ff; font-weight: 600; }
.reg-td { text-align: center; min-width: 130px; }
.reg-none { color: #c2c6d2; }
.reg-cell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 100%; min-height: 44px; padding: 6px 8px; border: 1px dashed #c7cbe0; border-radius: 10px; background: #fff; font: inherit; color: inherit; }
button.reg-cell { cursor: pointer; }
button.reg-cell:hover:not(:disabled) { border-color: #2f4fd6; background: #f3f5ff; }
button.reg-cell:disabled { opacity: 0.6; cursor: progress; }
.reg-cell.has-teachers { border-style: solid; border-color: #d5d9ea; background: #f8f9fd; }
.reg-cell.is-mine { border-style: solid; border-color: #16a34a; background: #ecfdf3; }
.reg-teacher { font-size: 0.82rem; line-height: 1.25; }
.reg-teacher.is-me { font-weight: 700; color: #15803d; }
.reg-empty { font-size: 0.82rem; color: #2f4fd6; }
.reg-cell-static .reg-empty { color: #9aa0ac; }
.reg-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 0.85rem; color: #6b7280; margin: 0 0 8px; }
.reg-legend-cell { display: inline-flex !important; width: auto; min-height: 0; padding: 2px 10px; }
.reg-msg { padding: 10px 14px; border-radius: 10px; margin-bottom: 10px; font-size: 0.9rem; }
.reg-msg-ok { background: #ecfdf3; color: #166534; }
.reg-msg-err { background: #fef2f2; color: #991b1b; }

/* ตารางสอนของครู / Launch */
.tt-subject-name { font-size: 0.7rem; color: var(--muted); }
.tt-launch-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.tt-page[hidden] { display: none !important; }
@media print {
  #my-timetable .tt-page[hidden] { display: block !important; }
}

/* นำเข้าตัวชี้วัดจาก Excel */
.ind-import { margin: 20px 0 8px; padding: 16px; border: 1px dashed var(--border); border-radius: 12px; background: #fbfbfe; }
.ind-import .ind-import-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* แถวรายวิชาที่เพิ่งเพิ่ม (หน้าบริหารหลักสูตร) */
.row-just-added td { background: #ecfdf3; }

/* หัวหน้าฝ่าย */
.dept-head-chip { display: inline-block; margin: 2px 6px 2px 0; padding: 3px 10px; border-radius: 999px; background: #eef1ff; color: #2f4fd6; font-size: 0.85rem; }
.reg-mini-form .ind-import-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; grid-column: 1 / -1; }

/* ลบตัวชี้วัดหลายตัวพร้อมกัน */
.ind-bulk-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }

/* ห้องศูนย์/ห้องปฏิบัติการ: แถวกรอก เลขห้อง + ชื่อห้อง */
.lab-rows { display: flex; flex-direction: column; gap: 10px; }
.lab-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(200px, 3fr); gap: 12px; }

/* แก้ห้องสอนในช่องตาราง */
.tt-room-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--primary, #2f4fd6); cursor: pointer; text-decoration: underline dotted; font-size: inherit; }
.tt-room-btn:hover { text-decoration: underline; }
.tt-room-select { min-width: 150px; font-size: 0.8rem; }
.reg-advanced > summary { cursor: pointer; padding: 4px 0; }

/* ตารางเรียนของนักเรียน / ห้องเรียนตอนสมัคร */
.my-class-card { margin-bottom: 20px; }
.school-class-fields { display: grid; gap: 12px; }

/* จัดการรายวิชา (NumFTP) */
.subj-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 0 0 16px; }
.subj-stat { --c: #2563eb; background: var(--surface, #fff); border: 1px solid var(--border, #e5e7eb); border-left: 4px solid var(--c); border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; }
.subj-stat strong { font-size: 1.5rem; line-height: 1.2; color: var(--c); }
.subj-stat span { font-size: 0.85rem; color: var(--muted, #6b7280); }
.subj-add > summary { cursor: pointer; padding: 2px 0; }
.subj-form { margin-top: 12px; }
.subj-due-set { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ช่องติ๊กแผนการเรียนของรายวิชา */
.plan-check-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.plan-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer; font-weight: 500; }
.plan-chip:has(input:checked) { border-color: #2563eb; background: #eff6ff; color: #1d4ed8; }
.plan-chip input { margin: 0; }
.plan-checks-hint { font-style: normal; font-weight: 400; color: var(--muted); font-size: 0.85rem; }

/* เลือกรูปแบบเอกสาร (แผนการสอน / กำหนดการสอน) */
.doc-mode-options { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.doc-mode-option { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; flex: 1 1 260px; }
.doc-mode-option small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }
.doc-mode-option:has(input:checked) { border-color: #7c3aed; background: #f5f3ff; }
.doc-mode-options .btn { align-self: center; }

/* เอกสารกำหนดการสอน (Course Syllabus) */
.syl-doc { background: #fff; color: #111; border: 1px solid var(--border); border-radius: 12px; padding: 24px 28px; max-width: 900px; margin: 0 auto 24px; line-height: 1.6; }
.syl-head { text-align: center; margin-bottom: 14px; }
.syl-head h2 { margin: 4px 0; }
.syl-school { font-weight: 700; }
.syl-doc h3 { margin: 18px 0 6px; font-size: 1.05rem; }
.syl-info { width: 100%; border-collapse: collapse; }
.syl-info th { text-align: left; vertical-align: top; width: 210px; padding: 3px 8px 3px 0; white-space: nowrap; }
.syl-info td { padding: 3px 0; }
.syl-table { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 0.95rem; }
.syl-table th, .syl-table td { border: 1px solid #9ca3af; padding: 4px 8px; vertical-align: top; }
.syl-table th { background: #f3f4f6; }
.syl-table .c { text-align: center; }
.syl-table .r { text-align: right; }
.syl-rooms { margin-top: 10px; }
.syl-text { white-space: pre-wrap; margin: 4px 0; }
.syl-list { margin: 4px 0 4px 20px; padding: 0; }
.syl-dash { list-style: none; margin-left: 4px; }
.syl-dash li::before { content: "- "; }
.syl-grades { max-width: 420px; }
.syl-edit-table textarea, .syl-edit-table input[type=text], .syl-edit-table input[type=number] { width: 100%; box-sizing: border-box; font: inherit; }
@media print {
  .syl-doc { border: 0; padding: 0; max-width: none; margin: 0; }
  .syl-doc h3 { break-after: avoid; }
  .syl-table tr { break-inside: avoid; }
}

/* ปุ่มส่งแผนการสอน */
.submit-plan-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 4px 0 12px; }


/* เปิด/ปิดการลงทะเบียนผู้สอน */
.reg-closed-banner { border-left: 4px solid #dc2626; background: #fef2f2; }

/* ---------- คลังข้อสอบ: การ์ดปกข้อสอบ ---------- */
.exam-bank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; margin-top: 8px; }
.exam-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; display: flex; flex-direction: column; }
.exam-card-cover {
  position: relative;
  height: 170px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
  background: linear-gradient(160deg, var(--exam-cover-a, var(--primary)) 0%, var(--exam-cover-b, var(--primary-dark)) 100%);
  overflow: hidden;
}
.exam-card-cover::before {
  content: "";
  position: absolute;
  inset: -30% -10% auto -10%;
  height: 70%;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  transform: rotate(-8deg);
}
.exam-card-icon { position: relative; font-size: 2.6rem; line-height: 1; opacity: 0.9; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.18)); }
.exam-card-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.32);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.exam-card-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.exam-card-delete:hover { background: #dc2626; }
.exam-card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.exam-card-title { font-weight: 700; font-size: 0.95rem; line-height: 1.35; margin: 0; }
.exam-card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.exam-card-tag { background: var(--primary-light); color: var(--primary-dark); font-size: 0.7rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.exam-card-desc { color: var(--muted); font-size: 0.82rem; line-height: 1.4; margin: 0; }
.exam-card-meta { color: var(--muted); font-size: 0.72rem; }
/* margin-top: auto ปักปุ่มไว้ล่างสุดของการ์ดเสมอ ไม่ว่าการ์ดข้างกันจะมีรายละเอียด/แท็กมากน้อยแค่ไหน คำว่า "ดาวน์โหลด" จึงอยู่แถวเดียวกันเป๊ะทุกใบในแถวเดียวกัน */
.exam-card-body .btn { margin-top: auto; align-self: flex-start; }

/* ---------- หน้าสรุปการวางแผน: การ์ดแผนโครงการ ---------- */
.plan-summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.plan-summary-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.plan-summary-name { margin: 0; font-size: 1rem; }
.plan-summary-line { margin: 0; font-size: 0.86rem; }
.plan-summary-block { font-size: 0.86rem; }
.plan-summary-list { margin: 4px 0 0; padding-left: 18px; }
.plan-summary-list li { margin-bottom: 2px; }

/* ---------- ระบบบันทึกการสอนพิเศษ (/tutor) ---------- */

.tutor-topbar-user { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.tutor-topbar-user .btn { white-space: nowrap; padding: 8px 14px; font-size: 0.88rem; }
.tutor-topbar-name {
  font-weight: 600;
  font-size: 0.9rem;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tutor-tag { white-space: nowrap; }
.admin-table td .tutor-reset-form input[type="text"] { width: 150px; }

.tutor-student-tabs { margin-bottom: 8px; }

.tutor-manage {
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
}
.tutor-manage summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; color: var(--muted); }
.tutor-manage-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.tutor-manage-row-form { display: flex; flex: 1; gap: 8px; margin: 0; }
.tutor-manage-row input[type="text"] {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fbfbfe;
}

.tutor-cal-card { padding: 16px; }
.tutor-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.tutor-cal-title { display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.3; }
.tutor-cal-title strong { font-size: 1.2rem; }
.tutor-cal-title span { font-size: 0.85rem; color: var(--muted); }
.tutor-today-link { margin: -4px 0 10px; text-align: center; font-size: 0.85rem; }
.tutor-today-link a { color: var(--primary); font-weight: 600; }

.tutor-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.tutor-cal-dow {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 0;
}
.tutor-cal-dow.sun { color: var(--error); }

.tutor-cal-cell {
  min-height: 78px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 6px;
  font-family: inherit;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
}
.tutor-cal-cell.empty { border-color: transparent; background: transparent; }
.tutor-cal-cell.day { cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease; }
.tutor-cal-cell.day:hover { background: var(--primary-light); border-color: var(--primary); }
.tutor-cal-cell.today { box-shadow: 0 0 0 2px var(--primary); }
.tutor-cal-cell.has-lesson { background: var(--primary-light); border-color: var(--primary); }
.tutor-cal-day { font-size: 0.9rem; font-weight: 600; }
.tutor-cal-hours { font-size: 0.72rem; font-weight: 600; color: var(--primary-dark); }
.tutor-cal-fee { font-size: 0.72rem; color: var(--primary-dark); }

/* กิจกรรมในปฏิทิน: สีฟ้า แยกจากช่องชั่วโมงเรียนที่เป็นสีแดงเลือดหมู */
.act-blue   { --act-bg: #dbeafe; --act-fg: #1e40af; }
.act-green  { --act-bg: #d1fae5; --act-fg: #065f46; }
.act-amber  { --act-bg: #fef3c7; --act-fg: #92400e; }
.act-violet { --act-bg: #ede9fe; --act-fg: #5b21b6; }
.act-teal   { --act-bg: #ccfbf1; --act-fg: #115e59; }
.act-gray   { --act-bg: #e5e7eb; --act-fg: #374151; }

.tutor-chip {
  display: block;
  width: 100%;
  background: var(--act-bg, #dbeafe);
  color: var(--act-fg, #1e40af);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 0.7rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.tutor-chip-more { background: #e0e7ff; width: auto; }

.tutor-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0 0; font-size: 0.8rem; color: var(--muted); }
.tutor-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tutor-legend-box { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.tutor-legend-box.lesson { background: var(--primary-light); border: 1px solid var(--primary); }
.tutor-legend-box.activity { background: linear-gradient(90deg, #dbeafe 0 25%, #d1fae5 25% 50%, #fef3c7 50% 75%, #ede9fe 75%); border: 1px solid #94a3b8; }

.tutor-modal-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tutor-modal-tab {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.tutor-modal-tab.active[data-tab="lesson"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.tutor-modal-tab.active[data-tab="activity"] { background: #1e40af; border-color: #1e40af; color: #fff; }

.tutor-act-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow-y: auto; }
.tutor-act-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--act-bg, #dbeafe);
  color: var(--act-fg, #1e40af);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.92rem;
  font-weight: 600;
  word-break: break-word;
}
.tutor-act-list li.tutor-act-empty { background: transparent; color: var(--muted); font-weight: 400; padding: 0; }
.tutor-act-list li form { margin: 0; }
.tutor-act-del { border: none; background: transparent; color: inherit; font-size: 1rem; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.tutor-act-del:hover { background: rgba(0, 0, 0, 0.1); }
.tutor-act-info { display: flex; flex-direction: column; min-width: 0; }
.tutor-act-info small { font-weight: 400; font-size: 0.78rem; opacity: 0.85; }
.tutor-act-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

.tutor-act-dates { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.tutor-act-dates .field { min-width: 0; }
.tutor-act-dates input { min-width: 0; width: 100%; }
.tutor-color-picker { display: flex; flex-wrap: wrap; gap: 12px; padding: 4px 2px; }
.tutor-color-opt { position: relative; cursor: pointer; display: block; width: 30px; height: 30px; }
.tutor-color-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: none; opacity: 0; cursor: pointer; }
.tutor-swatch {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--act-bg);
  border: 3px solid var(--act-fg);
  opacity: 0.6;
  transition: opacity 0.12s ease, box-shadow 0.12s ease;
}
.tutor-color-opt input:checked + .tutor-swatch { opacity: 1; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--act-fg); }
.tutor-color-opt input:focus-visible + .tutor-swatch { outline: 2px solid var(--primary); outline-offset: 3px; }

.tutor-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.tutor-summary-head h2 { margin: 0; }

/* เลือกหลายเดือนรวมสรุป */
.tutor-month-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.tutor-month-picker-label { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-right: 2px; }
.tutor-month-chip { position: relative; cursor: pointer; }
.tutor-month-chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.tutor-month-chip span {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.12s ease, color 0.12s ease;
}
.tutor-month-chip input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.tutor-month-chip input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.tutor-month-picker .btn { padding: 6px 14px; font-size: 0.88rem; }
.tutor-month-link { font-size: 0.85rem; font-weight: 600; color: var(--primary); }

.tutor-summary-table tr.tutor-subtotal td { background: #fafbfd; font-weight: 700; font-size: 0.88rem; color: var(--muted); }

.tutor-summary-table th.num,
.tutor-summary-table td.num { text-align: right; }
.tutor-summary-table tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--border);
  border-bottom: none;
  background: #fafbfd;
}

.tutor-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.tutor-modal.is-open { display: flex; }
.tutor-modal-backdrop { position: absolute; inset: 0; background: rgba(20, 22, 38, 0.5); }
.tutor-modal-panel {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  max-height: 92vh;
  overflow-y: auto;
}
.tutor-modal-panel h3 { margin: 0 0 4px; font-size: 1.1rem; }
.tutor-modal-panel .lead { margin: 0 0 14px; }
.tutor-modal-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 720px) {
  .tutor-cal-card { padding: 12px 8px; }
  .tutor-cal-grid { gap: 3px; }
  .tutor-cal-cell { min-height: 62px; padding: 4px; border-radius: 8px; }
  .tutor-cal-day { font-size: 0.82rem; }
  .tutor-cal-hours, .tutor-cal-fee { font-size: 0.64rem; }
  .tutor-topbar-name { display: none; }
  .tutor-modal { align-items: flex-end; padding: 0; }
  .tutor-modal-panel { max-width: none; border-radius: var(--radius) var(--radius) 0 0; }
}

/* ---------- หน้า "ลงตาราง" แบบหน้าคู่: ซ้าย = ลงตารางสอน, ขวา = ตารางห้อง (นักเรียน) + ตารางครู เทียบไปพร้อมกัน ---------- */
.tt-split-wrap { width: min(1760px, calc(100vw - 64px)); position: relative; left: 50%; transform: translateX(-50%); }
.tt-split { display: grid; grid-template-columns: minmax(0, 1fr) clamp(420px, 38vw, 640px); gap: 16px; align-items: start; }
.tt-split.is-single { grid-template-columns: minmax(0, 1fr); }
.tt-split.is-single .tt-split-side { display: none; }
.tt-split-main { min-width: 0; }
.tt-split-side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; min-width: 0; max-height: calc(100vh - 92px); overflow-y: auto; }
.tt-side-card { padding: 12px 14px; margin: 0; }
.tt-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.tt-side-head h3 { margin: 0; font-size: 1rem; }
.tt-side-select { width: auto; min-width: 140px; max-width: 62%; border-style: solid; color: var(--text); padding: 6px 8px; }
.tt-side-stat { font-size: 0.78rem; color: var(--muted); margin-bottom: 8px; min-height: 1.1em; }

.tt-class-col[data-rowkey] { cursor: pointer; }
.tt-class-col.tt-row-focus { background: var(--primary-light); color: var(--primary-dark); }
.tt-slot { cursor: pointer; }

.tt-mini-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.tt-mini { border-collapse: collapse; width: 100%; min-width: 460px; table-layout: fixed; font-size: 0.7rem; }
.tt-mini th, .tt-mini td { border: 1px solid var(--border); padding: 3px; text-align: center; vertical-align: middle; }
.tt-mini thead th { background: #fbfbfe; font-weight: 600; }
.tt-mini td { height: 44px; overflow: hidden; }
.tt-mini .tt-time { font-size: 0.56rem; }
.tt-mini .tt-mini-day { background: #fbfbfe; font-weight: 700; width: 44px; position: sticky; left: 0; z-index: 1; }
.tt-mini tr.is-current .tt-mini-day { background: #fef3c7; color: #92400e; }
.tt-mini tr.is-current td { background: #fffdf5; }
.tt-mini-item { background: var(--primary-light); color: var(--primary-dark); border-radius: 6px; padding: 2px 3px; line-height: 1.2; }
.tt-mini-item + .tt-mini-item { margin-top: 2px; }
.tt-mini-item strong { display: block; font-size: 0.68rem; overflow-wrap: anywhere; }
.tt-mini-item span { display: block; font-size: 0.62rem; color: var(--muted); word-break: break-word; }
.tt-mini-lock { background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 5px, #e5e7eb 5px, #e5e7eb 10px) !important; color: var(--muted); font-size: 0.62rem; font-weight: 600; }
.tt-mini-clash .tt-mini-item { background: #fee2e2; color: #991b1b; }
.tt-mini-flash { animation: ttMiniFlash 1.8s ease-out; }
@keyframes ttMiniFlash { from { box-shadow: inset 0 0 0 3px #f59e0b; background: #fef3c7; } to { box-shadow: inset 0 0 0 0 transparent; } }

@media (max-width: 1100px) {
  .tt-split-wrap { width: auto; left: auto; transform: none; }
  .tt-split { grid-template-columns: minmax(0, 1fr); }
  .tt-split-side { position: static; max-height: none; overflow: visible; }
}

/* ---------- วิชาที่ยังไม่ได้ลง (ลากไปวางในตารางได้) ---------- */
.tt-tray { margin: 0 0 8px; }
.tt-tray-title { font-size: 0.72rem; color: var(--muted); margin-bottom: 4px; line-height: 1.3; }
.tt-tray-done { font-size: 0.75rem; color: var(--success); font-weight: 600; }
.tt-tray-chips { display: flex; flex-wrap: wrap; gap: 4px; max-height: 88px; overflow-y: auto; padding: 1px; }
.tt-chip {
  cursor: grab;
  user-select: none;
  border: 1px dashed var(--primary);
  background: #fff;
  color: var(--primary-dark);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.35;
}
.tt-chip small { font-weight: 500; font-size: 0.66rem; color: var(--muted); }
.tt-chip:hover { background: var(--primary-light); }
.tt-chip:active { cursor: grabbing; }
.tt-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.tt-chip.is-armed { background: var(--primary); border-style: solid; color: #fff; }
.tt-chip.is-armed small { color: #fde8e8; }

.tt-mini td.drop-ok, .tt-grid td.drop-ok { outline: 2px dashed #16a34a; outline-offset: -3px; background: #f0fdf4; }
.tt-mini td.drop-ok { cursor: copy; }
.tt-mini td.drop-ok.drop-hover, .tt-grid td.drop-ok.drop-hover { background: #bbf7d0; outline-style: solid; }
.tt-mini td.drop-no, .tt-grid td.drop-no { opacity: 0.5; }
body.tt-dragging { cursor: grabbing; }

/* ---------- ตารางเทียบ 4 ช่อง: เลือกได้ว่าเป็นตารางนักเรียน (ห้อง) หรือตารางครู ---------- */
.tt-side-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.tt-split.is-wide { grid-template-columns: minmax(0, 1fr) clamp(1000px, 62vw, 1180px); }
.tt-split.is-wide .tt-side-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.tt-layout-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.tt-layout-select { width: auto; border-style: solid; color: var(--text); padding: 6px 8px; }
.tt-side-head { justify-content: flex-start; gap: 6px; margin-bottom: 6px; }
.tt-type-select { width: auto; border-style: solid; color: var(--text); font-weight: 700; padding: 6px 8px; }
.tt-side-select { flex: 1 1 130px; min-width: 120px; max-width: none; }
.tt-follow-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 3px 12px;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}
.tt-follow-btn:hover { background: var(--primary-light); }
.tt-follow-btn.is-locked { background: var(--primary); border-color: var(--primary); color: #fff; }

@media (max-width: 1100px) {
  .tt-split.is-wide { grid-template-columns: minmax(0, 1fr); }
  .tt-split.is-wide .tt-side-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---- ระบบครูสอนพิเศษ: สถานะจ่ายแล้ว ---- */
.tutor-cal-cell.has-lesson.is-paid { background: #e8f7ee; border-color: #16a34a; }
.tutor-cal-cell.is-paid .tutor-cal-fee { color: #15803d; }
.tutor-paid-tick { font-weight: 800; color: #16a34a; }
.tutor-legend-box.paid { background: #e8f7ee; border: 1px solid #16a34a; }
.tutor-paid-line { margin: 4px 0 12px; font-size: 0.95rem; color: var(--muted); }
.tutor-paid-amt { color: #15803d; }
.tutor-unpaid-amt { color: #b45309; }
.tutor-paid-form { margin: 0; display: inline; }
.tutor-paid-btn { font: inherit; font-size: 0.8rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1px solid; cursor: pointer; white-space: nowrap; }
.tutor-paid-btn.paid { background: #e8f7ee; color: #15803d; border-color: #16a34a; }
.tutor-paid-btn.unpaid { background: #fff7ed; color: #b45309; border-color: #f59e0b; }
.tutor-paid-btn:hover { filter: brightness(0.96); }
.tutor-paid-done { font-size: 0.8rem; color: #15803d; font-weight: 700; }
.tutor-summary-table tfoot tr.tutor-foot-paid td { color: #15803d; }
.tutor-summary-table tfoot tr.tutor-foot-unpaid td { color: #b45309; font-weight: 700; }
.tutor-paid-bulk { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tutor-paid-check { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; font-weight: 600; cursor: pointer; }
.tutor-paid-check input { width: 18px; height: 18px; }
