/* =========================================================
   โทนสีพาสเทล ม่วง - เหลือง (Lavender & Buttercream Theme)
   พร้อมระบบจัดเรียงการ์ดสมมาตรกึ่งกลางอัตโนมัติ และแถบลิงก์ภายนอกด้านล่าง
   ========================================================= */
:root {
  --primary: #7c63a8;
  --primary-hover: #654c91;
  --primary-soft: #efe8fa;
  --primary-border: #dfd2f5;

  --accent-yellow-bg: #fef6d8;
  --accent-yellow-border: #f3dc8a;
  --accent-yellow-text: #855d0e;
  --accent-yellow-dot: #e2b53b;

  --text-main: #33264a;
  --text-muted: #64577a;
  --card-bg: rgba(255, 255, 255, 0.88);
  --card-border: rgba(223, 210, 245, 0.9);
  --card-shadow: 0 10px 28px rgba(93, 70, 138, 0.08);
  --card-shadow-hover: 0 16px 36px rgba(93, 70, 138, 0.15);

  /* ค่าควบคุมภาพพื้นหลัง (จะถูกอัปเดตจากชีต Portal_Settings) */
  --bg-blur: 4px;
  --bg-overlay-opacity: 0.84;
  --bg-overlay-custom: none;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  min-height: 100%;
  font-family: 'Sarabun', sans-serif;
  color: var(--text-main);
  background-color: #f6f1fc;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, .dept-badge, .filter-pill, .app-btn, .app-badge, .passcode-btn, .external-link-btn, .top-bar-label, .quick-card-title {
  font-family: 'Prompt', sans-serif;
}

.hidden {
  display: none !important;
}

/* =========================================================
   พื้นหลังพร้อมเอฟเฟกต์เบลอและแผ่นกรองแสงพาสเทล
   ========================================================= */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-image {
  position: absolute;
  inset: -16px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(var(--bg-blur));
  transform: scale(1.04);
  transition: background-image 0.4s ease, filter 0.3s ease;
}

.bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(244, 237, 253, var(--bg-overlay-opacity)) 0%,
    rgba(252, 248, 238, var(--bg-overlay-opacity)) 55%,
    rgba(254, 246, 218, var(--bg-overlay-opacity)) 100%
  );
  transition: background 0.3s ease;
}

.page-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: min(1440px, 96vw);
  margin: 0 auto;
  padding: 0 clamp(14px, 2vw, 28px);
}

/* =========================================================
   แถบประกาศ (Notice Bar)
   ========================================================= */
.notice-bar {
  background: rgba(254, 246, 216, 0.96);
  border-bottom: 1px solid var(--accent-yellow-border);
  color: var(--accent-yellow-text);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.notice-inner {
  padding-top: 9px;
  padding-bottom: 9px;
  font-size: 0.94rem;
  font-weight: 500;
  text-align: center;
}

.notice-marquee-viewport {
  width: 100%;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to right, transparent 0%, #000 3%, #000 97%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 3%, #000 97%, transparent 100%);
}

.notice-marquee-track {
  display: inline-flex;
  align-items: center;
  width: max-content;
  will-change: transform;
  animation: noticeMarqueeScroll var(--marquee-duration, 24s) linear infinite;
}

.notice-marquee-viewport:hover .notice-marquee-track,
.notice-marquee-viewport:focus-within .notice-marquee-track {
  animation-play-state: paused;
}

.notice-marquee-group {
  display: inline-flex;
  align-items: center;
  gap: 20px;
  padding-right: 56px;
  flex-shrink: 0;
}

.notice-marquee-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: none;
  padding: 2px 8px;
  border-radius: 999px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease;
}

.notice-marquee-item:hover,
.notice-marquee-item:focus-visible {
  background: rgba(180, 120, 16, 0.14);
  color: #4a2e00;
  outline: none;
}

.notice-marquee-item:hover .notice-marquee-title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.notice-marquee-org {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(124, 99, 168, 0.14);
  color: #553d82;
}

.notice-marquee-sep {
  color: rgba(145, 98, 12, 0.45);
  user-select: none;
}

@keyframes noticeMarqueeScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .notice-marquee-track {
    animation: none;
    flex-wrap: wrap;
    justify-content: center;
  }
  .notice-marquee-group[aria-hidden="true"] {
    display: none;
  }
}

/* Popup อ่านรายละเอียดประกาศปักหมุด */
.pinned-ann-modal-card {
  max-width: 600px;
  width: calc(100% - 28px);
}

.pinned-ann-modal-head {
  align-items: center;
  gap: 10px;
}

.pinned-ann-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.pinned-ann-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.pinned-ann-badge.pin {
  background: #fef3c7;
  color: #92400e;
}

.pinned-ann-badge.org {
  background: #ede9fe;
  color: #5b21b6;
}

.pinned-ann-badge.cat {
  background: #e0f2fe;
  color: #075985;
}

.pinned-ann-modal-body {
  padding: 6px 0 14px;
}

.pinned-ann-title {
  margin: 0 0 8px;
  font-size: 1.18rem;
  line-height: 1.45;
  color: var(--text-primary);
}

.pinned-ann-meta {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.pinned-ann-summary {
  background: #faf8ff;
  border: 1px solid #e9e2f6;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 0.96rem;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 45vh;
  overflow-y: auto;
}

.pinned-ann-modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid #ede8f6;
}

.pinned-ann-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pinned-ann-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.pinned-ann-action-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  background: #7c63a8;
  color: #fff;
  transition: opacity 0.15s ease;
}

.pinned-ann-action-link:hover {
  opacity: 0.9;
}

.pinned-ann-action-link.secondary {
  background: #ede9fe;
  color: #5b21b6;
}

.pinned-ann-all-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

/* =========================================================
   ส่วนหัว (Hero Header) และปุ่มมุมขวาบน
   ========================================================= */
.hero-header {
  padding: 36px 0 22px;
}

.hero-inner {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 28px 32px;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(14px);
}

.hero-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 22px;
  flex: 1;
  min-width: 0;
}

.dept-logo {
  width: 78px;
  height: 78px;
  object-fit: contain;
  border-radius: 16px;
  background: #ffffff;
  padding: 8px;
  border: 1px solid var(--primary-border);
  box-shadow: 0 4px 12px rgba(124, 99, 168, 0.1);
  flex-shrink: 0;
}

