/* ==========================================================================
   FIET EdPEx Dashboard Theme
   Modeled after: https://www.ph.up.ac.th/2025/edpex-dashboard/Academic_Service.html
   Official Theme Color: #E22400 (Crimson Red - FIET RUTS)
   ========================================================================== */

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

:root {
  /* Theme Primary - #E22400 (FIET Crimson Red) */
  --theme-primary: #E22400;
  --theme-dark: #b31c00;
  --theme-deep: #4a0c00;
  --theme-soft: #fef2f0;
  --theme-border: #f8d5cf;
  --theme-gradient: linear-gradient(132deg, #380a00 0%, #6d1100 40%, #b31c00 75%, #e22400 100%);

  /* Secondary & Status Colors */
  --gold: #c4996c;
  --gold-soft: #f7eee4;
  --green: #21a447;
  --green-soft: #f0fbf3;
  --blue: #2877c7;
  --blue-soft: #eef5ff;
  --teal: #0891b2;
  --amber: #d97706;
  --amber-soft: #fff8ed;
  --red: #dc2626;
  --slate: #64748b;
  --ink: #211927;
  --muted: #6f6878;
  --line: #e5e7eb;
  --page: #f3f4f6;
  --card: #ffffff;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);

  --edpex-suite-primary: #E22400;
  --edpex-suite-target: #C33A32;
  --edpex-suite-compare: #2877C7;
  --edpex-suite-compare-2: #4B8FAE;

  --font-base: "Sarabun", "Prompt", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Top Glow Effect - Modeled after Once UI with #E22440 */
.fiet-ambient-bg {
  min-height: 100vh;
  background-color: #fafafc !important;
  background-image: 
    radial-gradient(ellipse 85% 55% at 50% -8%, rgba(226, 36, 64, 0.28) 0%, rgba(226, 36, 64, 0.14) 38%, rgba(226, 36, 64, 0.04) 65%, transparent 100%),
    radial-gradient(circle 650px at 50% 40px, rgba(226, 36, 64, 0.16) 0%, rgba(226, 36, 64, 0.05) 50%, transparent 80%) !important;
  background-repeat: no-repeat !important;
  background-attachment: fixed !important;
}

button, input, select, textarea {
  font: inherit;
}

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(226, 36, 0, 0.2);
  outline-offset: 2px;
}

/* ==========================================================================
   1. EdPEx Suite Sticky Top Navigation Bar
   ========================================================================== */

.edpex-suite-nav {
  position: sticky;
  top: 0;
  z-index: 10000;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 8px clamp(12px, 3vw, 38px);
  background: transparent !important;
  border-bottom: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}

.edpex-suite-nav.nav-hidden {
  opacity: 0;
  transform: translateY(-100%);
  pointer-events: none;
  visibility: hidden;
}

.edpex-suite-brand {
  grid-column: 1;
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  color: #2e2435;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  text-decoration: none;
}

.edpex-suite-brand::before {
  display: none;
}

.suite-brand-logo {
  height: 32px;
  max-width: 160px;
  width: auto;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}

.suite-brand-logo[src*="Logo-w"] {
  filter: brightness(0) saturate(100%) invert(18%) sepia(87%) saturate(5423%) hue-rotate(1deg) brightness(97%) contrast(110%);
}

.edpex-suite-links {
  grid-column: 2;
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  min-width: 0;
  padding: 0;
}

.edpex-suite-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 4px 6px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #4b5563;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.18s ease;
}

.edpex-suite-link i {
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s ease;
}

.edpex-suite-link:hover {
  background: transparent;
  color: var(--theme-primary);
  border: none;
}

.edpex-suite-link[aria-current="page"], .edpex-suite-link.active {
  background: transparent;
  color: var(--theme-primary);
  border: none;
  box-shadow: none;
  font-weight: 800;
}

/* =========================================================================
   Hamburger Menu Toggle Button (hidden on desktop)
   ========================================================================= */
