/* ==================== GLOBAL SERVER TH SARABUN FONT (v24.0 SQL) ==================== */
@font-face {
  font-family: 'TH Sarabun PSK';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/THSarabunNew.ttf') format('truetype');
}
@font-face {
  font-family: 'TH Sarabun PSK';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/THSarabunNewBold.ttf') format('truetype');
}
@font-face {
  font-family: 'THSarabunCheckin';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/THSarabunNew.ttf') format('truetype');
}
@font-face {
  font-family: 'THSarabunCheckin';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/THSarabunNewBold.ttf') format('truetype');
}

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

/* ==================== TRIPLE-LAYER TH SARABUN FONT ENGINE (iPad / iPhone / Android / Mac / PC) ==================== */
@font-face {
  font-family: 'TH Sarabun PSK';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local('TH Sarabun PSK'),
       local('THSarabunPSK'),
       local('TH Sarabun New'),
       local('THSarabunNew'),
       url('../fonts/THSarabunNew.ttf') format('truetype'),
       url('../fonts/THSarabunNew.woff2') format('woff2'),
       url('https://cdn.jsdelivr.net/gh/lazywasabi/thai-web-fonts@7/fonts/THSarabunNew/THSarabunNew.woff2') format('woff2');
}
@font-face {
  font-family: 'TH Sarabun PSK';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: local('TH Sarabun PSK Bold'),
       local('THSarabunPSK-Bold'),
       local('TH Sarabun New Bold'),
       local('THSarabunNew-Bold'),
       url('../fonts/THSarabunNewBold.ttf') format('truetype'),
       url('../fonts/THSarabunNewBold.woff2') format('woff2'),
       url('https://cdn.jsdelivr.net/gh/lazywasabi/thai-web-fonts@7/fonts/THSarabunNew/THSarabunNew-Bold.woff2') format('woff2');
}
@font-face {
  font-family: 'TH Sarabun Metric Fallback';
  font-style: normal;
  font-weight: 400;
  size-adjust: 73%;
  ascent-override: 95%;
  descent-override: 25%;
  src: local('Sarabun'), local('Sarabun Regular'), local('Thonburi'), local('Tahoma');
}
@font-face {
  font-family: 'TH Sarabun Metric Fallback';
  font-style: normal;
  font-weight: 700;
  size-adjust: 73%;
  ascent-override: 95%;
  descent-override: 25%;
  src: local('Sarabun Bold'), local('Sarabun-Bold'), local('Thonburi Bold'), local('Tahoma Bold');
}

:root {
  --kc-navy: #0F2C59;
  --kc-navy-dark: #091C3A;
  --kc-navy-light: #1A3E78;
  --kc-gold: #C59B27;
  --kc-gold-soft: #FDF6E2;
  --kc-bg: #F3F6FA;
  --kc-surface: #FFFFFF;
  --kc-border: #E2E8F0;
  --kc-text: #1E293B;
  --kc-muted: #64748B;
  --sidebar-width: 276px;
}

body {
  font-family: 'Sarabun', sans-serif;
  background-color: var(--kc-bg);
  color: var(--kc-text);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0;
  overflow-x: hidden;
}

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

.app-sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--kc-navy-dark) 0%, var(--kc-navy) 100%);
  color: #FFFFFF;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 3px solid var(--kc-gold);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1030;
}

.sidebar-brand {
  padding: 16px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: #FFFFFF;
  padding: 4px;
  object-fit: contain;
  border: 2px solid var(--kc-gold);
  flex-shrink: 0;
}

.sidebar-menu-group-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--kc-gold);
  padding: 13px 16px 5px;
  font-weight: 700;
}

.sidebar-nav {
  padding: 0 10px 18px;
}

.sidebar-nav .nav-link {
  color: rgba(255, 255, 255, 0.86);
  padding: 8px 13px;
  border-radius: 8px;
  margin-bottom: 3px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sidebar-nav .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
}