.brand-text {
  flex: 1;
  min-width: 0;
}

.dept-badge {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent-yellow-text);
  background: var(--accent-yellow-bg);
  border: 1px solid var(--accent-yellow-border);
  padding: 4px 14px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.site-title {
  font-size: clamp(1.45rem, 2.6vw, 2rem);
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
  margin-bottom: 6px;
}

.site-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
}

/* ปุ่มสลับมุมมองสำหรับผู้ใช้งาน & ปุ่มจัดการรหัสผ่านมุมขวาบน */
.hero-actions {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.user-view-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px solid var(--primary-border);
  padding: 4px 6px;
  border-radius: 999px;
  box-shadow: 0 3px 10px rgba(124, 99, 168, 0.08);
}

.user-view-label {
  font-family: 'Prompt', sans-serif;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 6px;
}

.user-view-btn {
  font-family: 'Prompt', sans-serif;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-main);
  background: transparent;
  border: none;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.user-view-btn:hover {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.user-view-btn.active {
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(124, 99, 168, 0.25);
}

body.theme-hybrid .user-view-switcher {
  display: none;
}

.passcode-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  color: var(--primary);
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid var(--primary-border);
  box-shadow: 0 3px 10px rgba(124, 99, 168, 0.08);
  cursor: pointer;
  transition: all 0.2s ease;
}

.admin-portal-btn {
  background: var(--accent-yellow-bg);
  color: var(--accent-yellow-text);
  border-color: var(--accent-yellow-border);
}

.passcode-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.passcode-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(124, 99, 168, 0.24);
  transform: translateY(-1px);
}

/* =========================================================
   ช่องค้นหาและตัวกรองหมวดหมู่
   ========================================================= */
.toolbar {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--primary-border);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.search-box {
  position: relative;
  flex: 1 1 280px;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--primary);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 42px;
  font-family: 'Sarabun', sans-serif;
  font-size: 0.98rem;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid var(--primary-border);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(124, 99, 168, 0.14);
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.role-switcher {
  display: inline-flex;
  align-items: center;
  background: rgba(244, 237, 253, 0.85);
  border: 1.5px solid var(--primary-border);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
}

.role-pill {
  font-family: 'Prompt', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.role-pill:hover {
  color: var(--primary);
}

.role-pill.active {
  background: var(--accent-yellow-bg);
  color: var(--accent-yellow-text);
  box-shadow: 0 2px 8px rgba(133, 93, 14, 0.14);
  font-weight: 600;
}

/* =========================================================
   แถบข่าวประกาศล่าสุดอัตโนมัติ (Live Announcements Ticker)
   ========================================================= */
.live-announcements-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1.5px solid var(--primary-border);
  border-left: 5px solid var(--primary);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(93, 70, 138, 0.06);
  backdrop-filter: blur(10px);
}

.live-ann-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Prompt', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--primary);
  padding: 4px 12px;
  border-radius: 999px;
  flex-shrink: 0;
}

.live-ann-badge svg {
  width: 14px;
  height: 14px;
}

.live-ann-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  flex: 1;
  min-width: 220px;
}

.live-ann-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-main);
  text-decoration: none;
  padding: 3px 10px;
  border-radius: 999px;
  background: #faf7fe;
  border: 1px solid var(--primary-border);
  max-width: 100%;
  transition: all 0.18s ease;
}

.live-ann-item:hover {
  background: var(--accent-yellow-bg);
  border-color: var(--accent-yellow-border);
  color: var(--accent-yellow-text);
  transform: translateY(-1px);
}

.live-ann-pin {
  font-family: 'Prompt', sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent-yellow-text);
  background: var(--accent-yellow-bg);
  border: 1px solid var(--accent-yellow-border);
  padding: 1px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.live-ann-org {
  font-family: 'Prompt', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
  flex-shrink: 0;
}

.live-ann-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 340px;
  font-weight: 500;
}

.live-ann-more {
  font-family: 'Prompt', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}

.live-ann-more:hover {
  text-decoration: underline;
}

.app-dual-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.app-btn-secondary {
  background: var(--accent-yellow-bg);
  color: var(--accent-yellow-text);
  border: 1.5px solid var(--accent-yellow-border);
}

.app-btn-secondary:hover {
  background: #fceca8;
  color: #6b4908;
  box-shadow: 0 6px 14px rgba(133, 93, 14, 0.16);
}

.filter-pill {
  border: 1px solid var(--primary-border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 500;
  padding: 7px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.filter-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(124, 99, 168, 0.28);
}

/* =========================================================
   ส่วนแสดงการ์ดระบบงานแบบสมมาตรกึ่งกลางอัตโนมัติ
   ========================================================= */
.main-content {
  flex: 1;
  padding: 14px 0 44px;
}

.status-message {
  text-align: center;
  padding: 48px 20px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  color: var(--text-muted);
  backdrop-filter: blur(10px);
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 14px;
  border: 3.5px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-right-color: var(--accent-yellow-dot);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================================================
   แถบเมนูลัดแนวนอนด้านบน (Top Quick-Access Bar: TOP_BAR)
   ========================================================= */
.top-bar-section {
  margin-bottom: 24px;
  padding: 12px 16px 14px;
  background: linear-gradient(
    135deg,
    rgba(254, 249, 231, 0.86) 0%,
    rgba(245, 238, 254, 0.86) 100%
  );
  border: 1.5px solid var(--accent-yellow-border);
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(124, 99, 168, 0.07);
  backdrop-filter: blur(12px);
}

.top-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.top-bar-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-yellow-text);
  background: rgba(254, 246, 216, 0.95);
  border: 1px solid var(--accent-yellow-border);
  padding: 3px 11px;
  border-radius: 999px;
}

.top-bar-label svg {
  width: 13px;
  height: 13px;
  color: var(--primary);
  flex-shrink: 0;
}

.top-bar-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.top-bar-grid.cols-1 {
  grid-template-columns: minmax(260px, 520px);
  justify-content: center;
}