.nav-hamburger {
  display: none;
  grid-column: 3;
  justify-self: end;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: #374151;
  font-size: 20px;
  line-height: 1;
  border-radius: 8px;
  transition: color 0.18s ease, background 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-hamburger:hover {
  color: var(--theme-primary);
  background: rgba(226, 36, 0, 0.06);
}

/* Mobile Nav Overlay Drawer */
.nav-mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.nav-mobile-overlay.open {
  opacity: 1;
}

.nav-mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(300px, 82vw);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: -8px 0 36px rgba(0, 0, 0, 0.18);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  padding: 20px 0 28px;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-mobile-drawer.open {
  transform: translateX(0);
}

.nav-mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  margin-bottom: 8px;
}

.nav-mobile-drawer-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #6b7280;
  font-size: 18px;
  padding: 6px;
  border-radius: 8px;
  line-height: 1;
  transition: color 0.18s, background 0.18s;
  -webkit-tap-highlight-color: transparent;
}

.nav-mobile-drawer-close:hover {
  color: var(--theme-primary);
  background: rgba(226, 36, 0, 0.06);
}

.nav-mobile-links {
  display: flex;
  flex-direction: column;
  padding: 4px 12px;
  gap: 4px;
}

.nav-mobile-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 10px;
  color: #374151;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.18s, color 0.18s;
  -webkit-tap-highlight-color: transparent;
}

.nav-mobile-link i {
  width: 20px;
  text-align: center;
  font-size: 16px;
  color: #6b7280;
  transition: color 0.18s;
}

.nav-mobile-link:hover,
.nav-mobile-link.active {
  background: rgba(226, 36, 0, 0.06);
  color: var(--theme-primary);
}

.nav-mobile-link.active i,
.nav-mobile-link:hover i {
  color: var(--theme-primary);
}

.nav-mobile-link.active {
  font-weight: 800;
}

@media (max-width: 768px) {
  .edpex-suite-nav {
    grid-template-columns: auto 1fr auto;
    padding: 8px 14px;
    min-height: 50px;
  }

  .edpex-suite-links {
    display: none !important; /* hidden on mobile, replaced by hamburger drawer */
  }

  .nav-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .nav-mobile-overlay {
    display: block;
    pointer-events: none;
  }

  .nav-mobile-overlay.open {
    pointer-events: auto;
  }
}

/* Floating Back-to-Top Button */
.back-to-top-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: linear-gradient(135deg, #E22400 0%, #B91C1C 100%);
  color: #ffffff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(226, 36, 0, 0.38), 0 2px 6px rgba(0, 0, 0, 0.12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.85);
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.2s ease,
              box-shadow 0.2s ease;
  will-change: transform, opacity;
}

.back-to-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.back-to-top-btn:hover {
  background: linear-gradient(135deg, #FF3515 0%, #C81E00 100%);
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 10px 24px rgba(226, 36, 0, 0.48), 0 3px 8px rgba(0, 0, 0, 0.12);
  color: #ffffff;
}

.back-to-top-btn:active {
  transform: translateY(0) scale(0.96);
  box-shadow: 0 4px 12px rgba(226, 36, 0, 0.3);
}

.back-to-top-btn i {
  line-height: 1;
  pointer-events: none;
}

@media (max-width: 640px) {
  .back-to-top-btn {
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    font-size: 15px;
  }
}

/* ==========================================================================
   2. Hero Header Banner
   ========================================================================== */

.hero {
  position: relative;
  overflow: hidden;
  background: var(--theme-gradient);
}

.hero:before, .hero:after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
}

.hero:before {
  width: 380px;
  height: 380px;
  right: -100px;
  top: -180px;
}

.hero:after {
  width: 200px;
  height: 200px;
  left: 34%;
  bottom: -145px;
}

