/* ==========================================================
   KOKSI GAMES 2026 - Youthful & Vibrant School Sports Theme
   Inspired by Koksi Pitthayasan School (Purple-Gold) + Pop Sports Festival
   ========================================================== */

:root {
  --bg: #fbf8ff;
  --surface: #ffffff;
  --surface-2: #faf7ff;
  --border: #ede5ff;
  --border-strong: #d8c8ff;
  --text: #1e1633;
  --text-muted: #645980;
  --text-light: #988eb3;

  /* Youthful Vibrant Palette (Purple + Pink + Sunny Gold + Mint + Sky) */
  --navy: #3b1775;
  --navy-2: #4c1d95;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-soft: #f3ecff;
  --indigo: #ec4899;
  --pink: #ec4899;
  --pink-soft: #fdf2f8;
  --gold: #facc15;
  --gold-2: #f59e0b;
  --gold-dark: #a16207;
  --gold-soft: #fefce8;
  --emerald: #10b981;
  --emerald-soft: #ecfdf5;
  --rose: #f43f5e;
  --rose-soft: #fff1f2;
  --sky: #06b6d4;
  --sky-soft: #ecfeff;

  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 26px;
  --radius-full: 9999px;

  --shadow-xs: 0 2px 6px rgba(109, 40, 217, 0.06);
  --shadow-sm: 0 6px 18px rgba(109, 40, 217, 0.08);
  --shadow-md: 0 12px 30px rgba(109, 40, 217, 0.13);
  --shadow-lg: 0 20px 46px rgba(109, 40, 217, 0.18);

  --topbar-h: 66px;
  --bottomnav-h: 68px;
  --sidebar-w: 268px;

  --font-display: 'Kanit', 'Prompt', 'Leelawadee UI', system-ui, sans-serif;
  --font-body: 'Prompt', 'Sarabun', 'Tahoma', system-ui, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 8% -4%, rgba(168, 85, 247, 0.16) 0%, rgba(168, 85, 247, 0) 36%),
    radial-gradient(circle at 92% 4%, rgba(236, 72, 153, 0.14) 0%, rgba(236, 72, 153, 0) 34%),
    radial-gradient(circle at 50% 22%, rgba(250, 204, 21, 0.11) 0%, rgba(250, 204, 21, 0) 40%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px) + 18px);
}

h1, h2, h3, h4, h5, .font-display {
  font-family: var(--font-display);
  margin: 0;
  line-height: 1.26;
  letter-spacing: -0.005em;
}

a {
  color: var(--primary);
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

/* ---------- Vibrant Festival Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: linear-gradient(135deg, #6d28d9 0%, #9333ea 52%, #ec4899 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 3px solid rgba(250, 204, 21, 0.72);
  box-shadow: 0 6px 22px rgba(109, 40, 217, 0.24);
  color: #fff;
  display: flex;
  align-items: center;
}

.topbar-inner {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.04rem;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #ffffff;
  padding: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(59, 7, 100, 0.28), 0 0 0 2px rgba(254, 240, 138, 0.8);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.brand:hover .brand-mark {
  transform: scale(1.06) rotate(-3deg);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(59, 7, 100, 0.25);
}

.brand-sub {
  font-size: 0.72rem;
  font-weight: 400;
  color: #fef08a;
  white-space: nowrap;
}

.desktop-nav {
  display: none;
  align-items: center;
  gap: 6px;
}

.desktop-nav a {
  color: rgba(255, 255, 255, 0.9);
  padding: 8px 15px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.18s ease;
}

.desktop-nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.desktop-nav a.active {
  color: #4c1d95;
  background: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(59, 7, 100, 0.2);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 13px 5px 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 0.84rem;
  font-family: var(--font-display);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #facc15, #f97316);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  color: #3b0764;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.user-pill-name {
  display: none;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

/* Backend Sidebar Shell */
.app-shell {
  display: block;
}

.sidebar {
  display: none;
}

.main-content {
  min-width: 0;
  flex: 1;
}

/* ---------- Mobile Bottom Navigation (Fresh Pop Glass Dock) ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 2px solid #f3e8ff;
  box-shadow: 0 -8px 26px rgba(109, 40, 217, 0.1);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
}

.bottom-nav a,
.bottom-nav button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: var(--font-display);
  font-size: 0.71rem;
  font-weight: 500;
  padding: 6px 4px;
  cursor: pointer;
  position: relative;
  transition: all 0.18s ease;
}

.bottom-nav a.active,
.bottom-nav button.active {
  color: var(--primary);
  font-weight: 600;
}

.bottom-nav a.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 4px;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(90deg, #7c3aed, #ec4899, #f59e0b);
}

/* ---------- Mobile Drawer (Vibrant Purple Gradient) ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(59, 7, 100, 0.45);
  backdrop-filter: blur(4px);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(315px, 86vw);
  background: linear-gradient(170deg, #581c87 0%, #6d28d9 55%, #9333ea 100%);
  color: #fff;
  z-index: 90;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 18px 16px 28px;
}

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

.drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.88);
  font-family: var(--font-display);
  font-size: 0.93rem;
  font-weight: 500;
  margin-bottom: 4px;
  transition: all 0.16s ease;
}

.drawer-link:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  transform: translateX(3px);
}

.drawer-link.active {
  background: linear-gradient(135deg, #facc15 0%, #fb923c 100%);
  color: #3b0764;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(59, 7, 100, 0.25);
}

.drawer-section {
  font-size: 0.72rem;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #e9d5ff;
  margin: 16px 12px 6px;
  opacity: 0.85;
}

/* ---------- Event Banner Showcase Hero ---------- */
.hero-banner-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #ffffff;
  border: 2.5px solid rgba(168, 85, 247, 0.28);
  box-shadow: 0 18px 42px rgba(109, 40, 217, 0.18), 0 0 0 4px rgba(250, 204, 21, 0.18);
  margin-bottom: 22px;
}