.top-bar-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.top-bar-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.top-bar-grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.quick-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--primary-border);
  border-left: 4px solid var(--primary);
  box-shadow: 0 3px 10px rgba(93, 70, 138, 0.05);
  text-decoration: none;
  color: var(--text-main);
  min-width: 0;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

a.quick-card:hover {
  transform: translateY(-2px);
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 8px 18px rgba(124, 99, 168, 0.14);
}

.quick-card.is-disabled {
  opacity: 0.78;
  cursor: not-allowed;
  border-left-color: #b8adc9;
  background: rgba(250, 248, 253, 0.82);
}

.quick-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-yellow-bg) 0%, var(--primary-soft) 100%);
  border: 1px solid var(--accent-yellow-border);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.quick-card-icon svg {
  width: 18px;
  height: 18px;
}

.quick-card-body {
  flex: 1;
  min-width: 0;
}

.quick-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}

.quick-card-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-card-badge {
  font-size: 0.68rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.quick-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-card-arrow {
  width: 16px;
  height: 16px;
  color: var(--primary);
  flex-shrink: 0;
  opacity: 0.65;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

a.quick-card:hover .quick-card-arrow {
  transform: translate(2px, -2px);
  opacity: 1;
}

.category-section {
  margin-bottom: 36px;
}

.category-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 18px;
  text-align: center;
}

.category-heading::before,
.category-heading::after {
  content: '';
  height: 3px;
  width: 36px;
  border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}

.category-heading::before {
  background: linear-gradient(90deg, var(--accent-yellow-dot) 0%, var(--primary) 100%);
}

.category-heading::after {
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent-yellow-dot) 100%);
}

/* Flex Container จัดการ์ดกึ่งกลางทุกแถวโดยคงขนาดเท่ากัน */
.apps-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 20px;
}

/* การ์ดแอปพลิเคชัน (บนคอมพิวเตอร์: สูงสุด 3 ใบต่อแถว เท่ากันทุกใบ) */
.app-card {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 0 0 calc((100% - 40px) / 3);
  max-width: 360px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(12px);
  overflow: hidden;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.app-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, #b59de0 55%, #f2d06b 100%);
  opacity: 0.9;
}

.app-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-shadow-hover);
  border-color: #c8b4ec;
}

.app-card.is-disabled {
  opacity: 0.82;
}

.app-card.is-disabled:hover {
  transform: none;
  box-shadow: var(--card-shadow);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.app-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary-soft) 0%, var(--accent-yellow-bg) 100%);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-icon-wrap svg {
  width: 24px;
  height: 24px;
}

/* ป้ายสถานะโทนพาสเทล */
.app-badge {
  font-size: 0.76rem;
  font-weight: 500;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-active {
  background: #e5f6ed;
  color: #216b49;
  border: 1px solid #bce4cf;
}

.badge-restricted {
  background: var(--accent-yellow-bg);
  color: var(--accent-yellow-text);
  border: 1px solid var(--accent-yellow-border);
}

.badge-coming_soon {
  background: #f1edf7;
  color: #706385;
  border: 1px solid #dfd7ec;
}

.badge-maintenance {
  background: #ffedd5;
  color: #9a3412;
  border: 1px solid #fdba74;
}

.badge-advisor_only {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #a5b4fc;
}

/* =========================================================
   โหมดปิดปรับปรุงระบบ (Full Portal Maintenance Screen)
   ========================================================= */
.admin-maintenance-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 18px;
  border-radius: 14px;
  background: #fff7ed;
  border: 1.5px solid #fb923c;
  color: #9a3412;
  font-size: 0.88rem;
  box-shadow: 0 4px 14px rgba(154, 52, 18, 0.08);
}

.maintenance-screen {
  text-align: center;
  max-width: 680px;
  margin: 24px auto 40px;
  padding: 42px 28px;
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid #fdba74;
  border-radius: 24px;
  box-shadow: 0 16px 38px rgba(154, 52, 18, 0.1);
  backdrop-filter: blur(12px);
}

.maintenance-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, #ffedd5 0%, #fef3c7 100%);
  border: 1.5px solid #fdba74;
  color: #c2410c;
  display: flex;
  align-items: center;
  justify-content: center;
}

.maintenance-icon svg {
  width: 34px;
  height: 34px;
}

.maintenance-heading {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 10px;
}

.maintenance-desc {
  font-size: 0.98rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 16px;
}

.maintenance-eta-box {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 999px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  font-size: 0.9rem;
}

.app-title {
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
  line-height: 1.38;
}

.app-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  flex: 1;
}

.app-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(244, 237, 253, 0.55);
  padding: 8px 12px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.app-meta svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
  flex-shrink: 0;
}

/* ปุ่มเปิดระบบงาน */
.app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 0.94rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: #ffffff;
  transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.app-btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 16px rgba(124, 99, 168, 0.26);
}

.app-btn.btn-disabled {
  background: #ebe6f4;
  color: #847799;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

/* =========================================================
   แถบปุ่มลิงก์หน่วยงานภายนอกด้านล่าง (External Links Bar)
   ========================================================= */
.external-links-section {
  margin-top: 26px;
  padding: 24px 26px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(12px);
}

.external-links-heading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  text-align: center;
  margin-bottom: 16px;
}

.external-links-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.external-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.96);
  border: 1.5px solid var(--primary-border);
  box-shadow: 0 3px 10px rgba(93, 70, 138, 0.06);
  transition: all 0.2s ease;
}

.external-link-btn svg {
  width: 14px;
  height: 14px;
  color: var(--primary);
  flex-shrink: 0;
  transition: transform 0.2s ease, color 0.2s ease;
}

.external-link-btn:hover {
  background: var(--accent-yellow-bg);
  border-color: var(--accent-yellow-border);
  color: var(--accent-yellow-text);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(133, 93, 14, 0.14);
}

.external-link-btn:hover svg {
  color: var(--accent-yellow-text);
  transform: translate(2px, -2px);
}

/* =========================================================
   ส่วนท้าย (Footer)
   ========================================================= */
.site-footer {
  background: rgba(255, 255, 255, 0.78);
  border-top: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
  padding: 20px 0;
}

.footer-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  text-align: left;
}

.footer-admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-family: 'Prompt', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--primary-border);
  cursor: pointer;
  transition: all 0.18s ease;
}