.sidebar-nav .nav-link.active {
  background-color: var(--kc-gold);
  color: var(--kc-navy-dark) !important;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-topbar {
  background: #FFFFFF;
  border-bottom: 1px solid var(--kc-border);
  padding: 10px 24px;
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.app-content {
  padding: 22px 24px;
  flex: 1;
}

/* Cards & Professional Tables (v5 Refined Hierarchy) */
.card-kc {
  background: var(--kc-surface);
  border: 1px solid var(--kc-border);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(15, 44, 89, 0.04);
}

.school-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.school-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(15, 44, 89, 0.09);
}

.school-logo-avatar {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: contain;
  background: #F8FAFC;
  border: 1px solid var(--kc-border);
  padding: 4px;
  flex-shrink: 0;
}

.school-logo-sm {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  object-fit: contain;
  background: #F8FAFC;
  border: 1px solid var(--kc-border);
  padding: 2px;
  flex-shrink: 0;
}

/* Professional Table Typography - Clean, Balanced, Never Oversized */
.table-kc {
  font-size: 0.875rem;
  color: #334155;
  border-collapse: separate;
  border-spacing: 0;
}

.table-kc thead th {
  background-color: var(--kc-navy);
  color: #FFFFFF;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.015em;
  border-bottom: none;
  padding: 10px 14px;
  white-space: nowrap;
}

.table-kc thead th:first-child {
  border-top-left-radius: 8px;
}
.table-kc thead th:last-child {
  border-top-right-radius: 8px;
}

.table-kc tbody td {
  padding: 10px 14px;
  font-size: 0.875rem;
  color: #334155;
  border-bottom: 1px solid #EEF2F6;
  vertical-align: middle;
  line-height: 1.42;
}

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

.table-kc tbody tr:hover td {
  background-color: #F8FAFC;
}

/* Professional Table Cell Elements */
.pro-title-cell {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--kc-navy);
  line-height: 1.38;
}

.pro-sub-cell {
  font-size: 0.77rem;
  color: var(--kc-muted);
  font-weight: 400;
  margin-top: 2px;
}

.pro-cat-tag {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  background-color: #F0F9FF;
  color: #0369A1;
  border: 1px solid #BAE6FD;
  display: inline-block;
  line-height: 1.3;
}

.pro-proj-badge-softpower {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background-color: #EFF6FF;
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
  display: inline-block;
  white-space: nowrap;
}

.pro-proj-badge-academic {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background-color: #FEFCE8;
  color: #A16207;
  border: 1px solid #FEF08A;
  display: inline-block;
  white-space: nowrap;
}

.pro-level-pill {
  font-size: 0.77rem;
  font-weight: 600;
  color: #475569;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-block;
  white-space: nowrap;
}

.pro-quota-text {
  font-size: 0.8rem;
  color: #475569;
  font-weight: 500;
  white-space: nowrap;
}

.pro-count-pill {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.pro-count-pill.has-teams {
  background-color: #DCFCE7;
  color: #15803D;
  border: 1px solid #BBF7D0;
}

.pro-count-pill.zero-teams {
  background-color: #F1F5F9;
  color: #64748B;
  border: 1px solid #E2E8F0;
}

.pro-rank-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  background: #F1F5F9;
  color: #334155;
}
.pro-rank-num.rank-1 {
  background: #FEF08A;
  color: #854D0E;
  border: 1px solid #FDE047;
}
.pro-rank-num.rank-2 {
  background: #E2E8F0;
  color: #1E293B;
  border: 1px solid #CBD5E1;
}
.pro-rank-num.rank-3 {
  background: #FFEDD5;
  color: #9A3412;
  border: 1px solid #FED7AA;
}

.pro-score-num {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--kc-navy);
}

.btn-kc-primary {
  background-color: var(--kc-navy);
  color: #FFFFFF;
  border: none;
  font-weight: 600;
  font-size: 0.84rem;
}
.btn-kc-primary:hover {
  background-color: var(--kc-navy-dark);
  color: #FFFFFF;
}

.btn-kc-gold {
  background-color: var(--kc-gold);
  color: var(--kc-navy-dark);
  border: none;
  font-weight: 700;
  font-size: 0.84rem;
}
.btn-kc-gold:hover {
  background-color: #b1881e;
  color: var(--kc-navy-dark);
}