.hero-banner-media {
  position: relative;
  width: 100%;
  background: linear-gradient(135deg, #6d28d9, #facc15);
  overflow: hidden;
}

.hero-banner-media img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

.hero-banner-bar {
  padding: 16px 20px;
  background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 55%, #9333ea 100%);
  border-top: 3px solid #facc15;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hero-banner-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-size: 0.9rem;
  color: #fef9c3;
  font-family: var(--font-display);
}

.hero-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

@media (min-width: 768px) {
  .hero-banner-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
  }
}

/* ---------- Hero Banner (Energetic Youth Sports Festival!) ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 35%, #d946ef 74%, #f97316 100%);
  color: #fff;
  padding: 28px 22px;
  margin-bottom: 22px;
  box-shadow: 0 16px 38px rgba(124, 58, 237, 0.28);
  border: 2px solid rgba(255, 255, 255, 0.28);
}

.hero::before {
  content: '';
  position: absolute;
  top: -70px;
  right: -50px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(254, 240, 138, 0.52) 0%, rgba(254, 240, 138, 0) 68%);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -95px;
  left: -30px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.36) 0%, rgba(56, 189, 248, 0) 70%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 2;
}

.hero-brand-row {
  display: flex;
  align-items: center;
  gap: 18px;
}

.hero-logo-box {
  width: 82px;
  height: 82px;
  border-radius: 24px;
  background: #ffffff;
  padding: 7px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px rgba(59, 7, 100, 0.3), 0 0 0 4px rgba(254, 240, 138, 0.65);
  animation: floatBadge 4s ease-in-out infinite;
}

@keyframes floatBadge {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-4px); }
}

.hero-logo-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (max-width: 520px) {
  .hero-brand-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .hero-logo-box {
    width: 68px;
    height: 68px;
    border-radius: 18px;
  }
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  border: 1.5px solid rgba(254, 240, 138, 0.65);
  color: #fef9c3;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.hero h1 {
  font-size: clamp(1.65rem, 5.2vw, 2.65rem);
  font-weight: 800;
  margin-bottom: 8px;
  text-shadow: 0 3px 14px rgba(59, 7, 100, 0.28);
}

.hero p {
  margin: 0 0 20px;
  color: rgba(255, 255, 255, 0.94);
  font-size: 0.98rem;
  max-width: 660px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- Cards & Colorful KPI Stats ---------- */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: visible;
}

.card-pad {
  padding: 18px;
}