.footer-admin-btn svg {
  width: 13px;
  height: 13px;
  color: var(--primary);
}

.footer-admin-btn:hover {
  background: var(--accent-yellow-bg);
  color: var(--accent-yellow-text);
  border-color: var(--accent-yellow-border);
}

.footer-text {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
}

.contact-info {
  font-size: 0.86rem;
  color: var(--text-muted);
}

/* =========================================================
   Responsive สำหรับแท็บเล็ตและมือถือ
   ========================================================= */
@media (max-width: 960px) {
  .app-card {
    flex: 0 0 calc((100% - 20px) / 2);
    max-width: 420px;
  }

  .top-bar-grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .top-bar-grid,
  .top-bar-grid.cols-2,
  .top-bar-grid.cols-3,
  .top-bar-grid.cols-4 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .hero-top-row {
    flex-direction: column;
    gap: 14px;
  }

  .hero-actions {
    align-self: flex-end;
  }
}

@media (max-width: 680px) {
  .hero-header {
    padding: 20px 0 14px;
  }

  .hero-inner {
    padding: 20px;
    border-radius: 18px;
  }

  .brand-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .dept-logo {
    width: 64px;
    height: 64px;
  }

  .hero-actions {
    align-self: stretch;
  }

  .passcode-btn {
    width: 100%;
    justify-content: center;
  }

  .search-box {
    max-width: 100%;
  }

  .category-filters {
    width: 100%;
    justify-content: center;
  }

  .category-heading::before,
  .category-heading::after {
    width: 24px;
  }

  .top-bar-section {
    padding: 10px 12px 12px;
    margin-bottom: 18px;
  }

  .top-bar-grid,
  .top-bar-grid.cols-1,
  .top-bar-grid.cols-2,
  .top-bar-grid.cols-3,
  .top-bar-grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .quick-card {
    padding: 9px 10px;
    gap: 8px;
  }

  .quick-card-icon {
    width: 32px;
    height: 32px;
  }

  .quick-card-icon svg {
    width: 16px;
    height: 16px;
  }

  .quick-card-title {
    font-size: 0.85rem;
  }

  .quick-card-desc {
    font-size: 0.75rem;
  }

  .quick-card-arrow {
    display: none;
  }

  .app-card {
    flex: 0 0 100%;
    max-width: 480px;
  }

  .external-links-section {
    padding: 18px 16px;
  }

  .external-link-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .top-bar-grid,
  .top-bar-grid.cols-1,
  .top-bar-grid.cols-2,
  .top-bar-grid.cols-3,
  .top-bar-grid.cols-4 {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   หน้าต่างจัดการข้อมูล Portal Hub (Admin Modal & Forms)
   ========================================================= */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(34, 24, 53, 0.58);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.admin-modal-card {
  width: 100%;
  max-width: 1120px;
  max-height: 92vh;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid var(--primary-border);
  border-radius: 22px;
  padding: 24px 26px;
  box-shadow: 0 22px 54px rgba(34, 24, 53, 0.28);
}

.admin-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--primary-border);
}

.admin-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.admin-login-box {
  max-width: 440px;
  margin: 18px auto 12px;
  padding: 22px;
  background: #faf7fe;
  border: 1px solid var(--primary-border);
  border-radius: 16px;
}

.admin-muted {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.admin-form-group {
  margin-bottom: 12px;
}

.admin-form-group label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.admin-input {
  width: 100%;
  padding: 9px 12px;
  font-family: 'Sarabun', sans-serif;
  font-size: 0.94rem;
  color: var(--text-main);
  background: #ffffff;
  border: 1.5px solid var(--primary-border);
  border-radius: 10px;
  outline: none;
}

.admin-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 99, 168, 0.14);
}

.admin-btn-primary,
.admin-btn-outline,
.admin-btn-danger {
  font-family: 'Prompt', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
}

.admin-btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.admin-btn-primary:hover {
  background: var(--primary-hover);
}

.admin-btn-outline {
  background: #ffffff;
  color: var(--primary);
  border-color: var(--primary-border);
}

.admin-btn-outline:hover {
  background: var(--primary-soft);
}

.admin-btn-danger {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.admin-btn-danger:hover {
  background: #fecaca;
}

.admin-btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.admin-error-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fdecec;
  border: 1px solid #f5c2c2;
  color: #a42828;
  font-size: 0.86rem;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.admin-tab {
  font-family: 'Prompt', sans-serif;
  font-size: 0.86rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 10px;
  background: #ffffff;
  color: var(--primary);
  border: 1.5px solid var(--primary-border);
  cursor: pointer;
}

.admin-tab.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.admin-pane-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-editor-box {
  background: #faf7fe;
  border: 1.5px solid var(--primary-border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.admin-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.admin-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
}

.admin-grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: #ffffff;
}

.admin-table th,
.admin-table td {
  border: 1px solid var(--primary-border);
  padding: 9px 11px;
  vertical-align: middle;
}

.admin-col-title {
  min-width: 240px;
  line-height: 1.4;
}

.admin-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Prompt', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
}