.hero-inner {
  position: relative;
  max-width: 1440px;
  margin: auto;
  padding: 16px 30px 22px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.hero-inner:after {
  content: "";
  position: absolute;
  height: 4px;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, var(--gold), #f3dbba, var(--gold));
}

.brand-logo {
  height: auto;
  width: auto;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
}

.brand-logo img,
.brand-logo-img {
  height: 64px;
  max-width: 250px;
  width: auto;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(46, 7, 0, 0.25));
}

.brand-copy {
  min-width: 0;
}

.eyebrow, .section-kicker {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fce3cc;
  text-transform: uppercase;
}

.brand-copy h1 {
  font-size: 26px;
  color: #fff;
  line-height: 1.25;
  margin-top: 4px;
  font-weight: 800;
}

.brand-copy p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 4px;
  line-height: 1.55;
}

.hero-org {
  margin-left: auto;
  text-align: right;
  flex: 0 0 auto;
}

.hero-org-faculty {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.4;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 4px rgba(46, 7, 0, 0.35);
}

.hero-org-univ {
  font-size: 13px;
  font-weight: 500;
  color: #fce3cc;
  margin-top: 3px;
  line-height: 1.3;
}

.hero-stats {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero-stat {
  min-width: 98px;
  padding: 10px 12px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 13px;
}

.hero-stat.current {
  background: rgba(196, 153, 108, 0.25);
  border-color: rgba(240, 208, 169, 0.35);
}

.hero-stat strong {
  display: block;
  color: #fff;
  font-size: 21px;
  line-height: 1.05;
  font-weight: 800;
}

.hero-stat span {
  display: block;
  color: rgba(255, 255, 255, 0.75);
  font-size: 10.5px;
  font-weight: 700;
  margin-top: 5px;
}

/* ==========================================================================
   3. Executive Overview & Toolbar Filter Bar
   ========================================================================== */
.overview-section {
  max-width: 1440px;
  margin: 0;
  padding: 18px 30px 10px;
}

.toolbar {
  background: transparent;
  border-top: none;
  border-bottom: none;
  padding: 4px 30px 10px;
  max-width: 1440px;
  margin: 0;
}

.toolbar-inner {
  background: #ffffff;
  border-radius: 14px;
  padding: 14px 20px;
  box-shadow: 0 4px 18px rgba(74, 12, 0, 0.04);
  border: 1px solid rgba(226, 36, 0, 0.08);
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 135px;
}

.field-wide {
  min-width: 240px;
}

.field-search {
  min-width: 220px;
  flex: 1;
}

.field > span, .inline-select > span {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--theme-dark);
}

.field select, .field input, .inline-select select {
  height: 40px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #413849;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
  outline: none;
}

.field select:focus, .field input:focus, .inline-select select:focus {
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 3px rgba(226, 36, 0, 0.1);
}

/* Autocomplete Suggestions Dropdown */
.search-suggestions-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1.5px solid var(--theme-border);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(74, 12, 0, 0.16);
  max-height: 380px;
  overflow-y: auto;
  z-index: 100000;
  padding: 6px;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
  color: #2e2435;
}

.suggestion-item:hover, .suggestion-item.active {
  background: var(--theme-soft);
  color: var(--theme-primary);
}

.suggestion-code {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--theme-primary);
  background: rgba(226, 36, 0, 0.08);
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}

.suggestion-sheet {
  font-size: 10.5px;
  font-weight: 700;
  color: #72687c;
  background: #f1ecf3;
  padding: 2px 6px;
  border-radius: 5px;
  white-space: nowrap;
}

.suggestion-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.suggestion-highlight {
  color: var(--theme-primary);
  font-weight: 800;
  text-decoration: underline;
}