.card-header {
  padding: 16px 18px;
  background: linear-gradient(180deg, #ffffff 0%, #fcfaff 100%);
  border-bottom: 1.5px solid var(--border);
  border-radius: calc(var(--radius) - 1.5px) calc(var(--radius) - 1.5px) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--navy);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-auto {
  grid-template-columns: 1fr;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 17px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #7c3aed, #ec4899);
}

.stats-grid .stat-card:nth-child(1) {
  background: linear-gradient(160deg, #ffffff 45%, #f5f0ff 100%);
}
.stats-grid .stat-card:nth-child(1)::before {
  background: linear-gradient(90deg, #7c3aed, #a855f7);
}

.stats-grid .stat-card:nth-child(2) {
  background: linear-gradient(160deg, #ffffff 45%, #ecfdf5 100%);
  border-color: #c7f7e4;
}
.stats-grid .stat-card:nth-child(2)::before {
  background: linear-gradient(90deg, #10b981, #14b8a6);
}

.stats-grid .stat-card:nth-child(3) {
  background: linear-gradient(160deg, #ffffff 45%, #ecfeff 100%);
  border-color: #c5f3fa;
}
.stats-grid .stat-card:nth-child(3)::before {
  background: linear-gradient(90deg, #06b6d4, #3b82f6);
}

.stats-grid .stat-card:nth-child(4) {
  background: linear-gradient(160deg, #ffffff 45%, #fefce8 100%);
  border-color: #fde68a;
}
.stats-grid .stat-card:nth-child(4)::before {
  background: linear-gradient(90deg, #f59e0b, #ec4899);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.08;
  color: var(--navy);
}

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

/* ---------- Page Header ---------- */
.page-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.page-title {
  font-size: clamp(1.38rem, 4.2vw, 1.85rem);
  font-weight: 800;
  background: linear-gradient(135deg, #5b21b6 0%, #9333ea 58%, #db2777 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.page-title svg {
  color: #7c3aed;
  flex-shrink: 0;
}

.page-sub {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-top: 3px;
}

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

/* ---------- Playful Tactile Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 18px;
  border-radius: 14px;
  border: 1.5px solid transparent;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0px) scale(0.98);
}

.btn-sm {
  min-height: 36px;
  padding: 6px 13px;
  font-size: 0.82rem;
  border-radius: 11px;
}

.btn-lg {
  min-height: 50px;
  padding: 12px 24px;
  font-size: 0.98rem;
  border-radius: 16px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 55%, #ec4899 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.32);
}

.btn-primary:hover {
  box-shadow: 0 10px 24px rgba(124, 58, 237, 0.4);
  filter: brightness(1.04);
}

.btn-gold {
  background: linear-gradient(135deg, #fde047 0%, #facc15 48%, #fb923c 100%);
  color: #3b0764;
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.36);
}

.btn-gold:hover {
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.46);
  filter: brightness(1.03);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.3);
}

.btn-danger {
  background: var(--rose-soft);
  color: #be123c;
  border-color: #fecdd3;
}

.btn-danger:hover {
  background: #ffe4e6;
}

.btn-outline {
  background: #fff;
  color: var(--navy);
  border-color: var(--border-strong);
}

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

.btn-ghost {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.38);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.32);
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #ddd6fe;
}

.btn-soft:hover {
  background: #e9d5ff;
}

/* ---------- Vibrant Badges & Medals ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-info {
  background: #e0f2fe;
  color: #0284c7;
  border: 1px solid #7dd3fc;
}

.badge-success {
  background: #d1fae5;
  color: #047857;
  border: 1px solid #6ee7b7;
}

.badge-live {
  background: #ffe4e6;
  color: #e11d48;
  border: 1px solid #fda4af;
}

.badge-live::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f43f5e;
  animation: pulseDot 1.3s infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.55); opacity: 0.45; }
}

.badge-neutral {
  background: #f5f0ff;
  color: #5b21b6;
  border: 1px solid #e9d5ff;
}

.badge-gold {
  background: linear-gradient(135deg, #fef9c3, #fde68a);
  color: #854d0e;
  border: 1px solid #facc15;
}

.medal-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.79rem;
  font-weight: 600;
}

.medal-gold { background: linear-gradient(135deg, #fef9c3, #fde047); color: #713f12; border: 1px solid #eab308; }
.medal-silver { background: linear-gradient(135deg, #f8fafc, #e2e8f0); color: #334155; border: 1px solid #cbd5e1; }
.medal-bronze { background: linear-gradient(135deg, #ffedd5, #fed7aa); color: #9a3412; border: 1px solid #fb923c; }
.medal-participant { background: linear-gradient(135deg, #f3e8ff, #e0f2fe); color: #5b21b6; border: 1px solid #c4b5fd; }

.team-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  border: 2.5px solid #ffffff;
  box-shadow: 0 0 0 1.5px rgba(91, 33, 182, 0.2);
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--navy-2);
  margin-bottom: 6px;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.textarea {
  min-height: 92px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.16);
}

/* ---------- Custom Visual Color-Swatch Select ---------- */
.cselect {
  position: relative;
  width: 100%;
}

.cselect-native {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.cselect-trigger {
  width: 100%;
  min-height: 44px;
  padding: 9px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 14px;
  background: #ffffff;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.cselect-trigger:hover {
  border-color: #a855f7;
}

.cselect.open .cselect-trigger,
.cselect-trigger:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.16);
}

.cselect-val {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.cselect-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.cselect-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1.5px rgba(30, 22, 51, 0.22), 0 2px 6px rgba(0, 0, 0, 0.12);
}

.cselect-caret {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.18s ease;
}

.cselect.open .cselect-caret {
  transform: rotate(180deg);
  color: var(--primary);
}

.cselect-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 95;
  background: #ffffff;
  border: 1.5px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 16px 36px rgba(91, 33, 182, 0.18);
  padding: 6px;
  max-height: 270px;
  overflow-y: auto;
  display: none;
  animation: fadeSlide 0.15s ease;
}

.cselect.open .cselect-menu {
  display: block;
}

.cselect-opt {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 0.94rem;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  position: relative;
  border-left: 4px solid transparent;
  transition: background 0.14s ease, transform 0.12s ease;
  margin-bottom: 3px;
}

.cselect-opt:last-child {
  margin-bottom: 0;
}

.cselect-opt:hover {
  background: #f5f0ff;
}

.cselect-opt.has-color {
  border-left-color: var(--opt-color);
  background: linear-gradient(90deg, color-mix(in srgb, var(--opt-color) 16%, #ffffff) 0%, #ffffff 78%);
}

.cselect-opt.has-color:hover {
  background: linear-gradient(90deg, color-mix(in srgb, var(--opt-color) 28%, #ffffff) 0%, #faf7ff 90%);
}

.cselect-opt.selected {
  font-weight: 700;
  box-shadow: inset 0 0 0 1.5px rgba(124, 58, 237, 0.35);
}

.cselect-opt-check {
  margin-left: auto;
  color: var(--primary);
  font-weight: 800;
  font-size: 0.9rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.check-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  background: var(--surface-2);
  transition: all 0.15s ease;
}

.check-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.check-card input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* ---------- Tables (Clean & Cheerful) ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.table th {
  text-align: left;
  padding: 12px 14px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: #6d28d9;
  background: #faf5ff;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 13px 14px;
  border-bottom: 1px solid #f3ecff;
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: #fcfaff;
}

.text-center { text-align: center; }
.text-right { text-align: right; }

/* ---------- Filter Chips ---------- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: #fff;
  border: 1.5px solid var(--border-strong);
  color: var(--navy);
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 600;
  transition: all 0.16s ease;
  box-shadow: var(--shadow-xs);
}

.chip.active,
.chip:hover {
  background: linear-gradient(135deg, #7c3aed 0%, #ec4899 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 14px rgba(124, 58, 237, 0.28);
}

/* ---------- Sport Card (Pop Youthful Cards) ---------- */
.sport-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

.sport-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #7c3aed, #ec4899, #facc15);
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.sport-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: #c4b5fd;
}

.sport-card:hover::after {
  opacity: 1;
}

.sport-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

/* ---------- Alerts & Flash ---------- */
.alert {
  padding: 13px 16px;
  border-radius: 16px;
  margin-bottom: 16px;
  font-size: 0.92rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1.5px solid transparent;
}

.alert-success { background: #ecfdf5; color: #065f46; border-color: #6ee7b7; }
.alert-error { background: #fff1f2; color: #9f1239; border-color: #fda4af; }
.alert-warning { background: #fefce8; color: #854d0e; border-color: #fde047; }
.alert-info { background: #f3ecff; color: #5b21b6; border-color: #c4b5fd; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(59, 7, 100, 0.48);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 26px 26px 0 0;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideUp {
  from { transform: translateY(28px); opacity: 0.7; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-head {
  padding: 16px 20px;
  border-bottom: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
}

.modal-body {
  padding: 20px;
}

/* ---------- Certificate Preview & Editor ---------- */
.cert-canvas-stage {
  background: linear-gradient(135deg, #f3e8ff 0%, #fce7f3 50%, #fef9c3 100%);
  border-radius: 20px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 2px solid var(--border-strong);
}

.cert-canvas-stage canvas {
  width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 14px 36px rgba(91, 33, 182, 0.2);
  background: #fff;
  touch-action: none;
}

.editor-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.editor-canvas-col {
  z-index: 5;
}

@media (min-width: 960px) {
  .editor-canvas-col {
    position: sticky;
    top: calc(var(--topbar-h) + 16px);
    align-self: start;
  }
  .editor-canvas-col .cert-canvas-stage canvas {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100vh - var(--topbar-h) - 88px);
  }
}

.field-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.field-pill {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-strong);
  background: #fff;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--navy-2);
}

.field-pill.active {
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  border-color: transparent;
  color: #fff;
}

.field-pill.disabled-field {
  opacity: 0.48;
  text-decoration: line-through;
}

/* ---------- Share Link Box ---------- */
.share-box {
  background: linear-gradient(135deg, #f5f0ff 0%, #fdf2f8 52%, #fefce8 100%);
  border: 2px solid #d8b4fe;
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.share-url-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.share-url-input {
  flex: 1;
  min-width: 190px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  padding: 9px 13px;
  border-radius: 12px;
  border: 1.5px solid #c084fc;
  background: #fff;
  color: var(--navy);
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  top: 76px;
  right: 16px;
  left: 16px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: linear-gradient(135deg, #5b21b6, #9333ea);
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  border: 1.5px solid rgba(254, 240, 138, 0.55);
  pointer-events: auto;
  animation: fadeSlide 0.22s ease;
  max-width: 440px;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 42px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--primary-soft);
  border: 1.5px solid var(--border-strong);
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

/* ---------- Utility ---------- */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.muted { color: var(--text-muted); }
.small { font-size: 0.84rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Tablet & Desktop Breakpoints ---------- */
@media (min-width: 640px) {
  .container { padding: 24px 20px 38px; }
  .hero { padding: 38px 34px; }
  .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-auto { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .checkbox-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { flex-direction: row; align-items: center; justify-content: space-between; }
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 24px; }
  .user-pill-name { display: inline; }
}

@media (min-width: 960px) {
  body {
    padding-bottom: 28px;
  }
  .bottom-nav {
    display: none;
  }
  .desktop-nav {
    display: flex;
  }
  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .grid-auto {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .editor-grid {
    grid-template-columns: 1.45fr 1fr;
    align-items: start;
  }
  .app-shell.with-sidebar {
    display: flex;
    max-width: 1380px;
    margin: 0 auto;
    padding: 22px 20px 38px;
    gap: 22px;
    align-items: flex-start;
  }
  .app-shell.with-sidebar .sidebar {
    display: block;
    width: var(--sidebar-w);
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--topbar-h) + 20px);
    background: linear-gradient(170deg, #581c87 0%, #6d28d9 58%, #9333ea 100%);
    color: #fff;
    border-radius: 24px;
    padding: 18px 14px;
    box-shadow: 0 14px 34px rgba(109, 40, 217, 0.24);
    border: 2px solid rgba(254, 240, 138, 0.35);
  }
  .app-shell.with-sidebar .container {
    padding: 0;
    max-width: none;
  }
}

/* ---------- Print Styles ---------- */
@media print {
  .topbar, .bottom-nav, .sidebar, .no-print, .toast-container, .modal-backdrop {
    display: none !important;
  }
  body {
    background: #fff !important;
    padding: 0 !important;
  }
  .container {
    max-width: 100% !important;
    padding: 0 !important;
  }
  .card {
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
}