.admin-sync-saving {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.admin-sync-saved {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.btn-busy {
  opacity: 0.72;
  pointer-events: none;
}

.admin-table th {
  background: var(--primary-soft);
  color: var(--text-main);
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  text-align: left;
}

.portal-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1100;
  background: #33264a;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
}

/* =========================================================
   แถบสลับโหมดพรีวิว (Preview Switcher Bar - โทนพาสเทลม่วง-เหลือง)
   ========================================================= */
.design-preview-bar {
  background: linear-gradient(90deg, #ede4fb 0%, #fef3c7 100%);
  color: #3d2a5d;
  border-bottom: 2px solid #e6c86e;
  padding: 8px 0;
  font-size: 0.84rem;
}

.preview-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.preview-bar-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 500;
}

.preview-tag {
  font-family: 'Prompt', sans-serif;
  font-size: 0.74rem;
  font-weight: 700;
  background: #6d519c;
  color: #ffffff;
  padding: 2px 10px;
  border-radius: 999px;
}

.preview-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.preview-btn-group {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid #d4c4ef;
  border-radius: 8px;
  padding: 3px;
  gap: 4px;
}

.preview-mode-btn,
.preview-layout-btn {
  font-family: 'Prompt', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: #4f3a75;
  background: transparent;
  border: none;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preview-mode-btn:hover,
.preview-layout-btn:hover {
  color: #2f1f4d;
  background: rgba(235, 224, 252, 0.65);
}

.preview-mode-btn.active,
.preview-layout-btn.active {
  background: #6d519c;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(109, 81, 156, 0.25);
}

/* ปุ่มเลือกธีมในหน้า Admin (Admin Theme Switcher Cards) */
.admin-theme-switcher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.admin-theme-option-btn {
  text-align: left;
  background: #ffffff;
  border: 2px solid #d8c8f2;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: 'Sarabun', sans-serif;
}

.admin-theme-option-btn:hover {
  border-color: #7c63a8;
  background: #fdfbff;
}

.admin-theme-option-btn.active {
  border-color: #6d519c;
  background: linear-gradient(135deg, #f3ecfd 0%, #fef6d8 100%);
  box-shadow: 0 4px 12px rgba(109, 81, 156, 0.16);
}

.admin-theme-opt-title {
  font-family: 'Prompt', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  color: #382659;
  margin-bottom: 4px;
}

.admin-theme-opt-desc {
  font-size: 0.8rem;
  color: #62537d;
  line-height: 1.45;
}

/* ซ่อนเมนูแนวนอนแบบคลาสสิกในโหมดพาสเทลเดิม */
.classic-menubar {
  display: none;
}

/* =========================================================
   โหมดลูกผสมพาสเทลม่วง-เหลือง (Hybrid Classic-Pastel Institutional Theme)
   ========================================================= */
body.theme-hybrid {
  background-color: #f8f5fd;
  color: #33264a;
}

body.theme-hybrid .bg-overlay {
  background: linear-gradient(
    135deg,
    rgba(245, 240, 253, 0.94) 0%,
    rgba(253, 250, 242, 0.94) 55%,
    rgba(254, 247, 224, 0.94) 100%
  ) !important;
}

body.theme-hybrid .hero-header {
  padding: 0;
  background: linear-gradient(135deg, #e9dff9 0%, #f3ecfc 52%, #fef4d1 100%);
  border-bottom: 3px solid #e6c665;
  box-shadow: 0 4px 14px rgba(109, 81, 156, 0.1);
  margin-bottom: 18px;
}

body.theme-hybrid .hero-inner {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  padding: 20px 20px 0;
}

body.theme-hybrid .hero-top-row {
  align-items: center;
  padding-bottom: 16px;
}

body.theme-hybrid .dept-logo {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  border: 2px solid #e6c665;
  background: #ffffff;
  padding: 6px;
  box-shadow: 0 3px 10px rgba(109, 81, 156, 0.1);
}

body.theme-hybrid .dept-badge {
  background: #fef6d8;
  color: #7c540b;
  border: 1px solid #eccf78;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 11px;
  margin-bottom: 6px;
}

body.theme-hybrid .site-title {
  color: #3b2860;
  font-size: clamp(1.35rem, 2.3vw, 1.75rem);
  margin-bottom: 4px;
}

body.theme-hybrid .site-subtitle {
  color: #5d4a82;
  font-size: 0.94rem;
}

body.theme-hybrid .passcode-btn {
  border-radius: 8px;
  background: #ffffff;
  color: #4a3570;
  border: 1.5px solid #cbb6ec;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(109, 81, 156, 0.08);
}

body.theme-hybrid .passcode-btn:hover {
  background: #fef6d8;
  color: #7c540b;
  border-color: #e6c665;
}

/* แถบเมนูนำทางแนวนอนแบบเว็บทางการดั้งเดิม (โทนม่วงพาสเทล-เหลืองครีม) */
body.theme-hybrid .classic-menubar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: #dfd1f5;
  margin: 0 -20px;
  padding: 0 20px;
  border-top: 1px solid #cbb8eb;
}

.classic-menubar-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.classic-nav-item {
  font-family: 'Prompt', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: #3f2b63;
  background: transparent;
  border: none;
  border-right: 1px solid #cbb8eb;
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.classic-nav-item:first-child {
  border-left: 1px solid #cbb8eb;
}

.classic-nav-item:hover {
  background: rgba(255, 255, 255, 0.55);
  color: #2b1b47;
}

.classic-nav-item.active {
  background: #fef3c7;
  color: #6b4706;
  font-weight: 700;
  box-shadow: inset 0 -3px 0 #d9a72a;
}

.classic-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
}

.classic-view-label {
  font-family: 'Prompt', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: #4f3a75;
}

.classic-view-btn {
  font-family: 'Prompt', sans-serif;
  font-size: 0.76rem;
  font-weight: 500;
  color: #4a3570;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid #bfa8e6;
  padding: 4px 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.classic-view-btn:hover {
  background: #ffffff;
}

.classic-view-btn.active {
  background: #6d519c;
  color: #ffffff;
  border-color: #6d519c;
  font-weight: 600;
}

/* แถบค้นหาและตัวกรองด้านล่างแบนเนอร์ในโหมดลูกผสมพาสเทล */
body.theme-hybrid .toolbar {
  background: #ffffff;
  margin: 0 -20px;
  padding: 12px 20px;
  border-top: none;
  border-bottom: 1px solid #dcd0f0;
}

body.theme-hybrid .search-box input {
  border-radius: 8px;
  border: 1.5px solid #d1c1ec;
  background: #faf7fe;
  padding-top: 8px;
  padding-bottom: 8px;
}

body.theme-hybrid .role-switcher {
  border-radius: 8px;
  background: #f5effd;
  border: 1px solid #d8c8f2;
}

body.theme-hybrid .role-pill {
  border-radius: 6px;
}

body.theme-hybrid .role-pill.active {
  background: #6d519c;
  color: #ffffff;
}

body.theme-hybrid .category-filters {
  display: none;
}

/* แถบประกาศและบริการด่วนในโหมดลูกผสมพาสเทล */
body.theme-hybrid .live-announcements-bar {
  border-radius: 10px;
  background: #ffffff;
  border: 1.5px solid #d8c8f2;
  border-left: 5px solid #7c63a8;
  box-shadow: 0 2px 8px rgba(109, 81, 156, 0.06);
}

body.theme-hybrid .live-ann-badge {
  border-radius: 6px;
  background: #6d519c;
}

body.theme-hybrid .live-ann-item {
  border-radius: 6px;
  background: #faf7fe;
  border-color: #dfd2f5;
}

body.theme-hybrid .top-bar-section {
  background: #ffffff;
  border: 1.5px solid #d8c8f2;
  border-top: 3px solid #e6c665;
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(109, 81, 156, 0.06);
  padding: 14px 16px;
}

body.theme-hybrid .top-bar-label {
  border-radius: 6px;
  background: #fef6d8;
  border-color: #eccf78;
  color: #7c540b;
}

body.theme-hybrid .quick-card {
  border-radius: 8px;
  background: #faf7fe;
  border: 1px solid #d8c8f2;
  border-left: 4px solid #7c63a8;
  box-shadow: none;
}

body.theme-hybrid a.quick-card:hover {
  background: #fef9e7;
  border-color: #d9a72a;
  transform: none;
}

/* กล่องหมวดหมู่ระบบงานแบบมีหัวแถบสีม่วงพาสเทลคาดทอง (Structured Pastel Panel Box) */
.hybrid-panel-box {
  background: #ffffff;
  border: 1.5px solid #d5c5f0;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(109, 81, 156, 0.06);
  overflow: hidden;
  margin-bottom: 24px;
}

.hybrid-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: linear-gradient(90deg, #e7dcf8 0%, #f3ecfd 65%, #fef6d8 100%);
  color: #3b2860;
  padding: 11px 18px;
  border-bottom: 2.5px solid #e6c665;
}

body.theme-hybrid .category-heading {
  color: #3b2860;
  margin: 0;
  font-size: 1.06rem;
  justify-content: flex-start;
  text-align: left;
}

body.theme-hybrid .category-heading::before,
body.theme-hybrid .category-heading::after {
  display: none;
}

.hybrid-panel-count {
  font-family: 'Prompt', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  background: #ffffff;
  color: #6d519c;
  border: 1px solid #d1c1ec;
  padding: 2px 11px;
  border-radius: 999px;
}

body.theme-hybrid .apps-grid {
  padding: 22px 24px;
  justify-content: center;
  align-items: stretch;
  gap: 20px;
  background: #fcfaff;
}

body.theme-hybrid .app-card {
  flex: 0 1 calc((100% - 40px) / 3);
  max-width: 350px;
  min-width: 280px;
  background: #ffffff;
  border: 1.5px solid #dcd0f0;
  border-top: 3.5px solid #8b72b8;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(109, 81, 156, 0.05);
  backdrop-filter: none;
  padding: 20px;
}

/* จัดสมมาตรกึ่งกลางตามจำนวนการ์ดในหมวดหมู่ (1, 2, 4 หรือหลายใบ) */
body.theme-hybrid .apps-grid.grid-count-1 .app-card {
  flex: 0 1 480px;
  max-width: 480px;
}

body.theme-hybrid .apps-grid.grid-count-2 .app-card {
  flex: 0 1 calc((100% - 24px) / 2);
  max-width: 440px;
}

body.theme-hybrid .apps-grid.grid-count-4 .app-card {
  flex: 0 1 calc((100% - 24px) / 2);
  max-width: 440px;
}

@media (max-width: 960px) {
  body.theme-hybrid .app-card,
  body.theme-hybrid .apps-grid.grid-count-2 .app-card,
  body.theme-hybrid .apps-grid.grid-count-4 .app-card {
    flex: 0 1 calc((100% - 20px) / 2);
    max-width: 420px;
  }
}

@media (max-width: 680px) {
  body.theme-hybrid .app-card,
  body.theme-hybrid .apps-grid.grid-count-1 .app-card,
  body.theme-hybrid .apps-grid.grid-count-2 .app-card,
  body.theme-hybrid .apps-grid.grid-count-4 .app-card {
    flex: 1 1 100%;
    max-width: 100%;
  }
}

body.theme-hybrid .app-card::before {
  display: none;
}

body.theme-hybrid .app-card:hover {
  transform: translateY(-2px);
  border-color: #7c63a8;
  box-shadow: 0 6px 16px rgba(109, 81, 156, 0.12);
}

body.theme-hybrid .app-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, #efe8fa 0%, #fef6d8 100%);
  border: 1px solid #d5c5f0;
  color: #5e448a;
}

.hybrid-code-badge {
  display: inline-block;
  font-family: 'Prompt', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  background: #f3ecfd;
  color: #543b80;
  border: 1px solid #d5c5f0;
  padding: 2px 9px;
  border-radius: 6px;
}

body.theme-hybrid .app-badge {
  border-radius: 6px;
}

body.theme-hybrid .app-meta {
  border-radius: 8px;
  background: #faf7fe;
  border: 1px solid #e6dcf7;
}

body.theme-hybrid .app-btn {
  border-radius: 8px;
  background: #6d519c;
  padding: 9px 14px;
  font-size: 0.9rem;
}

body.theme-hybrid .app-btn:hover {
  background: #583e85;
}

body.theme-hybrid .app-btn.app-btn-secondary {
  background: #fef6d8;
  color: #78520a;
  border: 1.5px solid #e6c665;
}

body.theme-hybrid .app-btn.app-btn-secondary:hover {
  background: #fdeba8;
}

/* มุมมองตารางสารบัญ (Classic Table Directory View - โทนพาสเทลม่วง-เหลือง) */
.hybrid-table-wrap {
  overflow-x: auto;
}

.hybrid-directory-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  background: #ffffff;
}

.hybrid-directory-table th,
.hybrid-directory-table td {
  border-bottom: 1px solid #e6dcf7;
  border-right: 1px solid #e6dcf7;
  padding: 12px 14px;
  vertical-align: middle;
}

.hybrid-directory-table th:last-child,
.hybrid-directory-table td:last-child {
  border-right: none;
}

.hybrid-directory-table th {
  background: #f5effd;
  color: #3f2b63;
  font-family: 'Prompt', sans-serif;
  font-size: 0.84rem;
  font-weight: 600;
  text-align: left;
  border-bottom: 2px solid #d5c5f0;
}

.hybrid-directory-table tbody tr:nth-child(even) {
  background: #fcfaff;
}

.hybrid-directory-table tbody tr:hover {
  background: #fef9e7;
}

.hybrid-table-title-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #33264a;
  font-size: 0.96rem;
}

.hybrid-mini-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #efe8fa 0%, #fef6d8 100%);
  border: 1px solid #d5c5f0;
  color: #5e448a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hybrid-mini-icon svg {
  width: 17px;
  height: 17px;
}