.suggestion-empty {
  padding: 16px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.suggestion-header {
  padding: 6px 10px 4px;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #f2ecf3;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

.toolbar-actions {
  display: flex;
  gap: 7px;
}

.button {
  height: 40px;
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: 0.16s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.button:hover {
  transform: translateY(-1px);
}

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

.button.secondary {
  background: var(--blue-soft);
  border: 1px solid #c9dcfa;
  color: #1f5da2;
}
.button.secondary:hover {
  background: #e1effe;
  border-color: #a8cdfc;
  color: #154580;
}
.button.loading .sync-icon,
#btn-sync.loading .sync-icon {
  animation: edpexSpin 0.85s linear infinite;
}

@keyframes edpexSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.button.ghost {
  background: var(--theme-soft);
  border: 1px solid var(--theme-border);
  color: var(--theme-primary);
}

.button.small {
  height: 32px;
  padding: 5px 10px;
  font-size: 11.5px;
}

.api-status {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #cfe9d7;
  background: #f0fbf3;
  color: #176534;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 11.5px;
  font-weight: 800;
}

.api-status.loading {
  background: #fff8ed;
  color: #99540f;
  border-color: #f5d5a8;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.api-status.loading .status-dot {
  animation: pulse 1.1s infinite;
}

@keyframes pulse {
  50% { opacity: 0.3; }
}

/* ==========================================================================
   4. Tab Bar Navigation
   ========================================================================== */

.tab-bar {
  position: relative;
  top: auto;
  z-index: 999;
  background: rgba(251, 249, 249, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: none;
  box-shadow: 0 4px 16px rgba(74, 12, 0, 0.03);
  padding: 6px 0;
  margin-bottom: 6px;
}

.tabs {
  max-width: 1440px;
  margin: auto;
  padding: 0 30px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab {
  border: 1px solid rgba(226, 36, 0, 0.07);
  background: #ffffff;
  padding: 9px 16px;
  border-radius: 10px;
  color: #5c5264;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  border-bottom: none;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.tab:hover {
  color: var(--theme-primary);
  background: #ffffff;
  border-color: rgba(226, 36, 0, 0.22);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(74, 12, 0, 0.06);
}

.tab.active {
  color: #ffffff;
  background: linear-gradient(135deg, #b31c00 0%, #e22400 100%);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(226, 36, 0, 0.25);
  transform: translateY(-1px);
}

.tab-count {
  display: inline-flex;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  align-items: center;
  justify-content: center;
  margin-left: 7px;
  border-radius: 999px;
  background: var(--theme-soft);
  color: var(--theme-primary);
  font-size: 11px;
  font-weight: 800;
  transition: all 0.18s;
}

.tab.active .tab-count {
  background: #ffffff;
  color: var(--theme-primary);
}

/* ==========================================================================
   5. Main Content Area & Panels
   ========================================================================== */

.page {
  max-width: 1440px;
  margin: 0;
  padding: 24px 30px 65px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.page-heading .section-kicker {
  color: #98663e;
}

.page-heading h2 {
  font-size: 22px;
  color: var(--theme-deep);
  line-height: 1.35;
  margin-top: 3px;
  font-weight: 800;
}

.page-heading p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.65;
}

.period-chip,
.period-select-wrap {
  white-space: nowrap;
  border: 1.5px solid #ead5bc;
  background: var(--gold-soft);
  color: #78502f;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(120, 80, 47, 0.05);
}

.period-select-wrap:hover {
  border-color: #d1b494;
  background: #fdf5ec;
  box-shadow: 0 3px 10px rgba(120, 80, 47, 0.12);
  transform: translateY(-1px);
}

.period-select-wrap .period-icon {
  color: #8c5828;
  font-size: 13px;
  pointer-events: none;
}

.period-select-wrap .period-arrow {
  color: #8c5828;
  font-size: 10px;
  margin-left: 2px;
  pointer-events: none;
}

.period-select-wrap select.period-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: transparent;
  border: none;
  outline: none;
  color: #78502f;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  padding-right: 2px;
}

.period-select-wrap select.period-select option {
  background: #fff;
  color: var(--ink);
  font-weight: 600;
}

/* Metric Strip (5 KPIs) */
.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 84px;
  box-shadow: 0 3px 15px rgba(74, 12, 0, 0.025);
  transition: transform 0.16s;
}

.metric:hover {
  transform: translateY(-2px);
  border-color: var(--theme-border);
}

.metric strong {
  display: block;
  font-size: 22px;
  color: var(--theme-primary);
  overflow-wrap: anywhere;
  font-weight: 800;
}

.metric span {
  display: block;
  font-size: 11.5px;
  color: #756d7c;
  line-height: 1.45;
  margin-top: 4px;
}

.metric em {
  display: block;
  font-style: normal;
  font-size: 10px;
  color: #99909f;
  margin-top: 3px;
}

/* Section Title */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 28px 0 14px;
  color: #625a69;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-title:before {
  content: "";
  width: 20px;
  height: 3px;
  border-radius: 2px;
  background: var(--gold);
}

.section-title:after {
  content: "";
  height: 1px;
  background: var(--line);
  flex: 1;
}

/* Category Breakdown Grid */
.group-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.group-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  min-height: 112px;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: all 0.16s;
}

.group-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.group-card h3 {
  font-size: 13.5px;
  color: #382541;
  line-height: 1.45;
  font-weight: 700;
}

.group-card .coverage {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
}

.coverage-track {
  height: 7px;
  background: #eee8f1;
  border-radius: 10px;
  flex: 1;
  overflow: hidden;
}

.coverage-fill {
  height: 100%;
  background: var(--accent, var(--theme-primary));
  border-radius: 10px;
  width: 0%;          /* เริ่มต้นโปร่งใส ก่อนมีข้อมูล */
  transition: width 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 0;
}


.group-card .coverage-text {
  font-size: 11px;
  font-weight: 800;
  color: #675e6e;
}

.group-card p {
  font-size: 10.5px;
  color: #918895;
  margin-top: 6px;
}

/* ==========================================================================
   6. Chart Grid & Cards
   ========================================================================== */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.chart-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: var(--shadow);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: transform 0.16s, box-shadow 0.16s;
}