.btn-table-action {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.badge-gold {
  background-color: var(--kc-gold);
  color: var(--kc-navy-dark);
  font-weight: 600;
  font-size: 0.76rem;
}

.medal-gold { background-color: #FEF9C3; color: #854D0E; border: 1px solid #FDE047; font-weight: 600; font-size: 0.77rem; }
.medal-silver { background-color: #F1F5F9; color: #334155; border: 1px solid #CBD5E1; font-weight: 600; font-size: 0.77rem; }
.medal-bronze { background-color: #FFEDD5; color: #9A3412; border: 1px solid #FED7AA; font-weight: 600; font-size: 0.77rem; }

.pr-banner-hero {
  background: linear-gradient(135deg, var(--kc-navy-dark) 0%, var(--kc-navy-light) 100%);
  color: #FFFFFF;
  border-radius: 14px;
  padding: 26px 28px;
  border-bottom: 4px solid var(--kc-gold);
}

@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    left: -290px;
    transition: left 0.25s ease;
  }
  .app-sidebar.mobile-open {
    left: 0;
  }
}

/* TH Sarabun PSK Font Support for Certificates & UI */
@font-face {
  font-family: 'TH Sarabun PSK';
  src: local('TH Sarabun PSK'), local('THSarabunPSK'), local('TH Sarabun New'), local('Sarabun');
}

.font-thsarabun {
  font-family: 'TH Sarabun PSK', 'TH Sarabun New', 'Sarabun', sans-serif !important;
}

/* Admin Accordion Styling */
.admin-accordion .accordion-item {
  border: 1px solid var(--kc-border);
  border-radius: 12px !important;
  overflow: hidden;
  margin-bottom: 10px;
  box-shadow: 0 2px 6px rgba(15, 44, 89, 0.03);
}

.admin-accordion .accordion-button {
  background-color: #FFFFFF;
  color: var(--kc-navy);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 14px 18px;
}

.admin-accordion .accordion-button:not(.collapsed) {
  background: linear-gradient(90deg, var(--kc-navy) 0%, var(--kc-navy-light) 100%);
  color: #FFFFFF;
  box-shadow: none;
}

.admin-accordion .accordion-button:not(.collapsed)::after {
  filter: brightness(0) invert(1);
}

/* Visual Certificate Drag-and-Drop Stage */
.cert-designer-stage-wrapper {
  background: #1E293B;
  padding: 18px;
  border-radius: 14px;
  overflow: auto;
  text-align: center;
}

.cert-designer-stage {
  position: relative;
  width: 842px;
  height: 595px;
  margin: 0 auto;
  background-color: #FFFFFF;
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  border: 2px solid var(--kc-gold);
  user-select: none;
  overflow: hidden;
}

.cert-draggable-item {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: move;
  padding: 4px 12px;
  border: 1.5px dashed rgba(15, 44, 89, 0.65);
  background: rgba(255, 255, 255, 0.78);
  border-radius: 6px;
  white-space: nowrap;
  font-family: 'TH Sarabun PSK', 'TH Sarabun Metric Fallback', sans-serif;
  line-height: 1.1;
  transition: box-shadow 0.1s ease, border-color 0.1s ease;
}

.cert-draggable-item:hover,
.cert-draggable-item.active-drag {
  border: 2px solid #D97706;
  background: rgba(254, 243, 199, 0.92);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 20;
}

/* Button Loading Animation */
.btn-is-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.88;
}

/* Professional Toast & Confirmation Dialogs */
.kc-toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 390px;
  width: calc(100% - 40px);
}