.hybrid-table-desc {
  color: #5a4b75;
  font-size: 0.88rem;
  line-height: 1.5;
}

.hybrid-table-users {
  color: #4a3968;
  font-size: 0.84rem;
}

.hybrid-table-action .app-btn {
  padding: 7px 12px;
  font-size: 0.82rem;
}

/* ลิงก์หน่วยงานภายนอกและส่วนท้ายในโหมดลูกผสมพาสเทล */
body.theme-hybrid .external-links-section {
  background: #ffffff;
  border: 1.5px solid #d5c5f0;
  border-top: 3px solid #8b72b8;
  border-radius: 12px;
  box-shadow: 0 3px 10px rgba(109, 81, 156, 0.06);
}

body.theme-hybrid .external-link-btn {
  border-radius: 8px;
  background: #faf7fe;
  border: 1px solid #d5c5f0;
}

body.theme-hybrid .external-link-btn:hover {
  background: #fef6d8;
  border-color: #e6c665;
  color: #78520a;
}

body.theme-hybrid .site-footer {
  background: linear-gradient(90deg, #e7dcf8 0%, #f5effd 60%, #fef6d8 100%);
  color: #3b2860;
  border-top: 2.5px solid #e6c665;
}

body.theme-hybrid .footer-text {
  color: #3b2860;
}

body.theme-hybrid .contact-info {
  color: #5d4a82;
}

body.theme-hybrid .footer-admin-btn {
  border-radius: 8px;
  background: #ffffff;
  color: #4a3570;
  border-color: #c8b5e8;
}

/* =========================================================
   ปุ่มล็อกอินอาจารย์มุมขวาบน & หน้าต่าง Pop-up แจ้งเตือนอาจารย์ที่ปรึกษา
   ========================================================= */
.faculty-quick-auth-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.passcode-sub-btn {
  background: var(--accent-yellow-bg);
  color: var(--accent-yellow-text);
  border-color: var(--accent-yellow-border);
  padding: 8px 13px;
  font-size: 0.8rem;
}

.faculty-pending-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 999px;
  background: #dc2626;
  color: #ffffff;
  font-family: 'Prompt', sans-serif;
  font-size: 0.74rem;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.35);
}

