/* =========================================
   1. ROOT VARIABLES & BASE STYLES
   ========================================= */
:root {
  --navy: #142238;
  --navy2: #1d304b;
  --bg: #f5f7fd;
  --white: #fff;
  --ink: #17243b;
  --muted: #8390a5;
  --border: #e8edf6;
  --blue: #4e68f6;
  --shadow: 0 12px 34px rgba(31, 47, 86, 0.045);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  font-family: 'Prompt', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ภาพพื้นหลังระบบ (กำหนด background-image จาก index.php / app.js) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.15; /* ปรับความเข้ม/จางของภาพได้ที่นี่ (0.1 ถึง 1.0) */
  z-index: -1;
  pointer-events: none;
}

button, input, select, textarea, .toast, .modal-note {
  font-family: inherit;
}

strong, b, h1, h2, h3, h4, h5, h6, .btn, .nav-item, th {
  font-weight: 500;
}

button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

svg.ico {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}
.svg-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.muted { color: var(--muted); }

/* =========================================
   2. TYPOGRAPHY & GLOW EFFECTS
   ========================================= */
.page-heading h1, .stat-body strong, .hero-copy h2, .modal-header h2, .confirm-body h3 {
  font-weight: 600;
  letter-spacing: -0.2px;
}

.page-heading h1, .page-heading p, .eyebrow, .section-heading h2, 
.section-heading p, .crumb, .crumb strong, .text-btn {
  text-shadow: 
    0px 1px 3px rgba(255, 255, 255, 1),
    0px 0px 10px rgba(255, 255, 255, 1),
    0px 0px 20px rgba(255, 255, 255, 0.9);
}

/* =========================================
   3. APP SHELL & SIDEBAR (Dark Pink Theme)
   ========================================= */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 258px;
  background: linear-gradient(170deg, #6c1849 0%, #3d0d29 100%);
  color: #e7edf8;
  flex: 0 0 258px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  padding: 28px 16px 18px;
}