.kc-toast-card {
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 44, 89, 0.18);
  padding: 13px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-left: 5px solid var(--kc-navy);
  animation: kcToastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.kc-toast-card.toast-success { border-left-color: #16A34A; }
.kc-toast-card.toast-error   { border-left-color: #DC2626; }
.kc-toast-card.toast-warning { border-left-color: #D97706; }

@keyframes kcToastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Top Role-Priority Menu Highlight in Sidebar */
.sidebar-role-priority-box {
  background: rgba(197, 155, 39, 0.14);
  border-bottom: 1px solid rgba(197, 155, 39, 0.35);
  padding-bottom: 6px;
}

/* PR Banner Card Hover */
.pr-card-interactive {
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.pr-card-interactive:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(15, 44, 89, 0.12);
}
.pr-card-img-wrap {
  position: relative;
  overflow: hidden;
  background: #0F2C59;
}
.pr-card-img-wrap img {
  width: 100%;
  height: 210px;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.pr-card-interactive:hover .pr-card-img-wrap img {
  transform: scale(1.03);
}

/* Schedule Table Refined Typography */
.sched-cat-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  background-color: #F0F9FF;
  color: #0369A1;
  border: 1px solid #BAE6FD;
  display: inline-block;
}
.sched-event-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--kc-navy);
  line-height: 1.35;
}
.sched-level-sub {
  font-size: 0.77rem;
  color: var(--kc-muted);
  font-weight: 500;
}
.sched-venue-box {
  font-size: 0.84rem;
  font-weight: 500;
  color: #334155;
}
.sched-date-pill {
  font-size: 0.8rem;
  font-weight: 600;
  color: #0F2C59;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  padding: 3px 10px;
  border-radius: 6px;
  display: inline-block;
  white-space: nowrap;
}
.sched-time-pill {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  display: inline-block;
  white-space: nowrap;
}
.sched-time-start {
  background: #DCFCE7;
  color: #15803D;
  border: 1px solid #BBF7D0;
}
.sched-time-end {
  background: #FEE2E2;
  color: #B91C1C;
  border: 1px solid #FECACA;
}

/* ==================== v5 Per-Event Judge Committee Cards ==================== */
.event-group-card {
  background: #FFFFFF;
  border: 1px solid var(--kc-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(15, 44, 89, 0.04);
  margin-bottom: 14px;
}

.event-group-card-header {
  background: linear-gradient(90deg, #F8FAFC 0%, #F1F5F9 100%);
  border-bottom: 1px solid var(--kc-border);
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.event-group-title {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--kc-navy);
  margin: 0;
}

.judge-role-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  display: inline-block;
  white-space: nowrap;
}
.judge-role-chair {
  background-color: #FEF3C7;
  color: #92400E;
  border: 1px solid #FDE68A;
}
.judge-role-member {
  background-color: #EFF6FF;
  color: #1E40AF;
  border: 1px solid #BFDBFE;
}
.judge-role-secretary {
  background-color: #ECFDF5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}

/* ==================== v5 Per-Event Student Representative Cards (Rank 1 & Rank 2) ==================== */
.rep-slot-card {
  border-radius: 10px;
  padding: 14px 16px;
  height: 100%;
  border: 1px solid var(--kc-border);
  background: #FFFFFF;
  position: relative;
}

.rep-slot-card.rep-rank-1 {
  background: linear-gradient(180deg, #FFFBEB 0%, #FFFFFF 100%);
  border: 1px solid #FDE68A;
  border-left: 4px solid #D97706;
}

.rep-slot-card.rep-rank-2 {
  background: linear-gradient(180deg, #F8FAFC 0%, #FFFFFF 100%);
  border: 1px solid #CBD5E1;
  border-left: 4px solid #0284C7;
}

.rep-rank-badge-1 {
  background: #FEF08A;
  color: #854D0E;
  border: 1px solid #FDE047;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.rep-rank-badge-2 {
  background: #E0F2FE;
  color: #0369A1;
  border: 1px solid #BAE6FD;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.rep-person-list {
  font-size: 0.82rem;
  color: #334155;
  margin-bottom: 0;
  padding-left: 16px;
}
.rep-person-list li {
  margin-bottom: 2px;
}

/* ==================== v5 Venue Full-Aspect-Ratio Centered Image Display ==================== */
.venue-full-image-card {
  background: #FFFFFF;
  border: 1px solid var(--kc-border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 3px 12px rgba(15, 44, 89, 0.05);
  text-align: center;
}

.venue-full-image-card img {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 1080px;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  cursor: zoom-in;
  image-rendering: -webkit-optimize-contrast;
}


/* ==================== v5 Ultimate Enhancements: 7 KPIs, Admin Icon Grid, Resizable 3-Col Banners & Inline Edit ==================== */

/* 1. Home 7-KPI Stat Cards */
.kpi-stat-card {
  background: #FFFFFF;
  border: 1px solid var(--kc-border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 6px rgba(15, 44, 89, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  height: 100%;
}
.kpi-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(15, 44, 89, 0.08);
}
.kpi-stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--kc-muted);
  margin-bottom: 2px;
}
.kpi-stat-value {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.15;
}
.kpi-stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  border: 1px solid rgba(15, 44, 89, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* 2. Admin Management Center Icon Menu Grid */
.admin-icon-menu-card {
  background: #FFFFFF;
  border: 1px solid var(--kc-border);
  border-radius: 14px;
  padding: 22px 18px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(15, 44, 89, 0.04);
  position: relative;
}
.admin-icon-menu-card:hover {
  transform: translateY(-4px);
  border-color: var(--kc-gold);
  box-shadow: 0 12px 24px rgba(15, 44, 89, 0.12);
}
.admin-icon-circle {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.85rem;
  margin-bottom: 12px;
  transition: transform 0.18s ease;
}
.admin-icon-menu-card:hover .admin-icon-circle {
  transform: scale(1.08);
}
.admin-icon-title {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--kc-navy);
  margin-bottom: 4px;
}
.admin-icon-sub {
  font-size: 0.78rem;
  color: var(--kc-muted);
  margin-bottom: 0;
}

/* 3. Home PR Banner 3-Column Resizable Grid */
.pr-banner-col-item {
  transition: width 0.2s ease, flex 0.2s ease;
}
.pr-card-admin-toolbar {
  background: rgba(15, 44, 89, 0.92);
  color: #FFFFFF;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.74rem;
}
.pr-span-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}
.pr-span-btn.active {
  background: var(--kc-gold);
  color: var(--kc-navy-dark);
  border-color: var(--kc-gold);
}
.pr-resize-handle-right {
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 100%;
  cursor: ew-resize;
  background: linear-gradient(90deg, transparent, rgba(197, 155, 39, 0.35));
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 15;
}
.pr-card-interactive:hover .pr-resize-handle-right {
  opacity: 1;
}

/* 4. Inline Table Row Editing */
.inline-edit-row td {
  background-color: #FFFBEB !important;
  border-top: 1px solid #FDE68A !important;
  border-bottom: 1px solid #FDE68A !important;
}

/* 5. Toggle Switch Styling */
.form-switch .form-check-input {
  width: 2.6em;
  height: 1.35em;
  cursor: pointer;
}
.form-switch .form-check-input:checked {
  background-color: #16A34A;
  border-color: #16A34A;
}


/* ==================== v8 Enhancements: Initial Loading Overlay, ID Cards, A4 Portrait Dispatch Sheet & Full Certificate Studio ==================== */

/* 1. Initial App Loading Overlay */
.app-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 44, 89, 0.92);
  backdrop-filter: blur(4px);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.app-loading-overlay.loaded-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.app-loading-box {
  background: #FFFFFF;
  color: var(--kc-navy);
  padding: 28px 36px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  border-top: 5px solid var(--kc-gold);
  max-width: 360px;
  width: 90%;
}

/* 2. Student Photo Upload Thumbnail in Registration Form */
.stu-photo-upload-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stu-photo-thumb {
  width: 40px;
  height: 50px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--kc-border);
  background: #F8FAFC;
  flex-shrink: 0;
}

/* 3. Draggable Certificate Image Item (Logos & Signatures) */
.cert-draggable-img {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: move;
  border: 1.5px dashed rgba(15, 44, 89, 0.55);
  border-radius: 6px;
  padding: 2px;
  background: rgba(255, 255, 255, 0.35);
  user-select: none;
  transition: box-shadow 0.1s ease, border-color 0.1s ease;
}
.cert-draggable-img:hover,
.cert-draggable-img.active-drag {
  border: 2px solid #D97706;
  background: rgba(254, 243, 199, 0.65);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 25;
}
.cert-draggable-img img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

/* 4. Professional Competitor & Coach ID Cards (บัตรประจำตัวนักเรียนและครู) */
.idcard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
}

.kc-idcard {
  background: #FFFFFF;
  border: 2px solid var(--kc-navy);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(15, 44, 89, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.kc-idcard-header {
  background: linear-gradient(135deg, var(--kc-navy-dark) 0%, var(--kc-navy) 100%);
  color: #FFFFFF;
  padding: 12px 14px;
  border-bottom: 3px solid var(--kc-gold);
  display: flex;
  align-items: center;
  gap: 10px;
}

.kc-idcard-header.coach-header {
  background: linear-gradient(135deg, #064E3B 0%, #047857 100%);
}

.kc-idcard-logo {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #FFFFFF;
  padding: 3px;
  object-fit: contain;
  border: 1.5px solid var(--kc-gold);
  flex-shrink: 0;
}

.kc-idcard-body {
  padding: 14px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.kc-idcard-photo-box {
  width: 86px;
  height: 110px;
  border-radius: 8px;
  border: 2px solid var(--kc-gold);
  background: #F8FAFC;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.kc-idcard-photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kc-idcard-role-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 4px;
}
.kc-idcard-role-pill.role-stu {
  background: #FEF08A;
  color: #854D0E;
  border: 1px solid #FDE047;
}
.kc-idcard-role-pill.role-coach {
  background: #D1FAE5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}

.kc-idcard-footer {
  background: #F8FAFC;
  border-top: 1px dashed #CBD5E1;
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #475569;
}

/* 5. A4 Portrait Dispatch Sheet Preview (ใบส่งตัว A4 แนวตั้ง) */
.a4-portrait-preview-wrapper {
  background: #334155;
  padding: 24px 16px;
  border-radius: 14px;
  overflow-x: auto;
}

.a4-portrait-sheet {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  background: #FFFFFF;
  color: #000000;
  padding: 18mm 16mm;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  font-family: 'Sarabun', 'TH Sarabun PSK', sans-serif;
  font-size: 11pt;
  line-height: 1.45;
  box-sizing: border-box;
}

.a4-dispatch-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  margin-bottom: 18px;
}
.a4-dispatch-table th,
.a4-dispatch-table td {
  border: 1px solid #1E293B;
  padding: 7px 9px;
  vertical-align: top;
  font-size: 10.5pt;
}
.a4-dispatch-table th {
  background-color: #F1F5F9;
  font-weight: 700;
  text-align: center;
}

/* ==================== 1-LINE FULL-WIDTH FIXED FOOTER OVER SIDEBAR (v15) ==================== */
.app-main-wrapper {
  padding-bottom: 44px !important;
}
.app-sidebar {
  padding-bottom: 44px !important;
}
.app-footer-fixed {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1045; /* แสดงด้านหน้าทับ Sidebar (1030) แต่ไม่ทับ Modal (1055) */
  background: rgba(248, 250, 252, 0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid #CBD5E1;
  box-shadow: 0 -2px 10px rgba(15, 44, 89, 0.06);
  padding: 6px 16px;
  text-align: center;
}
.app-footer-fixed .footer-single-line {
  color: #475569;
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 991px) {
  .app-footer-fixed .footer-single-line {
    white-space: normal;
    font-size: 0.70rem;
  }
}
@media print {
  .app-footer-fixed {
    display: none !important;
  }
}

/* ปลดล็อกความสูงกรอบภาพข่าวประชาสัมพันธ์ให้ยืดตามค่าที่ตั้ง และแสดงเต็มรูปบนมือถือ */
.pr-card-img-wrap {
  height: auto;
  max-height: none !important;
  overflow: hidden;
  background-color: #f8fafc;
}

@media (max-width: 991.98px) {
  .pr-card-img-wrap {
    height: auto !important;
  }
  .pr-card-img-wrap img {
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    object-fit: contain !important;
  }
}

/* ป้ายบอกรุ่นของระบบแบบกลมกลืน ไม่เกะกะสายตาผู้ใช้งาน */
.sidebar-version-tag {
  margin-top: auto;
  padding: 10px 16px 12px;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.36);
  text-align: right;
  letter-spacing: 0.03em;
  user-select: none;
}

.cert-draggable-img img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: high-quality;
}

/* ==================== PROFESSIONAL ACTION BUTTON ALIGNMENT (v19.6.4) ==================== */
.table-action-group {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 6px !important;
  flex-wrap: nowrap !important;
  white-space: nowrap !important;
}

.table-kc td.text-end,
.table-kc th.text-end {
  white-space: nowrap !important;
}

.btn-table-action {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
  padding: 5px 12px !important;
  font-size: 0.80rem !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
  border-radius: 8px !important;
  white-space: nowrap !important;
  min-height: 31px !important;
  transition: all 0.16s ease !important;
  box-shadow: 0 1px 2px rgba(15, 44, 89, 0.06);
}

.btn-table-action i {
  font-size: 0.86rem;
  line-height: 1;
  margin: 0 !important;
}

.btn-table-action:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(15, 44, 89, 0.14);
}

/* ==================== SCHEDULE & JUDGE EDIT + REORDER (v19.7) ==================== */
.crud-row-editing {
  background-color: #FEF9C3 !important;
  outline: 2px solid #EAB308;
}

.crud-draggable-row {
  cursor: grab;
  transition: background-color 0.15s ease;
}

.crud-draggable-row:active {
  cursor: grabbing;
}

.crud-draggable-row.drag-over-target {
  border-top: 2px solid #2563EB !important;
  background-color: #EFF6FF !important;
}

.btn-row-move {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 28px !important;
  height: 29px !important;
  padding: 0 !important;
  border-radius: 6px !important;
  font-size: 0.82rem !important;
}

.drag-grip-icon {
  color: #94A3B8;
  cursor: grab;
  margin-right: 4px;
}

/* ==================== DIGITAL SIGNATURE PAD & CHECK-IN SYSTEM (v20 SQL) ==================== */
.sig-pad-wrapper {
  position: relative;
  width: 100%;
  height: 260px;
  background: #FFFFFF;
  border: 2px solid #0F2C59;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(15, 44, 89, 0.06);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#digitalSignatureCanvas {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.sig-pad-baseline {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 62px;
  border-bottom: 1.5px dashed #CBD5E1;
  pointer-events: none;
  z-index: 1;
}

.sig-pad-watermark {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 24px;
  text-align: center;
  font-size: 0.82rem;
  color: #94A3B8;
  pointer-events: none;
  z-index: 1;
}

.checkin-person-slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 6px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  background: #FFFFFF;
}

.checkin-person-slot:last-child {
  margin-bottom: 0;
}

.checkin-person-slot.is-signed {
  background: #F0FDF4;
  border-color: #BBF7D0;
}

.checkin-sig-thumb-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  border: 1px dashed #94A3B8;
  border-radius: 6px;
  padding: 2px 6px;
  height: 36px;
  min-width: 88px;
}

.checkin-sig-thumb-box img {
  max-height: 30px;
  max-width: 110px;
  object-fit: contain;
}


/* ==================== SIDEBAR VISITOR STATISTICS WIDGET (v24.4 SQL) ==================== */
.sidebar-visitor-stats-wrap {
  margin-top: auto;
  padding: 6px 10px 12px;
  cursor: pointer;
  user-select: none;
}

.sidebar-visitor-card {
  background: linear-gradient(180deg, rgba(6, 17, 36, 0.78) 0%, rgba(9, 28, 58, 0.92) 100%);
  border: 1px solid rgba(197, 155, 39, 0.42);
  border-radius: 10px;
  padding: 9px 11px 7px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  transition: all 0.18s ease;
}

.sidebar-visitor-card:hover {
  border-color: var(--kc-gold);
  background: linear-gradient(180deg, rgba(9, 24, 48, 0.9) 0%, rgba(15, 44, 89, 0.96) 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.32);
}

.sidebar-visitor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
}