.advisor-popup-card {
  max-width: 560px;
  border: 2px solid #e6c665;
  background: linear-gradient(160deg, #ffffff 0%, #fcf9ff 58%, #fef8e4 100%);
}

.advisor-popup-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 2px dashed var(--primary-border);
}

.advisor-popup-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, #fef3c7 0%, #ede4fb 100%);
  border: 1.5px solid #e6c665;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.65rem;
  flex-shrink: 0;
}

.advisor-popup-greeting {
  font-size: 0.96rem;
  color: var(--text-main);
  margin-bottom: 12px;
}

.advisor-popup-count-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(90deg, #efe8fa 0%, #fef6d8 100%);
  border: 1.5px solid #d5c5f0;
  border-left: 5px solid var(--primary);
  border-radius: 14px;
  padding: 13px 16px;
  margin-bottom: 14px;
}

.advisor-popup-count-box span {
  font-family: 'Prompt', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: #3b2860;
}

.advisor-popup-count-box strong {
  font-family: 'Prompt', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #b45309;
  background: #ffffff;
  border: 1px solid #f3dc8a;
  padding: 3px 12px;
  border-radius: 999px;
}

.advisor-popup-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.advisor-popup-item {
  background: #ffffff;
  border: 1px solid var(--primary-border);
  border-radius: 11px;
  padding: 10px 13px;
  font-size: 0.86rem;
}

.advisor-popup-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  color: #4a3570;
  margin-bottom: 3px;
}

.advisor-popup-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--primary-border);
}

.advisor-goto-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* =========================================================
   พื้นหลังเคมีอุตสาหกรรมพาสเทลมีชีวิต (Subtle Animated Chemistry BG)
   ========================================================= */
.chem-bg-decor {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.chem-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(54px);
  opacity: 0.42;
  will-change: transform;
}