.chart-card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.chart-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f2e9e7;
}

.chart-card-title {
  min-width: 0;
  flex: 1;
}

.chart-card h3 {
  font-size: 14.5px;
  color: #302037;
  line-height: 1.45;
  font-weight: 700;
}

.chart-card .sub {
  font-size: 11px;
  color: #827788;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chart-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.chart-host {
  min-height: 280px;
  position: relative;
  margin-top: 10px;
}

.chart-note {
  font-size: 11.5px;
  color: #554d5a;
  background: #faf9fb;
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  padding: 7px 10px;
  margin-top: 10px;
  line-height: 1.5;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Badges */
.group-pill, .segment-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.group-pill {
  background: var(--theme-soft);
  color: var(--theme-primary);
}

.segment-pill {
  background: var(--blue-soft);
  color: var(--blue);
}

.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}

.trend-badge.up, .trend-badge.good {
  background: #eaf8ef;
  color: #17713a;
}

.trend-badge.down {
  background: #fff0f1;
  color: #b3263c;
}

.trend-badge.warn {
  background: #fff7e7;
  color: #a35b00;
}

.trend-badge.flat, .trend-badge.na {
  background: #f1f3f6;
  color: #5d6672;
}

/* ==========================================================================
   7. Table Card Explorer
   ========================================================================== */

.table-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 30px;
}

.card-heading, .explorer-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid #f2e9e7;
}

.card-heading h3 {
  font-size: 16px;
  color: #2f1f38;
  line-height: 1.45;
  font-weight: 700;
}

.card-heading p {
  font-size: 12px;
  color: #7b7280;
  margin-top: 3px;
}

.table-scroll {
  overflow: auto;
  max-height: 65vh;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fbf5f4;
  color: var(--theme-dark);
  border-bottom: 2px solid #ecd5d1;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  font-weight: 700;
}

td {
  padding: 11px 12px;
  border-bottom: 1px solid #f4eae8;
  vertical-align: middle;
  line-height: 1.5;
}