.brand { display: flex; gap: 12px; align-items: center; padding: 3px 13px 34px; }
.brand-icon {
  width: 49px; height: 49px;
  display: grid; place-items: center;
  font-size: 26px; border-radius: 15px;
  background: linear-gradient(140deg, #eb4a89, #ff7eb1);
  box-shadow: 0 9px 23px #420f2b55;
}
.brand-logo-img { width: 100%; height: 100%; object-fit: contain; }
.brand strong { font-size: 22px; font-weight: 800; letter-spacing: -0.6px; white-space: nowrap; }
.brand strong span { color: #ffb1d8; }
.brand small { display: block; color: #95a7bf; font-size: 11px; white-space: nowrap; margin-top: 2px; }

.nav-caption { color: #7286a2; padding: 4px 15px 12px; font-size: 11px; letter-spacing: 1px; font-weight: 700; }
.nav-caption.minor { margin-top: 28px; }
.nav-list { display: grid; gap: 5px; }
.nav-item {
  width: 100%; border: 0; text-align: left; background: transparent;
  color: #bcc9da; display: flex; align-items: center; gap: 14px;
  padding: 12px 15px; border-radius: 11px; font-weight: 600;
  transition: background 0.2s, color 0.2s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.15); color: white; }
.nav-item.active {
  background: linear-gradient(100deg, #df2d70, #f55691);
  color: #fff;
  box-shadow: 0 8px 22px rgba(223, 45, 112, 0.27);
}
.nav-item .ico { width: 19px; height: 19px; }

.side-bottom {
  display: flex; align-items: center; gap: 11px;
  padding: 22px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: auto; width: 100%;
}
.profile-icon {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800;
  background: rgba(255, 255, 255, 0.15);
  color: #ffb1d8;
}
.side-bottom strong { font-size: 13px; display: block; }
.side-bottom small { color: #8fa4bd; font-size: 11px; display: block; margin-top: 2px; }

/* Guest Login Button Style */
.side-bottom.is-guest {
  margin: auto 16px 24px; width: calc(100% - 32px);
  padding: 14px 16px; border-radius: 16px;
  border: 1px dashed rgba(255, 177, 216, 0.4);
  background: rgba(255, 255, 255, 0.03);
  transition: all 0.3s ease; box-sizing: border-box;
}
.side-bottom.is-guest:hover {
  background: linear-gradient(135deg, #df2d70, #f55691);
  border-color: transparent;
  box-shadow: 0 8px 25px rgba(223, 45, 112, 0.4);
  transform: translateY(-2px);
}
.side-bottom.is-guest strong, .side-bottom.is-guest small { transition: color 0.3s ease; }
.side-bottom.is-guest:hover strong, .side-bottom.is-guest:hover small { color: #fff; }
.side-bottom.is-guest .profile-icon { background: rgba(255, 177, 216, 0.15); color: #ffb1d8; transition: all 0.3s ease; }
.side-bottom.is-guest:hover .profile-icon { background: rgba(255, 255, 255, 0.25); color: #fff; }

.login-trigger {
  border: none; background: transparent; cursor: pointer;
  transition: background 0.2s; padding: 20px 11px;
}
.login-trigger:not(.is-guest):hover { background: rgba(255, 255, 255, 0.08); }
.login-trigger strong { color: white; }

/* =========================================
   4. MAIN AREA & TOPBAR
   ========================================= */
.main-area { min-width: 0; flex: 1; }
.topbar {
  height: 77px; background: #fff; border-bottom: 1px solid #ecf0f7;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 33px; position: sticky; top: 0; z-index: 20;
}
.top-left, .top-right, .crumb { display: flex; align-items: center; gap: 12px; }
.crumb { color: #8c9ab0; font-size: 13px; gap: 10px; }
.crumb strong { color: #314562; font-weight: 700; }
.crumb .chevron { width: 12px; height: 12px; }

.top-right .avatar {
  height: 34px; width: 34px; font-size: 14px;
  display: grid; place-items: center; border-radius: 50%;
  font-weight: 800; background: #fff0f6; color: #c41c5c;
}

.icon-button {
  border: 0; background: transparent; color: #63758f;
  width: 37px; height: 37px; border-radius: 9px;
  display: grid; place-items: center;
}
.icon-button:hover { background: #eff3fa; }
.mobile-menu { display: none; }

.content-wrap { width: min(100%, 1510px); margin: 0 auto; padding: 32px 35px 60px; }
.page-view { display: none; }
.page-view.active { display: block; }

/* =========================================
   5. BUTTONS & COMPONENTS
   ========================================= */
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.page-heading h1 { margin: 0 0 6px; font-size: 27px; line-height: 1.35; }
.page-heading p { color: #8391a6; margin: 0; font-size: 13px; }
.eyebrow { color: #df2d70; letter-spacing: 1.5px; font-size: 10px; font-weight: 800; margin-bottom: 9px; }

.btn {
  border-radius: 10px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 17px; min-height: 42px; transition: transform 0.15s, background 0.15s; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn .ico { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.55; cursor: wait; transform: none; }

.btn-primary { background: #df2d70; color: #fff; box-shadow: 0 7px 18px rgba(223, 45, 112, 0.2); }
.btn-primary:hover { background: #c41c5c; }
.page-heading .btn-primary { box-shadow: 0 7px 18px rgba(223, 45, 112, 0.4), 0 0 15px rgba(255, 255, 255, 0.8); }
.btn-white { background: #fff; color: #c41c5c; box-shadow: 0 10px 25px rgba(19, 45, 129, 0.18); }
.btn-outline { background: #fff; border: 1px solid #dbe3f0; color: #465878; }
.text-btn { display: inline-flex; align-items: center; gap: 3px; border: 0; background: transparent; color: #df2d70; font-size: 12px; padding: 8px 0; }
.text-btn .ico { width: 15px; height: 15px; }

/* Dashboard Cards transparency */
.stat-card, .level-card, .surface-panel, .data-panel {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
}

/* =========================================
   6. DASHBOARD BLOCKS
   ========================================= */
.hero-panel {
  min-height: 230px; border-radius: 19px; position: relative; overflow: hidden;
  display: flex; align-items: center; margin-bottom: 23px;
  background: linear-gradient(112deg, #cf2263 0%, #e94380 55%, #f57ba9 100%);
  box-shadow: 0 20px 40px rgba(223, 45, 112, 0.13);
}
.hero-copy { padding: 25px 37px; position: relative; z-index: 2; }
.hero-chip { display: inline-block; background: rgba(255,255,255,0.16); color: #fff; border: 1px solid rgba(255,255,255,0.16); padding: 5px 12px; border-radius: 30px; font-size: 11px; font-weight: 700; }
.hero-copy h2 { font-size: 26px; line-height: 1.35; margin: 10px 0 5px; color: white; }
.hero-copy p { color: #ebf0ff; font-size: 12px; margin: 0 0 16px; }
.hero-copy .btn { min-height: 36px; padding: 8px 14px; font-size: 12px; }
.hero-illustration { position: absolute; right: 0; top: 0; bottom: 0; width: 43%; pointer-events: none; }
.hero-orb { position: absolute; border-radius: 50%; background: rgba(255,255,255,0.08); }
.orb-a { width: 290px; height: 290px; right: 45px; top: -55px; }
.orb-b { width: 190px; height: 190px; right: -50px; bottom: -120px; }
.hero-book { font-size: 115px; position: absolute; right: 115px; bottom: 24px; transform: rotate(-10deg); filter: drop-shadow(0 16px 9px rgba(36,57,145,0.3)); }
.hero-cap { font-size: 55px; position: absolute; right: 80px; top: 19px; transform: rotate(12deg); }
.hero-star { color: #dce5ff; font-size: 27px; position: absolute; }
.star-a { top: 23px; left: 25%; }
.star-b { bottom: 30px; right: 35px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card { border: 1px solid #edf0f7; border-radius: 16px; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 21px 19px; box-shadow: var(--shadow); }
.stat-icon { height: 57px; width: 57px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; flex: 0 0 57px; }
.stat-icon.blue { background: #e9f1ff; } .stat-icon.green { background: #e3f9f1; }
.stat-icon.pink { background: #ffebf4; } .stat-icon.orange { background: #fff1e0; }
.stat-body { min-width: 0; }
.stat-body span { font-size: 12px; color: #8290a5; display: block; white-space: nowrap; }
.stat-body strong { font-size: 31px; color: #1d2b46; line-height: 1.3; display: inline-block; margin-top: 3px; }
.stat-body small { font-size: 12px; color: #8696ac; margin-left: 6px; }

.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.section-heading h2 { font-size: 19px; margin: 0 0 4px; font-weight: 800; }
.section-heading p { font-size: 12px; color: #8a98ae; margin: 0; }

.level-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; margin-bottom: 27px; }
.level-card { border: 1px solid #e9edf6; border-radius: 17px; overflow: hidden; box-shadow: var(--shadow); }
.level-card-top { min-height: 93px; padding: 19px; display: flex; align-items: center; justify-content: space-between; color: white; position: relative; overflow: hidden; }
.level-card-top:after { content: ''; height: 120px; width: 120px; border-radius: 50%; position: absolute; right: -42px; top: -58px; background: rgba(255,255,255,0.12); }
.level-k .level-card-top { background: linear-gradient(110deg, #ff6999, #f44985); }
.level-p .level-card-top { background: linear-gradient(110deg, #5daeff, #4384f4); }
.level-m .level-card-top { background: linear-gradient(110deg, #ae79fd, #8657eb); }

.level-title { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.level-symbol { display: grid; place-items: center; background: rgba(255,255,255,0.2); height: 44px; width: 44px; border-radius: 12px; font-size: 25px; }
.level-title strong { display: block; font-size: 17px; }
.level-title small { display: block; font-size: 11px; opacity: 0.9; margin-top: 2px; }
.level-body { padding: 11px 13px 15px; display: grid; gap: 7px; }

.level-total-badge {
  position: relative; z-index: 1; padding: 6px 14px; border-radius: 20px; color: #ffffff;
  background: rgba(255, 255, 255, 0.25); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  display: flex; align-items: baseline; gap: 4.5px; border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08); white-space: nowrap;
}
.level-total-badge strong { font-size: 18px !important; font-weight: 800 !important; line-height: 1; }

.grade-button {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: #f9faff; border: 1px solid #eff1fa; border-radius: 10px; color: #3b4961;
  text-align: left; padding: 11px 12px; font-size: 13px; font-weight: 600; transition: background 0.15s, transform 0.15s;
}
.grade-button:hover { transform: translateX(3px); background: #edf2ff; }
.grade-button-left { display: flex; align-items: center; gap: 8px; }
.grade-dot { width: 8px; height: 8px; border-radius: 50%; background: #8f9df5; }
.level-k .grade-dot { background: #f477a0; } .level-p .grade-dot { background: #579ff4; } .level-m .grade-dot { background: #a67aed; }
.grade-count { font-size: 11px; color: #8390a5; margin-left: 5px; }
.grade-button .ico { width: 15px; height: 15px; color: #8795af; }

.overview-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.surface-panel { border: 1px solid #ebeff7; box-shadow: var(--shadow); border-radius: 16px; padding: 22px; }
.panel-title { display: flex; justify-content: space-between; align-items: start; gap: 10px; margin-bottom: 17px; }
.panel-title h3, .surface-panel > h3 { margin: 0; font-size: 15px; font-weight: 800; }
.panel-title span, .surface-panel > p { font-size: 12px; color: #90a0b2; display: block; margin: 4px 0 0; }

.distribution { display: grid; gap: 17px; padding: 7px 0; }
.bar-line { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; margin-bottom: 7px; }
.bar-line b { color: #8190a6; }
.bar-bg { height: 9px; border-radius: 12px; background: #f0f3fa; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 12px; min-width: 0; transition: width 0.3s; }
.bar-k { background: linear-gradient(90deg, #ff92b1, #f64b88); }
.bar-p { background: linear-gradient(90deg, #8acbff, #4988f6); }
.bar-m { background: linear-gradient(90deg, #c5a5fc, #865aec); }

.recent-list { display: grid; gap: 8px; }
.recent-item { display: flex; gap: 11px; align-items: center; padding: 10px; background: #fafbff; border-radius: 10px; }
.recent-avatar { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 17px; background: #fff0f6; color: #c41c5c; }
.recent-info { flex: 1; min-width: 0; }
.recent-info strong { font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-info small { font-size: 11px; color: #8c99ad; }
.recent-value { font-weight: 800; color: #df2d70; font-size: 13px; }
.empty-small { font-size: 12px; color: #9aa6b7; text-align: center; padding: 32px 10px; }

/* =========================================
   7. DATA TABLES & FORMS
   ========================================= */
.data-panel { border: 1px solid #ebeff7; box-shadow: var(--shadow); border-radius: 17px; overflow: hidden; }
.toolbar { display: flex; gap: 12px; justify-content: space-between; padding: 19px; border-bottom: 1px solid var(--border); }
.search-box { height: 42px; min-width: 240px; width: 360px; border: 1px solid #e4eaf4; border-radius: 10px; display: flex; align-items: center; gap: 9px; padding: 0 13px; color: #8897ae; }
.search-box input { outline: 0; border: 0; width: 100%; min-width: 0; color: #263750; background: transparent; font-size: 13px; }
.toolbar select { border: 1px solid #e4eaf4; border-radius: 10px; outline: 0; background: white; min-width: 195px; padding: 0 15px; color: #53647e; font-size: 13px; }

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; }
.data-table { border-collapse: collapse; width: 100%; min-width: 800px; font-size: 13px; white-space: nowrap; }
.data-table th { background: #f8faff; padding: 15px 20px; color: #8190a7; font-size: 12px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table td { padding: 15px 20px; border-bottom: 1px solid #f0f2f8; color: #42536d; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table strong { color: #24354f; font-weight: 700; }
.table-footer { padding: 14px 21px; color: #8e9cb0; font-size: 12px; background: #fbfcff; }
.row-pill { display: inline-block; border-radius: 6px; padding: 4px 9px; font-weight: 700; font-size: 11px; background: #fff0f6; color: #c41c5c; }

.delete-button { border: 0; border-radius: 7px; background: #fff0f2; color: #e04d69; width: 31px; height: 31px; display: grid; place-items: center; transition: all 0.2s; }
.delete-button:hover { background: #ffe4e6; transform: translateY(-1px); }
.delete-button .ico { height: 15px; width: 15px; }
.edit-button { border: 0; border-radius: 7px; background: #eef2ff; color: #4e68f6; width: 31px; height: 31px; display: grid; place-items: center; transition: all 0.2s; }
.edit-button:hover { background: #dbe4ff; transform: translateY(-1px); }
.edit-button .ico { height: 15px; width: 15px; }

.zero-state { text-align: center; padding: 58px 12px; color: #8996aa; }
.zero-state .zero-icon { font-size: 39px; margin-bottom: 7px; }
.zero-state h3 { margin: 5px 0; color: #43516d; }
.zero-state p { font-size: 12px; margin: 5px 0 0; }

/* Settings Layout */
.settings-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(270px, 0.8fr); gap: 19px; align-items: start; }
.settings-form { margin-top: 24px; display: grid; gap: 18px; }
.settings-form label, .modal-body label { display: flex; flex-direction: column; gap: 7px; color: #4b5563; font-size: 13.5px; font-weight: 700; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 14px; }
.settings-form .btn { justify-self: start; margin-top: 4px; }
.help-panel .btn { margin: 22px 0 10px; }
.help-panel .hint { margin-top: 15px; line-height: 1.7; color: #a07f63; background: #fff9ef; border: 1px solid #ffebce; padding: 13px; border-radius: 10px; }

/* Premium Input Styles (Height, Padding, Font, Focus Glow) */
.settings-form input, .settings-form select,
.modal-body input, .modal-body select, .input-wrapper input {
  height: auto;
  min-height: 48px;
  padding: 12px 16px;
  line-height: 1.6;
  border-radius: 12px;
  background-color: #f8fafc;
  border: 2px solid #e2e8f0;
  color: #1e293b;
  font-size: 15px;
  outline: none;
  transition: all 0.25s ease;
  width: 100%;
}
.settings-form input:focus, .settings-form select:focus,
.modal-body input:focus, .modal-body select:focus, .input-wrapper input:focus {
  background-color: #ffffff;
  border-color: #df2d70;
  box-shadow: 0 0 0 4px #ffe4f0;
}

/* Credentials specific font for clear symbols */
input[name="username"], input[type="password"], input[type="email"], .input-wrapper input {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15.5px;
  letter-spacing: 0.5px;
}

/* Term / Historical Dropdown */
.term-selector-wrapper { position: relative; }
.term-dropdown {
  background-color: #fff0f6; border: 1px solid #ffdae9; padding: 8.5px 36px 8.5px 14px;
  border-radius: 10px; color: #c41c5c; font-size: 12.5px; font-weight: 700; outline: none;
  cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23c41c5c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 4-4H2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; transition: all 0.2s;
}
.term-dropdown:hover { background-color: #ffe4f0; }
.term-dropdown.historical {
  background-color: #f1f5f9; border-color: #cbd5e1; color: #475569;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 4-4H2z'/%3E%3C/svg%3E");
}

input[type="file"]::file-selector-button {
  border: none; background: #fff0f6; color: #df2d70; padding: 6px 12px;
  border-radius: 6px; font-weight: 700; cursor: pointer; margin-right: 10px;
  transition: background 0.2s;
}
input[type="file"]::file-selector-button:hover { background: #ffdae9; }

.image-preview-wrapper { margin-top: 5px; margin-bottom: 8px; border-radius: 12px; overflow: hidden; border: 1px solid #e8edf6; background: #f8fafc; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(31, 47, 86, 0.05); }
#logoPreviewWrapper { width: 85px; height: 85px; padding: 5px; }
#logoPreviewWrapper img { width: 100%; height: 100%; object-fit: contain; }
#bgPreviewWrapper { width: 100%; max-width: 320px; height: 140px; }
#bgPreviewWrapper img { width: 100%; height: 100%; object-fit: cover; }

/* =========================================
   8. MODALS & OVERLAYS (Premium UI)
   ========================================= */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center;
  background: rgba(13, 26, 47, 0.55); padding: 17px; backdrop-filter: blur(3px);
}
.modal-backdrop.show { display: flex; }
.modal-card {
  background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 24px; box-shadow: 0 25px 50px -12px rgba(108, 24, 73, 0.3); border: 1px solid #fce7f3;
}
.modal-card::-webkit-scrollbar { width: 6px; }
.modal-card::-webkit-scrollbar-track { background: transparent; margin: 20px 0; }
.modal-card::-webkit-scrollbar-thumb { background: #fbcfe8; border-radius: 10px; }
.modal-card::-webkit-scrollbar-thumb:hover { background: #f472b6; }

.modal-header { padding: 24px 30px 20px; display: flex; align-items: start; justify-content: space-between; border-bottom: 2px solid #fff0f6; }
.modal-header h2 { font-size: 21px; margin: 0; }
.modal-body { padding: 24px 30px; display: grid; gap: 18px; }
.modal-footer { padding: 20px 30px 24px; border-top: 2px solid #fff0f6; display: flex; gap: 10px; justify-content: flex-end; background: #fafafc; border-bottom-left-radius: 24px; border-bottom-right-radius: 24px; }
.modal-footer .btn { height: 44px; padding: 0 24px; border-radius: 12px; }

#closeModal, #closeLogin, #closeProfile, #closeEditProfile, #closeChangePassword {
  background: #fff0f6; color: #df2d70; border-radius: 50%; width: 34px; height: 34px; transition: all 0.2s ease; border: 0; display: grid; place-items: center; cursor: pointer;
}
#closeModal:hover, #closeLogin:hover, #closeProfile:hover, #closeEditProfile:hover, #closeChangePassword:hover { background: #df2d70; color: #fff; transform: rotate(90deg); }

.modal-note {
  font-size: 12px; background: #fff0f6; color: #c41c5c; padding: 12px;
  border: 1px dashed #ffdae9; border-radius: 12px; font-weight: 500; text-align: center;
}

/* Custom Confirm Modal */
.confirm-card { max-width: 360px; text-align: center; border-radius: 20px; }
.confirm-body { padding: 35px 25px 15px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.confirm-icon { font-size: 48px; margin-bottom: 5px; line-height: 1; background: #fff0f6; width: 80px; height: 80px; display: grid; place-items: center; border-radius: 50%; color: #df2d70; }
.confirm-body h3 { margin: 0; font-size: 19px; color: #1d2b46; }
.confirm-body p { margin: 0; font-size: 13.5px; color: #8291a9; line-height: 1.5; }

.toast {
  position: fixed; bottom: 25px; right: 25px; z-index: 9999;
  max-width: min(400px, calc(100vw - 30px)); background: #5c143d; color: white;
  border-radius: 10px; box-shadow: 0 12px 40px #1e2c4650; padding: 13px 18px;
  font-weight: 600; font-size: 13px; opacity: 0; transform: translateY(15px);
  transition: all 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #ae334c; }
.mobile-overlay { display: none; }

/* =========================================
   9. AUTHENTICATION & PROFILES
   ========================================= */
.input-wrapper { position: relative; display: flex; align-items: center; width: 100%; }
.input-wrapper input { padding-right: 44px !important; }
.toggle-password {
  position: absolute; right: 8px; background: transparent; border: none; color: #94a3b8; cursor: pointer;
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; transition: all 0.2s;
}
.toggle-password:hover { background: #f1f5f9; color: #df2d70; }
.password-match { margin-top: -3px; min-height: 16px; }
#matchText { font-size: 11px; font-weight: 600; transition: color 0.2s; }

.password-strength { display: flex; flex-direction: column; gap: 4px; margin-top: -3px; }
.strength-bar { width: 100%; height: 6px; background: #e2e8f0; border-radius: 10px; overflow: hidden; }
.strength-fill { height: 100%; width: 0%; transition: all 0.3s ease; background: #ef4444; }
#strengthText { font-size: 11px; font-weight: 600; color: #ef4444; }

.profile-modal-body { display: flex; flex-direction: column; align-items: center; padding: 0 30px 25px; }
.profile-avatar-large {
  width: 85px; height: 85px; border-radius: 50%;
  background: linear-gradient(140deg, #eb4a89, #ff7eb1); color: white;
  font-size: 38px; font-weight: 800; display: grid; place-items: center;
  box-shadow: 0 10px 25px #df2d7040; margin-bottom: 15px; margin-top: -10px;
}
.profile-modal-body h2 { margin: 0; font-size: 22px; color: #1d2b46; font-weight: 800; }
.profile-modal-body p { margin: 5px 0 20px; color: #8291a9; font-size: 14px; }
.profile-actions { width: 100%; display: flex; flex-direction: column; gap: 10px; }

.action-btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 8px; font-size: 11.5px; font-weight: 700; border: none; cursor: pointer; transition: transform 0.15s, background 0.15s; }
.action-btn:hover { transform: translateY(-1px); }
.btn-approve { background: #dcfce7; color: #166534; } .btn-approve:hover { background: #bbf7d0; }
.btn-suspend { background: #fee2e2; color: #991b1b; } .btn-suspend:hover { background: #fecaca; }
.btn-admin { background: #e0e7ff; color: #3730a3; } .btn-admin:hover { background: #c7d2fe; }
.btn-teacher { background: #f3f4f6; color: #4b5563; } .btn-teacher:hover { background: #e5e7eb; }

.avatar-upload-wrapper { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 10px; }
.avatar-preview-circle { width: 90px; height: 90px; border-radius: 50%; background: linear-gradient(140deg, #eb4a89, #ff7eb1); color: white; font-size: 38px; font-weight: 800; display: grid; place-items: center; overflow: hidden; box-shadow: 0 8px 25px rgba(223, 45, 112, 0.25); border: 3px solid #fff0f6; }
.avatar-preview-circle img { width: 100%; height: 100%; object-fit: cover; }

/* =========================================
   10. DRAG & DROP AND GRADEBOOK
   ========================================= */
.drag-handle { cursor: grab; color: #94a3b8; padding: 5px; margin-right: 8px; display: inline-block; transition: color 0.2s; }
.drag-handle:hover { color: #df2d70; }
.drag-handle:active { cursor: grabbing; }
.data-table tr.draggable-row { transition: background 0.2s, box-shadow 0.2s; }
.data-table tr.dragging { background: #fff0f6 !important; box-shadow: 0 5px 15px rgba(223, 45, 112, 0.15); opacity: 0.9; z-index: 10; }
.data-table tr.drag-over td { 
  border-top: 2px dashed #df2d70 !important; 
}
.student-number { font-weight: 800; color: #c41c5c; background: #fff0f6; padding: 4px 10px; border-radius: 8px; display: inline-block; min-width: 32px; text-align: center; }

/* ---------- ส่วนหัวสมุดคะแนน: แท็บรายวิชา + การ์ดรายวิชา ---------- */
.gb-head { padding: 18px 19px 2px; }
.sub-tabs-label { font-size: 11px; font-weight: 800; letter-spacing: 1px; color: #8190a7; margin-bottom: 10px; }
.subject-tabs { display: flex; gap: 10px; margin-bottom: 16px; overflow-x: auto; padding: 2px 2px 8px; }
.sub-tab { display: inline-flex; align-items: center; gap: 10px; padding: 8px 16px 8px 8px; border-radius: 14px; background: #fff; color: #475569; border: 1px solid #e8edf6; cursor: pointer; white-space: nowrap; text-align: left; transition: all 0.2s; box-shadow: 0 2px 8px rgba(31, 47, 86, 0.04); }
.sub-tab:hover:not(.active) { border-color: #ffdae9; background: #fff7fb; transform: translateY(-1px); }
.sub-tab-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #fff0f6; color: #df2d70; flex: 0 0 34px; }
.sub-tab-icon .ico { width: 17px; height: 17px; }
.sub-tab-text { display: flex; flex-direction: column; line-height: 1.25; }
.sub-tab-text small { font-size: 10.5px; font-weight: 700; color: #94a3b8; letter-spacing: .3px; }
.sub-tab-text b { font-size: 13.5px; font-weight: 700; }
.sub-tab.active { background: linear-gradient(100deg, #df2d70, #f55691); border-color: transparent; color: #fff; box-shadow: 0 8px 20px rgba(223, 45, 112, 0.3); }
.sub-tab.active .sub-tab-icon { background: rgba(255,255,255,0.22); color: #fff; }
.sub-tab.active .sub-tab-text small { color: rgba(255,255,255,0.85); }

.subject-card { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; justify-content: space-between; padding: 18px 20px; border-radius: 16px; border: 1px solid #ffdae9; background: linear-gradient(110deg, #fff0f6 0%, #fff7fb 55%, #ffffff 100%); position: relative; overflow: hidden; }
.subject-card::after { content: ''; position: absolute; width: 180px; height: 180px; border-radius: 50%; right: -60px; top: -90px; background: rgba(223, 45, 112, 0.06); pointer-events: none; }
.subject-card-main { display: flex; gap: 14px; align-items: center; min-width: 0; }
.subject-card-icon { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; flex: 0 0 52px; color: #fff; background: linear-gradient(140deg, #df2d70, #ff7eb1); box-shadow: 0 8px 20px rgba(223, 45, 112, 0.28); }
.subject-card-icon .ico { width: 24px; height: 24px; }
.subject-card-info .eyebrow { margin-bottom: 4px; text-shadow: none; }
.subject-card-info h3 { margin: 0 0 7px; font-size: 19px; font-weight: 700; color: #1d2b46; }
.subject-card-info h3 span { color: #df2d70; margin-right: 4px; }
.subject-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.subject-meta span { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: #64748b; background: #fff; border: 1px solid #f1e4ec; padding: 3px 10px; border-radius: 20px; }
.subject-meta .ico { width: 13px; height: 13px; color: #df2d70; }
.subject-card-side { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; position: relative; z-index: 1; }
.ratio-box { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid #ffdae9; border-radius: 14px; padding: 8px 14px; box-shadow: 0 4px 12px rgba(223, 45, 112, 0.06); }
.ratio-title { font-size: 12.5px; font-weight: 800; color: #be185d; }
.ratio-fields { display: flex; align-items: flex-end; gap: 8px; }
.ratio-fields label { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ratio-fields small { font-size: 10.5px; font-weight: 700; color: #94a3b8; }
.ratio-fields input { width: 58px; height: 36px; text-align: center; font-size: 16px; font-weight: 800; color: #be185d; border: 2px solid #fbcfe8; border-radius: 10px; outline: none; background: #fff; }
.ratio-fields input:focus { border-color: #df2d70; box-shadow: 0 0 0 3px #fce7f3; }
.ratio-colon { font-size: 18px; font-weight: 800; color: #be185d; padding-bottom: 6px; }
.subject-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.subject-card-actions .btn { min-height: 40px; padding: 8px 16px; font-size: 13px; }
.gb-head + .gradebook-container { margin: 16px 19px 0; }
@media(max-width:630px) {
  .gb-head { padding: 14px 12px 0; }
  .gb-head + .gradebook-container { margin: 14px 12px 0; }
  .subject-card { padding: 16px; }
  .subject-card-side, .ratio-box { width: 100%; }
  .ratio-box { justify-content: space-between; }
}

.gradebook-container { overflow-x: auto; border: 1px solid #cbd5e1; border-radius: 12px; margin-top: 15px; box-shadow: 0 10px 25px rgba(0,0,0,0.05); }
.gb-table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; background: #fff; min-width: 800px; }
.gb-table th, .gb-table td { border: 1px solid #cbd5e1; padding: 6px; text-align: center; vertical-align: middle; }
.gb-thead th { font-weight: 700; color: #1e293b; background: #f8fafc; }
.gb-header-main { background: #fce7f3 !important; color: #be185d !important; font-size: 14px; padding: 10px !important; }
.gb-header-keep { background: #e0f2fe !important; color: #0369a1 !important; }
.gb-header-final { background: #fef08a !important; color: #a16207 !important; }
.gb-header-total { background: #dcfce7 !important; color: #15803d !important; }
.gb-header-grade { background: #ede9fe !important; color: #6d28d9 !important; }

/* 🌟 ปรับปรุง: คอลัมน์ "เลขที่" และ "ชื่อ-สกุล" */
.gb-sticky-id { 
  position: sticky; 
  left: 0; 
  background: #fff; 
  z-index: 10; 
  min-width: 48px; 
  border-right: none !important; 
}

.gb-sticky-name { 
  position: sticky; 
  left: 48px; 
  background: #fff; 
  z-index: 10; 
  text-align: left !important; 
  padding-left: 16px !important; 
  min-width: 220px; 
  /* ลบเส้นและเงาแบบเดิมทิ้ง เพื่อใช้แบบจำลองแทน */
  border-right: none !important; 
  box-shadow: none !important;   
  clip-path: none !important;    
}

/* 🌟 สร้างเส้นกั้นและเงาแบบลอยตัว (รับประกันว่าไม่หายตอนเลื่อนตาราง) */
.gb-sticky-name::after {
  content: '';
  position: absolute;
  top: 0;
  right: -1px; /* ขยับออกไปทับเส้นตารางเดิมพอดี */
  bottom: -1px; 
  width: 3px; /* ความหนาของเส้นกั้น */
  background-color: #94a3b8; /* สีเส้นกั้น */
  box-shadow: 8px 0 12px -1px rgba(15, 23, 42, 0.18); /* เงา 3D */
  pointer-events: none; /* ไม่ให้กีดขวางการคลิกเมาส์ */
  z-index: 12; /* บังคับให้อยู่บนสุดเหนือเซลล์อื่นๆ */
}

/* สีพื้นหลังสำหรับส่วนหัวตาราง */
.gb-thead .gb-sticky-id, .gb-thead .gb-sticky-name { 
  background: #f8fafc !important; 
  z-index: 11; 
  border-bottom: 1px solid #cbd5e1;
}

.gb-input { width: 45px; text-align: center; border: 1px solid #cbd5e1; border-radius: 6px; padding: 6px 0; font-size: 14px; font-weight: 700; color: #0f172a; background: #fff; transition: all 0.2s; outline: none; }
.gb-input:focus { border-color: #df2d70; box-shadow: 0 0 0 3px #fce7f3; transform: scale(1.1); z-index: 10; position: relative; }
.gb-input.final-exam { background: #fef9c3; border-color: #fde047; color: #854d0e; }
.gb-input.saving { background: #e2e8f0; color: #94a3b8; pointer-events: none; }
.gb-input.error-score { background-color: #fee2e2 !important; border-color: #ef4444 !important; color: #b91c1c !important; animation: shake 0.3s ease-in-out; }

.gb-res-keep { font-weight: 800; color: #0284c7; font-size: 14px; background: #f0f9ff; }
.gb-res-total { font-weight: 900; color: #16a34a; font-size: 15px; background: #f0fdf4; }
.gb-res-grade { font-weight: 900; color: #7c3aed; font-size: 16px; background: #f5f3ff; }

.ratio-setup-bar { background: #fff0f6; border: 1px solid #ffdae9; padding: 12px 20px; border-radius: 12px; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-top: 15px; color: #be185d; }
.ratio-inputs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; }
.ratio-inputs input { width: 50px; text-align: center; font-weight: 800; border: 2px solid #fbcfe8; border-radius: 8px; padding: 4px; color: #be185d; outline: none; background: white; }
.ratio-inputs input:focus { border-color: #df2d70; }

.gb-inline-add { background: #df2d70; color: white; border: none; border-radius: 6px; width: 22px; height: 22px; font-weight: 900; font-size: 16px; cursor: pointer; margin-left: 8px; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 2px 5px rgba(223, 45, 112, 0.4); transition: all 0.2s; }
.gb-inline-add:hover { transform: scale(1.15); background: #be185d; }
.gb-inline-del { background: #ffe4e6; color: #f43f5e; border: none; border-radius: 4px; width: 18px; height: 18px; font-weight: 800; cursor: pointer; margin-left: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; transition: all 0.2s; }
.gb-inline-del:hover { background: #f43f5e; color: white; transform: scale(1.15); }

.gb-inline-edit { background: #e0f2fe; color: #0284c7; border: none; border-radius: 4px; width: 18px; height: 18px; font-weight: 800; cursor: pointer; margin-left: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; transition: all 0.2s; }
.gb-inline-edit:hover { background: #0284c7; color: white; transform: scale(1.15); }

/* Global Loader */
.global-loader { position: fixed; inset: 0; background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(5px); z-index: 99999; display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.global-loader.active { opacity: 1; pointer-events: auto; }
.spinner { width: 50px; height: 50px; border: 4px solid #fff0f6; border-top-color: #df2d70; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 15px; }
.loader-text { color: #df2d70; font-weight: 800; font-size: 15px; letter-spacing: 0.5px; animation: pulse 1.5s ease-in-out infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes shake { 0%, 100% {transform: translateX(0);} 25% {transform: translateX(-3px);} 75% {transform: translateX(3px);} }

/* =========================================
   11. RESPONSIVE DESIGN (MEDIA QUERIES)
   ========================================= */
@media(max-width:1200px) {
  .sidebar { width: 232px; flex-basis: 232px; }
  .content-wrap { padding: 26px 24px 40px; }
  .topbar { padding: 0 24px; }
  .stat-card { padding: 17px 13px; gap: 10px; }
  .stat-icon { width: 47px; height: 47px; flex-basis: 47px; font-size: 22px; }
  .stat-body span { font-size: 11px; }
  .stat-body strong { font-size: 26px; }
  .level-title strong { font-size: 14px; }
  .level-card-top { padding: 14px; }
}

@media(max-width:950px) {
  .sidebar { position: fixed; left: 0; top: 0; height: 100vh; transform: translateX(-100%); transition: transform 0.25s; width: 255px; }
  .sidebar.open { transform: translateX(0); }
  .mobile-overlay.open { display: block; position: fixed; inset: 0; background: rgba(12,22,51,0.4); z-index: 30; }
  .mobile-menu { display: grid; }
  .topbar { height: 68px; }
  .content-wrap { padding: 24px 22px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .level-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .overview-bottom { grid-template-columns: 1fr; }
  .level-m { grid-column: 1 / -1; }
  .level-m .level-body { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media(max-width:630px) {
  .topbar { padding: 0 15px; height: 62px; }
  .crumb > span, .crumb .chevron { display: none; }
  .term-tag { display: none; }
  .top-right { gap: 6px; }
  .content-wrap { padding: 20px 13px 35px; }
  .page-heading { gap: 12px; align-items: flex-start; margin-bottom: 17px; }
  .page-heading h1 { font-size: 22px; }
  .page-heading p { font-size: 12px; }
  .page-heading > .btn { font-size: 12px; padding: 10px 11px; margin-top: 6px; }
  .page-heading > .btn .ico { width: 14px; height: 14px; }
  .hero-panel { min-height: 228px; }
  .hero-copy { padding: 22px; }
  .hero-copy h2 { font-size: 22px; }
  .hero-copy p { max-width: 220px; line-height: 1.5; }
  .hero-illustration { width: 40%; opacity: 0.55; }
  .hero-book { font-size: 65px; right: 12px; bottom: 40px; }
  .hero-cap { font-size: 31px; right: 20px; top: 25px; }
  .stats-grid { gap: 10px; margin-bottom: 25px; }
  .stat-card { min-height: 105px; gap: 8px; align-items: flex-start; flex-direction: column; padding: 12px; }
  .stat-icon { width: 37px; height: 37px; flex-basis: 37px; border-radius: 9px; font-size: 18px; }
  .stat-body span { font-size: 11px; }
  .stat-body strong { font-size: 24px; }
  .level-grid { grid-template-columns: 1fr; gap: 13px; }
  .level-m { grid-column: auto; }
  .level-m .level-body { grid-template-columns: 1fr; }
  .level-card-top { min-height: 69px; padding: 12px 17px; }
  .level-symbol { width: 38px; height: 38px; font-size: 20px; }
  .level-title strong { font-size: 15px; }
  .level-body { padding: 10px; }
  .grade-button { padding: 10px 12px; }
  .section-heading h2 { font-size: 17px; }
  .overview-bottom { gap: 13px; }
  .surface-panel { padding: 18px 16px; }
  .toolbar { flex-direction: column; padding: 12px; }
  .search-box { min-width: 0; width: 100%; }
  .toolbar select { height: 42px; min-width: 0; width: 100%; }
  .settings-layout { grid-template-columns: 1fr; gap: 13px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .modal-header, .modal-body, .modal-footer { padding: 19px; }
  .toast { bottom: 15px; right: 15px; }
  .crumb strong { font-size: 12px; }
}

@media(prefers-reduced-motion:reduce) {
  *, *:before, *:after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* =========================================
   12. RESULTS (ปพ.6)
   ========================================= */
.results-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.results-toolbar { align-items: flex-end; flex-wrap: wrap; justify-content: flex-start; }
.results-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 700; color: #8190a7; }
.results-field select, .results-field input { height: 42px; border: 1px solid #e4eaf4; border-radius: 10px; padding: 0 14px; min-width: 200px; color: #314562; background: #fff; font-size: 13px; outline: 0; }
.results-field select:focus, .results-field input:focus { border-color: #df2d70; box-shadow: 0 0 0 3px #ffe4f0; }
.results-mode { margin-left: auto; align-self: center; font-size: 12px; font-weight: 700; color: #be185d; background: #fff0f6; border: 1px solid #ffdae9; padding: 8px 14px; border-radius: 10px; }
.results-mode:empty { display: none; }
.results-content { padding: 0 19px 19px; }

.results-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0 4px; }
.results-stat { background: #fafbff; border: 1px solid #edf0f7; border-radius: 12px; padding: 12px 14px; }
.results-stat span { display: block; font-size: 11.5px; color: #8290a5; }
.results-stat strong { font-size: 22px; color: #1d2b46; font-weight: 700; }

.res-table th { font-size: 12px; }
.res-table .res-group-act { background: #e0f2fe !important; color: #0369a1 !important; }
.res-table .res-group-quality { background: #ede9fe !important; color: #6d28d9 !important; }
.res-table td.num { font-weight: 800; color: #0f172a; }
.res-table td.gpa { font-weight: 900; color: #7c3aed; font-size: 14px; }
.res-select { height: 32px; min-width: 82px; border: 1px solid #cbd5e1; border-radius: 8px; padding: 0 6px; font-size: 12.5px; font-weight: 700; color: #334155; background: #fff; outline: none; cursor: pointer; }
.res-select:focus { border-color: #df2d70; box-shadow: 0 0 0 3px #fce7f3; }
.res-select.v-good { background: #dcfce7; border-color: #86efac; color: #166534; }
.res-select.v-fail { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
.res-select.fill-all { min-width: 74px; font-weight: 600; color: #64748b; background: #f8fafc; }
.res-print-btn { border: 0; border-radius: 8px; background: #fff0f6; color: #c41c5c; padding: 6px 10px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.res-print-btn:hover { background: #ffdae9; }
.res-print-btn .ico { width: 14px; height: 14px; }
.results-footer { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 18px 0 4px; }
.results-footer .hint { font-size: 12px; color: #8e9cb0; }

@media(max-width:950px) { .results-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media(max-width:630px) {
  .results-field, .results-field select, .results-field input { width: 100%; min-width: 0; }
  .results-mode { margin-left: 0; width: 100%; }
  .results-content { padding: 0 12px 12px; }
}

/* ตัวอย่าง ปพ.6 ในหน้าผลการเรียน */
.res-table tr.res-active td { background: #fff0f6 !important; }
.pp6-preview { margin-top: 22px; border: 1px solid #ffdae9; border-radius: 16px; background: linear-gradient(180deg, #fff7fb 0%, #f5f7fd 100%); overflow: hidden; }
.pp6-preview-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #ffdae9; background: rgba(255,255,255,0.85); }
.pp6-preview-head strong { font-size: 16px; color: #1d2b46; }
.pp6-preview-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pp6-preview-actions select { height: 42px; border: 1px solid #e4eaf4; border-radius: 10px; padding: 0 12px; min-width: 240px; font-size: 13px; color: #314562; background: #fff; outline: 0; }
.pp6-preview-frame { padding: 18px 12px 4px; overflow-x: auto; }
.pp6-preview-frame iframe { display: block; width: 100%; min-width: 820px; height: 1160px; border: 0; background: transparent; }
@media(max-width:630px) { .pp6-preview-actions select { min-width: 0; width: 100%; } }

/* สอบรายภาคเรียน: ช่องรวมคะแนนสอบ */
.gb-header-exam { background: #fde68a !important; color: #92400e !important; }
.gb-res-exam { font-weight: 800; color: #b45309; font-size: 14px; background: #fffbeb; }

/* =========================================
   13. CLUBS (ชุมนุม)
   ========================================= */
.club-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 20px; }
.club-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px; border: 1px solid #edf0f7; background: rgba(255,255,255,0.98); box-shadow: var(--shadow); position: relative; }
.club-card-icon { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 13px; display: grid; place-items: center; color: #fff; background: linear-gradient(140deg, #df2d70, #ff7eb1); box-shadow: 0 6px 16px rgba(223, 45, 112, 0.25); }
.club-card-icon .ico { width: 21px; height: 21px; }
.club-card-body { flex: 1; min-width: 0; }
.club-card-body strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 15px; line-height: 1.35; color: #1d2b46; overflow: hidden; }
.club-card-body small { display: block; font-size: 11.5px; color: #8391a6; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.club-card-count { text-align: center; background: #fff0f6; border-radius: 12px; padding: 4px 10px; }
.club-card-count b { display: block; font-size: 18px; color: #c41c5c; line-height: 1.2; }
.club-card-count small { font-size: 10.5px; color: #be185d; }
.club-card-actions { display: flex; flex-direction: column; gap: 5px; }
.club-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px; border: 2px dashed #ffdae9; border-radius: 16px; background: rgba(255,255,255,0.9); color: #8391a6; }
.club-empty strong { color: #43516d; font-size: 15px; }
.club-table .club-cell { min-width: 230px; }
.club-table .club-select { min-width: 210px; height: 36px; }
.club-table .club-advisor { color: #64748b; font-size: 12.5px; }
.club-pill { display: inline-block; padding: 4px 12px; border-radius: 20px; background: #dcfce7; color: #166534; font-weight: 700; font-size: 12.5px; }
.res-club { font-size: 10.5px; color: #be185d; font-weight: 600; margin-top: 3px; max-width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: auto; margin-right: auto; }