.chem-orb-1 {
  width: 340px;
  height: 340px;
  top: -80px;
  right: -60px;
  background: radial-gradient(circle, #d9c5ff 0%, rgba(217, 197, 255, 0) 70%);
  animation: chemFloatSlow 18s ease-in-out infinite;
}

.chem-orb-2 {
  width: 300px;
  height: 300px;
  bottom: 8%;
  left: -80px;
  background: radial-gradient(circle, #ffeeb3 0%, rgba(255, 238, 179, 0) 70%);
  animation: chemFloatSlow 22s ease-in-out infinite reverse;
}

.chem-orb-3 {
  width: 240px;
  height: 240px;
  top: 42%;
  right: 12%;
  background: radial-gradient(circle, #e5d8ff 0%, rgba(229, 216, 255, 0) 72%);
  animation: chemFloatSlow 25s ease-in-out infinite 2s;
}

.chem-svg {
  position: absolute;
  color: #8f72c7;
  opacity: 0.13;
  will-change: transform;
}

.chem-hex-1 {
  width: 150px;
  height: 150px;
  top: 14%;
  left: 3%;
  animation: chemDrift 24s ease-in-out infinite;
}

.chem-hex-2 {
  width: 190px;
  height: 145px;
  bottom: 12%;
  right: 4%;
  color: #b78d28;
  opacity: 0.12;
  animation: chemDrift 28s ease-in-out infinite reverse;
}

.chem-flask-1 {
  width: 112px;
  height: 112px;
  top: 52%;
  left: 6%;
  opacity: 0.11;
  animation: chemFloatSlow 20s ease-in-out infinite 3s;
}

.chem-bubble {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.85), rgba(186, 158, 240, 0.25));
  border: 1px solid rgba(154, 123, 214, 0.22);
  opacity: 0;
  animation: chemBubbleRise 16s linear infinite;
}

.chem-bubble-1 { width: 14px; height: 14px; left: 12%; bottom: -20px; animation-delay: 0s; animation-duration: 15s; }
.chem-bubble-2 { width: 10px; height: 10px; left: 32%; bottom: -20px; animation-delay: 4s; animation-duration: 19s; background: radial-gradient(circle at 30% 30%, #fff, rgba(244, 206, 98, 0.35)); border-color: rgba(217, 174, 58, 0.25); }
.chem-bubble-3 { width: 16px; height: 16px; left: 74%; bottom: -20px; animation-delay: 2s; animation-duration: 17s; }
.chem-bubble-4 { width: 11px; height: 11px; left: 88%; bottom: -20px; animation-delay: 7s; animation-duration: 21s; background: radial-gradient(circle at 30% 30%, #fff, rgba(244, 206, 98, 0.35)); border-color: rgba(217, 174, 58, 0.25); }

@keyframes chemFloatSlow {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(14px, -18px, 0) scale(1.04); }
}

@keyframes chemDrift {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50% { transform: translate3d(-12px, -16px, 0) rotate(8deg); }
}

@keyframes chemBubbleRise {
  0% { transform: translate3d(0, 0, 0) scale(0.8); opacity: 0; }
  12% { opacity: 0.45; }
  85% { opacity: 0.35; }
  100% { transform: translate3d(18px, -85vh, 0) scale(1.15); opacity: 0; }
}

/* ลูกเล่น Micro-animation บนการ์ดและไอคอน */
.app-card .app-icon-box,
.top-bar-card .top-bar-icon {
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s ease;
}

.app-card:hover .app-icon-box,
.app-card:hover .app-icon-wrap,
.top-bar-card:hover .top-bar-icon,
.quick-card:hover .quick-card-icon {
  transform: translateY(-2px) rotate(-4deg) scale(1.07);
}

/* =========================================================
   น้อง IC แอบโผล่เกาะขอบแต่ละหมวด (Peeking Mascots) + โทนไอคอนพาสเทล 3D
   ========================================================= */
.top-bar-section,
.category-section {
  position: relative;
  overflow: visible !important;
}

.top-bar-section {
  margin-top: 26px;
}

.category-section {
  margin-top: 38px;
}

.section-peek-wrap {
  position: absolute;
  top: -48px;
  right: 26px;
  z-index: 5;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.section-peek-wrap.is-sliding {
  cursor: grabbing;
  z-index: 8;
}

/* คละตำแหน่งเกาะขอบแต่ละหมวดให้สมดุล สบายตา ไม่กองอยู่ด้านขวาทั้งหมด */
.section-peek-wrap.peek-pos-0 { left: 28%; right: auto; }
.section-peek-wrap.peek-pos-1 { right: 18%; left: auto; }
.section-peek-wrap.peek-pos-2 { left: 36%; right: auto; }
.section-peek-wrap.peek-pos-3 { right: 28%; left: auto; }

.section-peek-mascot-img {
  height: 60px;
  width: auto;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 5px 10px rgba(84, 58, 134, 0.2));
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: 50% 100%;
}

.top-bar-section:hover .section-peek-wrap:not(.is-sliding) .section-peek-mascot-img,
.category-section:hover .section-peek-wrap:not(.is-sliding) .section-peek-mascot-img {
  transform: translateY(-5px) scale(1.05);
}

.section-peek-wrap.is-sliding-left .section-peek-mascot-img {
  transform: translateY(-4px) rotate(-10deg) scale(1.06);
}

.section-peek-wrap.is-sliding-right .section-peek-mascot-img {
  transform: translateY(-4px) rotate(10deg) scale(1.06);
}

.section-peek-bubble {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  width: max-content;
  max-width: min(320px, 78vw);
  white-space: normal;
  text-align: center;
  line-height: 1.4;
  padding: 8px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, #fffef5 0%, #fef3c7 100%);
  border: 1.5px solid #e6c665;
  color: #5b3e07;
  font-family: 'Prompt', 'Sarabun', sans-serif;
  font-size: 0.96rem;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(84, 58, 134, 0.2);
  z-index: 10;
}

/* โทนสีไอคอนพาสเทล 3D-feel แยกตามหมวดงาน */
.app-icon-wrap,
.quick-card-icon {
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s ease;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.85), 0 4px 10px rgba(94, 68, 143, 0.12);
}

.cat-tone-study .app-icon-wrap {
  background: linear-gradient(145deg, #f3ecff 0%, #dfd0fa 100%) !important;
  color: #5b3b96 !important;
  border-color: #cbb5f3 !important;
}

.cat-tone-admin .app-icon-wrap {
  background: linear-gradient(145deg, #fff9e2 0%, #fde6a4 100%) !important;
  color: #8a5a08 !important;
  border-color: #f2d277 !important;
}

.cat-tone-lab .app-icon-wrap {
  background: linear-gradient(145deg, #e6fbf6 0%, #b8efe3 100%) !important;
  color: #0f6b60 !important;
  border-color: #8edcd0 !important;
}

.live-ann-badge svg {
  animation: icAnnWiggle 2.8s ease-in-out infinite;
  transform-origin: 30% 60%;
}

@keyframes icAnnWiggle {
  0%, 75%, 100% { transform: rotate(0deg); }
  82% { transform: rotate(-12deg); }
  90% { transform: rotate(10deg); }
}

@media (max-width: 640px) {
  .top-bar-section { margin-top: 22px; }
  .category-section { margin-top: 30px; }
  .section-peek-wrap {
    top: -35px;
    right: 12px;
  }
  .section-peek-mascot-img {
    height: 44px;
  }
  .section-peek-wrap.peek-pos-0 { left: auto; right: 24%; }
  .section-peek-wrap.peek-pos-1 { right: 10px; left: auto; }
  .section-peek-wrap.peek-pos-2 { left: auto; right: 30%; }
  .section-peek-wrap.peek-pos-3 { right: 16%; left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .live-ann-badge svg { animation: none !important; }
}