tbody tr.clickable {
  cursor: pointer;
  transition: background 0.12s;
}

tbody tr.clickable:hover td {
  background: #fdf7f6;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.code {
  font-size: 11px;
  color: var(--theme-primary);
  font-weight: 800;
  white-space: nowrap;
}

/* ==========================================================================
   8. Embedded Graph Cards
   ========================================================================== */

.embed-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.embed-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.embed-container {
  position: relative;
  width: 100%;
  height: 420px;
  background: #0f131a;
}

.embed-container iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

/* ==========================================================================
   9. Detail Modal Window
   ========================================================================== */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(31, 14, 20, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 12000;
  backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
}

.modal-card {
  width: min(960px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
}

.modal-head {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 13px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  font-size: 16px;
  color: var(--theme-deep);
  margin-top: 2px;
  line-height: 1.45;
  font-weight: 700;
}

.modal-close {
  width: 35px;
  height: 35px;
  border: 0;
  border-radius: 9px;
  background: var(--theme-soft);
  color: var(--theme-primary);
  font-size: 20px;
  cursor: pointer;
}

.modal-body {
  padding: 18px 20px 24px;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.detail-meta div {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  background: #faf8f8;
}

.detail-meta span {
  display: block;
  font-size: 10px;
  color: #8c8290;
}

.detail-meta strong {
  display: block;
  font-size: 12px;
  color: #403447;
  margin-top: 3px;
  font-weight: 700;
}

.modal-chart {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

/* ==========================================================================
   10. Footer
   ========================================================================== */

footer {
  max-width: 1440px;
  margin: auto;
  padding: 0 30px 28px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #948b98;
  font-size: 11px;
}

.dashboard-back {
  color: var(--theme-primary);
  font-weight: 800;
  text-decoration: none;
}

.dashboard-back:hover {
  text-decoration: underline;
}

.edpex-suite-foot {
  margin-top: auto;
  padding: 18px clamp(14px, 3vw, 38px);
  border-top: none;
  background: transparent;
  color: #64748b;
  text-align: center;
  font: 500 12.5px/1.6 var(--font-base);
  letter-spacing: 0.2px;
}

/* Toast */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 16000;
  max-width: 380px;
  background: #2e1008;
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.show {
  opacity: 1;
  transform: none;
}

/* Page size buttons in pagination */
.page-size-btns .button.primary {
  background: var(--theme-primary);
  color: #fff;
  border-color: var(--theme-primary);
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   - 1180px : Tablet Landscape / Large Tablet
   - 1024px : Tablet
   - 820px  : Tablet Portrait / Large Phone
   - 640px  : Phone Landscape / Small Tablet
   - 480px  : Phone Portrait
   - 360px  : Small Phone
   ========================================================================== */

/* 1180px: Tablet Landscape */
@media (max-width: 1180px) {
  .hero-stats { display: none; }
  .group-grid { grid-template-columns: repeat(3, 1fr); }
  .metric-strip { grid-template-columns: repeat(3, 1fr); }
}

/* 1024px: Tablet */
@media (max-width: 1024px) {
  .page, .overview-section {
    padding-left: 20px;
    padding-right: 20px;
  }
  .toolbar {
    padding-left: 20px;
    padding-right: 20px;
  }
  .tabs {
    padding-left: 20px;
    padding-right: 20px;
  }
  .chart-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .embed-grid {
    grid-template-columns: 1fr;
  }
}

/* 820px: Tablet Portrait */
@media (max-width: 820px) {
  /* Hero banner */
  .hero-inner {
    padding: 14px 16px 18px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .brand-logo { height: auto; max-width: none; padding: 0; }
  .brand-logo img, .brand-logo-img { height: 48px; max-width: 160px; }
  .brand-copy h1 { font-size: 20px; }
  .brand-copy .eyebrow { font-size: 9.5px; }
  .hero-org {
    margin-left: 0;
    text-align: left;
    width: 100%;
    margin-top: 4px;
  }
  .hero-org-faculty { font-size: 13px; }
  .hero-org-univ { font-size: 11.5px; }

  /* Toolbar */
  .toolbar { padding-left: 16px; padding-right: 16px; }
  .toolbar-inner { padding: 12px 14px; }
  .field { min-width: calc(50% - 5px); flex: 1; }
  .field-wide, .field-search { min-width: 100%; flex: 0 0 100%; }
  /* Toolbar actions — ชิดขวา (thumb-friendly) */
  .toolbar-actions { width: 100%; justify-content: flex-end; }
  .toolbar-actions .button { flex: 0 1 auto; min-width: 120px; justify-content: center; }
  .api-status { width: auto; margin-left: auto; }

  /* Tabs */
  .tabs { padding-left: 16px; padding-right: 16px; }

  /* Main page */
  .page { padding: 16px 16px 48px; }
  .overview-section { padding: 14px 16px 8px; }

  /* Grids */
  .group-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid, .embed-grid { grid-template-columns: 1fr; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .detail-meta { grid-template-columns: repeat(2, 1fr); }

  /* Page heading */
  .page-heading { flex-direction: column; gap: 10px; }
  .page-heading h2 { font-size: 18px; }

  /* Period selector ชิดขวา (thumb-friendly) */
  .period-chip, .period-select-wrap { align-self: flex-end; margin-left: auto; }

  /* Footer */
  footer { flex-direction: column; }
  .edpex-suite-foot { padding: 14px 16px; font-size: 11.5px; }
}


/* 640px: Phone Landscape / Small Tablet */
@media (max-width: 640px) {
  /* Hero banner collapses fully */
  .hero-inner {
    padding: 12px 14px 16px;
    gap: 8px;
  }
  .brand-copy h1 { font-size: 18px; }
  .brand-copy .eyebrow { display: none; }
  .hero-org-faculty { font-size: 12.5px; }

  /* Toolbar: single-column fields */
  .field, .field-wide, .field-search {
    min-width: 100%;
    flex: 0 0 100%;
  }
  .toolbar-inner { gap: 10px; }

  /* Tabs: smaller text, horizontal scroll */
  .tab {
    padding: 8px 12px;
    font-size: 12px;
  }
  .tab-count {
    font-size: 10px;
    min-width: 18px;
    height: 18px;
    margin-left: 5px;
  }

  /* Group grid: 2 columns on landscape phone */
  .group-grid { grid-template-columns: repeat(2, 1fr); }
  .group-card { min-height: 96px; padding: 12px 12px; }
  .group-card h3 { font-size: 12.5px; }

  /* Metrics: 2-col */
  .metric-strip { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .metric { padding: 10px 12px; min-height: 72px; }
  .metric strong { font-size: 18px; }
  .metric span { font-size: 10.5px; }

  /* Charts: full-width */
  .chart-grid, .embed-grid { grid-template-columns: 1fr; }
  .chart-card { padding: 14px 12px; }

  /* Detail panel */
  .detail-meta { grid-template-columns: 1fr; }

  /* Section title */
  .section-title { font-size: 11px; }

  /* Toolbar action buttons ชิดขวา (thumb zone) */
  .toolbar-actions { justify-content: flex-end; }
  .toolbar-actions .button { flex: 0 1 auto; min-width: 110px; }

  /* Index page: glass icon buttons */
  .edpex-glass-container {
    column-gap: 2.5rem !important;
    row-gap: 3.5rem !important;
    padding: 1rem 0 3.5rem 0 !important;
  }
}

/* 480px: Phone Portrait */
@media (max-width: 480px) {
  /* Brand hero */
  .brand-copy h1 { font-size: 16px; }
  .hero-org-faculty { font-size: 11.5px; }
  .hero-org-univ { font-size: 10.5px; }

  /* Grids go single-column */
  .group-grid { grid-template-columns: 1fr; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }

  /* Tabs */
  .tab { padding: 7px 10px; font-size: 11.5px; }

  /* Main page */
  .page { padding: 12px 12px 40px; }
  .overview-section { padding: 10px 12px 6px; }
  .toolbar { padding-left: 12px; padding-right: 12px; }
  .toolbar-inner { padding: 10px 12px; gap: 8px; }
  .tabs { padding-left: 12px; padding-right: 12px; }

  /* Detail */
  .detail-meta { grid-template-columns: 1fr; }

  /* Back-to-top btn */
  .back-to-top-btn {
    bottom: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
    font-size: 14px;
  }

  /* Index page: icon buttons stack tighter */
  .edpex-glass-container {
    column-gap: 2rem !important;
    row-gap: 3.5rem !important;
  }

  /* Index page hero text */
  .icon-btn {
    width: 4em;
    height: 4em;
  }
  .icon-btn__label {
    font-size: 10.5px;
    width: 115px;
    max-width: 120px;
    margin-top: 14px;
  }
}

/* 360px: Small phones (Samsung Galaxy A, older iPhones) */
@media (max-width: 360px) {
  .brand-copy h1 { font-size: 15px; }
  .group-card h3 { font-size: 12px; }
  .metric strong { font-size: 17px; }
  .metric-strip { grid-template-columns: 1fr; }
  .tab { font-size: 11px; padding: 7px 8px; }
  .edpex-glass-container {
    column-gap: 1.8rem !important;
    row-gap: 3rem !important;
  }
  .icon-btn {
    width: 3.8em;
    height: 3.8em;
  }
  .icon-btn__label {
    font-size: 10px;
    width: 100px;
    max-width: 105px;
    margin-top: 12px;
  }
}

/* ==========================================================================
   10. App Sidebar Layout (SaaS Style)
   ========================================================================== */

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--page);
}

.app-sidebar {
  width: 260px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  z-index: 1000;
}

.app-sidebar-header {
  padding: 32px 24px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: center;
}

.app-sidebar-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  text-align: center;
}

.app-sidebar-logo img {
  height: 56px;
  width: auto;
}

.app-sidebar-logo span {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink);
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0;
}

.app-sidebar-search {
  padding: 20px 24px 10px;
}

.app-sidebar-search .search-box {
  display: flex;
  align-items: center;
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  color: #6b7280;
  font-size: 14px;
  gap: 8px;
}

.app-sidebar-menu-label {
  padding: 16px 24px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.app-sidebar-nav {
  padding: 0 16px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 8px;
  color: #4b5563;
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  transition: all 0.2s;
}

/* Category links look like faded buttons */
.app-sidebar-link.cat-link {
  background: #f8fafc; /* Very light gray */
  border: 1px solid #f1f5f9;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.app-sidebar-link i {
  width: 20px;
  text-align: center;
  font-size: 16px;
  color: #9ca3af;
}

.app-sidebar-link:hover {
  background: #f3f4f6;
  color: #111827;
}

.app-sidebar-link:hover i {
  color: #6b7280;
}

.app-sidebar-link.active {
  background: var(--theme-primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 6px -1px rgba(226, 36, 0, 0.2);
}

.app-sidebar-link.active i {
  color: #ffffff;
}

.app-sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-main {
  flex: 1;
  overflow-y: auto;
  position: relative;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
}

.app-main-header {
  height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 32px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 90;
}

.app-main-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

/* Hide Sidebar Top Nav on Desktop */
@media (min-width: 1181px) {
  .app-layout .edpex-suite-nav {
    display: none !important;
  }
}

/* Mobile Adjustments for Sidebar */
@media (max-width: 1180px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(0,0,0,0.1);
  }
  
  .app-sidebar.show {
    transform: translateX(0);
  }
  
  .app-main-header {
    display: none; /* Rely on top nav on mobile */
  }
  
  .app-layout {
    display: block;
    height: auto;
    overflow: visible;
  }
  
  .app-main {
    overflow: visible;
  }
}