.sidebar-visitor-title {
  font-size: 0.77rem;
  font-weight: 700;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.01em;
}

.sidebar-visitor-online-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: #6EE7B7;
  font-size: 0.68rem;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.sidebar-visitor-online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10B981;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: kcPulseOnline 1.8s infinite;
}

@keyframes kcPulseOnline {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.75); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.sidebar-visitor-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-visitor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.82);
  padding: 1.5px 2px;
}

.sidebar-visitor-row-total {
  margin-top: 2px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-visitor-label {
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.73rem;
}

.sidebar-visitor-val {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
}

.sidebar-visitor-val small {
  font-size: 0.66rem;
  opacity: 0.75;
}

.sidebar-visitor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-visitor-more {
  font-size: 0.67rem;
  color: rgba(253, 224, 71, 0.85);
  transition: color 0.15s ease;
}

.sidebar-visitor-card:hover .sidebar-visitor-more {
  color: #FDE047;
  text-decoration: underline;
}

.sidebar-visitor-footer .sidebar-version-tag {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0.64rem;
  color: rgba(255, 255, 255, 0.42);
}

/* 7-Days Bar Chart in Visitor Modal */
.visitor-7days-chart-box {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  align-items: end;
  height: 165px;
  padding: 18px 8px 6px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
}

.visitor-chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.visitor-chart-val {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--kc-navy);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.visitor-chart-bar-wrap {
  width: 100%;
  max-width: 38px;
  height: 102px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(226, 232, 240, 0.55);
  border-radius: 6px 6px 2px 2px;
  overflow: hidden;
}

.visitor-chart-bar {
  width: 100%;
  background: linear-gradient(180deg, #1E40AF 0%, #0F2C59 100%);
  border-radius: 6px 6px 0 0;
  min-height: 6px;
  transition: height 0.35s ease;
}

.visitor-chart-bar.is-today {
  background: linear-gradient(180deg, #F59E0B 0%, #C59B27 100%);
}

.visitor-chart-label {
  font-size: 0.69rem;
  color: #475569;
  margin-top: 6px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
