/* ============================================================
   BBL Portal — Design System (Light & Fresh)
   White/mint background + bright emerald accent + glass cards
   ============================================================ */

:root {
  /* Greens */
  --c-emerald-50:   #ecfdf5;
  --c-emerald-100:  #d1fae5;
  --c-emerald-200:  #a7f3d0;
  --c-emerald-300:  #6ee7b7;
  --c-emerald-400:  #34d399;
  --c-emerald-500:  #10b981;
  --c-emerald-600:  #059669;
  --c-emerald-700:  #047857;
  --c-emerald-800:  #065f46;
  --c-mint:         #6ee7b7;
  --c-spring:       #34d399;

  /* Neutrals (light theme) */
  --c-bg:           #f5fcf8;     /* page bg, very light mint-tinted white */
  --c-bg-2:         #ecfdf5;     /* mint cream */
  --c-bg-3:         #ffffff;     /* white cards */
  --c-ink:          #0f172a;     /* slate-900 - main text */
  --c-ink-soft:     #334155;     /* slate-700 - secondary */
  --c-ink-muted:    #64748b;     /* slate-500 - tertiary/labels */
  --c-line:         rgba(15,23,42,.08);   /* hair lines */

  --glass-bg:       rgba(255, 255, 255, 0.65);
  --glass-bg-2:     rgba(255, 255, 255, 0.45);
  --glass-bg-3:     rgba(255, 255, 255, 0.85);
  --glass-border:   rgba(16, 185, 129, 0.18);
  --glass-border-2: rgba(16, 185, 129, 0.32);

  --radius-sm: 10px;
  --radius:    18px;
  --radius-lg: 28px;
  --radius-xl: 36px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm: 0 2px 4px rgba(15, 23, 42, .04), 0 1px 2px rgba(15, 23, 42, .03);
  --shadow:    0 12px 32px -10px rgba(16, 185, 129, .18), 0 4px 12px -4px rgba(15, 23, 42, .08);
  --shadow-lg: 0 30px 60px -20px rgba(16, 185, 129, .22), 0 8px 24px -8px rgba(15, 23, 42, .08);
  --shadow-glow: 0 0 0 1px rgba(16,185,129,.22), 0 18px 40px -10px rgba(16,185,129,.28);

  --grad-hero:    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(110,231,183,.35) 0%, transparent 60%),
                  radial-gradient(circle at 20% 100%, rgba(167,243,208,.30) 0%, transparent 50%),
                  radial-gradient(circle at 100% 30%, rgba(94,234,212,.20) 0%, transparent 50%),
                  linear-gradient(180deg, #f5fcf8 0%, #ffffff 60%, #f0fdf4 100%);
  --grad-accent:  linear-gradient(135deg, #047857 0%, #10b981 60%, #34d399 100%);
  --grad-text:    linear-gradient(135deg, #064e3b 0%, #047857 55%, #059669 100%);  /* WCAG AAA on white */
  --grad-card:    linear-gradient(135deg, rgba(110,231,183,.06) 0%, rgba(110,231,183,0) 100%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-ink);
  font-family: 'Inter', 'IBM Plex Sans Thai', 'Sukhumvit Set', 'Noto Sans Thai', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  line-height: 1.5;
}

body {
  background: var(--grad-hero);
  background-attachment: fixed;
  position: relative;
}

/* Animated grid backdrop */
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(to right, rgba(16,185,129,.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(16,185,129,.06) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, #000 30%, transparent 80%);
  animation: grid-drift 40s linear infinite;
}
@keyframes grid-drift {
  0%   { background-position: 0 0,        0 0; }
  100% { background-position: 56px 56px,  56px 56px; }
}

/* Floating orbs (pastel on light) */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.bg-orbs .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  opacity: .55;
  animation: orb-float 22s ease-in-out infinite;
}
.bg-orbs .orb:nth-child(1) { top: -10%; left: -5%;  width: 460px; height: 460px; background: #6ee7b7; animation-delay: 0s; }
.bg-orbs .orb:nth-child(2) { top: 30%;  right: -10%; width: 380px; height: 380px; background: #a7f3d0; animation-delay: -7s; }
.bg-orbs .orb:nth-child(3) { bottom: -10%; left: 30%; width: 500px; height: 500px; background: #d1fae5; animation-delay: -14s; opacity: .45; }
@keyframes orb-float {
  0%,100% { transform: translate(0,0) scale(1); }
  33%     { transform: translate(40px,-40px) scale(1.08); }
  66%     { transform: translate(-30px,30px) scale(.95); }
}

/* Layout */
main, .main { position: relative; z-index: 2; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ---- Glass cards ---- */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.glass::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--grad-card);
  opacity: 1;
  pointer-events: none;
}
.glass > * { position: relative; z-index: 1; }

.glass-strong {
  background: var(--glass-bg-3);
  border: 1px solid var(--glass-border-2);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  box-shadow: var(--shadow-lg);
}

/* ---- Gradient text ---- */
.grad-text {
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .01em;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  position: relative;
  overflow: hidden;
  transition: transform .18s cubic-bezier(.2,.7,.3,1), box-shadow .25s, background .25s, color .25s, border-color .25s;
  white-space: nowrap;
}
.btn-primary {
  color: #fff;
  background: var(--grad-accent);
  box-shadow: 0 10px 24px -8px rgba(16,185,129,.55), inset 0 1px 0 rgba(255,255,255,.35);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px -8px rgba(16,185,129,.7), inset 0 1px 0 rgba(255,255,255,.4);
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.4) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform .8s ease;
  pointer-events: none;
}
.btn-primary:hover::after { transform: translateX(100%); }

.btn-ghost {
  color: var(--c-ink);
  background: rgba(255,255,255,.7);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
}
.btn-ghost:hover {
  background: rgba(255,255,255,.95);
  border-color: var(--glass-border-2);
  color: var(--c-emerald-700);
}

.btn-lg { padding: 18px 36px; font-size: 17px; }

/* ---- Form: pill input ---- */
.field {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, .75);
  border: 1.5px solid var(--glass-border);
  border-radius: 999px;
  padding: 6px 6px 6px 22px;
  transition: border-color .25s, box-shadow .25s, transform .25s, background .25s;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-xs);
}
.field:focus-within {
  border-color: var(--c-emerald-500);
  background: #fff;
  box-shadow: 0 0 0 6px rgba(16,185,129,.12), 0 12px 36px -10px rgba(16,185,129,.35);
  transform: translateY(-1px);
}
.field input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--c-ink);
  font-size: 17px;
  font-family: inherit;
  padding: 14px 8px;
  letter-spacing: .04em;
  min-width: 0;
}
.field input::placeholder { color: var(--c-ink-muted); }
.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field input[type=number] { -moz-appearance: textfield; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid transparent;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.badge-paid    { background: #d1fae5;          color: var(--c-emerald-700);  border-color: rgba(16,185,129,.35); }
.badge-paid    .dot { background: var(--c-emerald-500); box-shadow: 0 0 8px var(--c-emerald-400); }
.badge-unpaid  { background: #fee2e2;          color: #b91c1c;               border-color: rgba(239,68,68,.35); }
.badge-unpaid  .dot { background: #ef4444; box-shadow: 0 0 8px #fca5a5; animation: pulse-warn 1.4s infinite; }
.badge-pending { background: #fef3c7;          color: #92400e;               border-color: rgba(245,158,11,.35); }
.badge-pending .dot { background: #f59e0b; box-shadow: 0 0 8px #fcd34d; }
.badge-soft  { background: rgba(15,23,42,.05); color: var(--c-ink-soft); border-color: var(--c-line); }
@keyframes pulse-warn { 0%,100% { transform: scale(1); } 50% { transform: scale(1.4); } }

/* ---- Eyebrow ---- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .14em;
  background: #d1fae5;
  color: var(--c-emerald-700);
  border: 1px solid rgba(16,185,129,.25);
}
.eyebrow .pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--c-emerald-500);
  box-shadow: 0 0 0 0 rgba(16,185,129,.55);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.55); }
  70%  { box-shadow: 0 0 0 10px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

/* ---- Nav ---- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  background: rgba(255,255,255,.7);
  border-bottom: 1px solid var(--c-line);
}
.nav .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--c-ink);
  text-decoration: none;
  min-width: 0;
}
.nav .brand-mark {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff 0%, #ecfdf5 100%);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 6px 16px -6px rgba(16,185,129,.40), 0 0 0 1px rgba(16,185,129,.25), inset 0 1px 0 rgba(255,255,255,.95);
}
.nav .brand-mark img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }

.nav .brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.nav .brand-text > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.nav .brand-text small { font-size: 11px; color: var(--c-ink-muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.nav .spacer { flex: 1; }
.nav a.nav-link {
  color: var(--c-ink-soft);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  transition: color .2s, background .2s;
}
.nav a.nav-link:hover {
  color: var(--c-emerald-700);
  background: rgba(16,185,129,.08);
}
@media (max-width: 600px) {
  .nav .brand-text small { display: none; }
  .nav a.nav-link { padding: 6px 10px; font-size: 13px; }
}
@media (max-width: 420px) {
  .nav .brand-text { display: none; }
}

/* Logo block (hero/login) */
.logo-block {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff 0%, #ecfdf5 100%);
  display: grid; place-items: center;
  box-shadow: 0 12px 28px -8px rgba(16,185,129,.4), 0 0 0 1px rgba(16,185,129,.3), inset 0 1px 0 rgba(255,255,255,.95);
  overflow: hidden;
}
.logo-block img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }

/* ---- Hero ---- */
.hero {
  padding: 64px 20px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.hero h1 {
  font-size: clamp(36px, 6vw, 68px);
  font-weight: 800;
  line-height: 1.05;
  margin: 18px 0 16px;
  letter-spacing: -.02em;
  color: var(--c-ink);
}
.hero p.lead {
  max-width: 620px;
  font-size: clamp(15px, 1.6vw, 18px);
  color: var(--c-ink-soft);
  line-height: 1.65;
  margin: 0 0 32px;
}
.hero .search-card { width: min(640px, 100%); }
.hero .note {
  margin-top: 14px;
  color: var(--c-ink-muted);
  font-size: 13px;
}

/* ---- Countdown ---- */
.countdown {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255,255,255,.85);
  border: 1px solid var(--glass-border-2);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
}
.countdown .seg { display: flex; align-items: baseline; gap: 4px; }
.countdown .seg b {
  font-size: 18px;
  font-weight: 700;
  color: var(--c-emerald-700);
  min-width: 24px;
  text-align: center;
}
.countdown .seg span {
  font-size: 11px;
  color: var(--c-ink-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
}
.countdown .sep { color: rgba(15,23,42,.2); }

/* ---- Steps ---- */
.steps {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 28px;
}
.step {
  padding: 24px;
  border-radius: var(--radius);
  position: relative;
  transition: transform .3s, box-shadow .3s;
  background: var(--c-bg-3);
  border: 1px solid var(--glass-border);
}
.step:hover { transform: translateY(-4px); box-shadow: var(--shadow-glow); }
.step .num {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--grad-accent);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 6px 16px -6px rgba(16,185,129,.55);
  margin-bottom: 14px;
}
.step h3 { margin: 0 0 6px; font-size: 17px; color: var(--c-ink); font-weight: 700; }
.step p { margin: 0; color: var(--c-ink-soft); font-size: 14px; line-height: 1.6; }
.step .arrow {
  position: absolute;
  top: 50%; right: -16px;
  transform: translateY(-50%);
  color: var(--c-emerald-300);
  font-size: 22px;
  display: none;
  font-weight: 700;
}
@media (min-width: 900px) {
  .step .arrow { display: block; }
  .step:last-child .arrow { display: none; }
}

/* ---- Student card ---- */
.student-card {
  padding: 32px;
  border-radius: var(--radius-lg);
}
.student-header {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 28px;
}
.avatar {
  width: 88px; height: 88px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: var(--grad-accent);
  color: #fff;
  font-size: 36px;
  font-weight: 800;
  box-shadow: 0 12px 28px -8px rgba(16,185,129,.6), inset 0 1px 0 rgba(255,255,255,.4);
  flex-shrink: 0;
}
.student-name {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 800;
  margin: 0 0 6px;
  line-height: 1.2;
  color: var(--c-ink);
}
.student-meta { color: var(--c-ink-muted); font-size: 14px; }
.student-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.kv {
  padding: 18px;
  border-radius: var(--radius);
  background: rgba(236, 253, 245, .55);
  border: 1px solid var(--glass-border);
  transition: transform .25s, border-color .25s, background .25s;
}
.kv:hover {
  transform: translateY(-2px);
  border-color: var(--glass-border-2);
  background: rgba(209, 250, 229, .7);
}
.kv .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--c-ink-muted);
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
  font-weight: 600;
}
.kv .value { font-size: 18px; font-weight: 700; color: var(--c-ink); line-height: 1.3; }

.section-title {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 800;
  letter-spacing: -.01em;
  margin: 0 0 8px;
  color: var(--c-ink);
}
.section-subtitle {
  color: var(--c-ink-soft);
  font-size: 15px;
  margin: 0 0 24px;
}

/* ---- Footer ---- */
.footer {
  margin-top: 80px;
  padding: 30px 20px 40px;
  text-align: center;
  color: var(--c-ink-muted);
  font-size: 13px;
  border-top: 1px solid var(--c-line);
  background: rgba(255,255,255,.4);
  backdrop-filter: blur(8px);
}
.footer a:hover { color: var(--c-emerald-600); }
.footer .staff-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--c-ink-muted);
  font-size: 12px;
  text-decoration: none;
  opacity: .7;
  transition: opacity .2s, color .2s;
}
.footer .staff-link:hover { opacity: 1; color: var(--c-emerald-600); }

/* ---- Reveal animations ---- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .8s cubic-bezier(.2,.7,.3,1), transform .8s cubic-bezier(.2,.7,.3,1);
}
.reveal.in { opacity: 1; transform: none; }
.reveal-delay-1 { transition-delay: .08s; }
.reveal-delay-2 { transition-delay: .16s; }
.reveal-delay-3 { transition-delay: .24s; }
.reveal-delay-4 { transition-delay: .32s; }
.reveal-delay-5 { transition-delay: .40s; }
.reveal-delay-6 { transition-delay: .48s; }

/* ---- Map ---- */
.map-wrap {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.85);
}
.map-svg { width: 100%; height: auto; display: block; }
.map-svg .building {
  cursor: pointer;
  transition: filter .25s, opacity .25s;
}
.map-svg .building:hover { filter: brightness(1.05) drop-shadow(0 8px 24px rgba(16,185,129,.3)); }
.map-svg .building.dim { opacity: .4; }
.map-svg .building.active rect,
.map-svg .building.active polygon {
  filter: drop-shadow(0 0 18px rgba(16,185,129,.7));
}
.map-svg .building-label {
  pointer-events: none;
  fill: #0f172a;
  font-weight: 700;
  font-family: inherit;
}
.map-svg .room-pin {
  filter: drop-shadow(0 0 12px rgba(16,185,129,.9));
  animation: pin-bob 1.6s ease-in-out infinite;
}
@keyframes pin-bob {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-6px); }
}

/* ---- Alerts ---- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, .8);
  margin-bottom: 16px;
  display: flex; gap: 12px; align-items: flex-start;
  color: var(--c-ink);
}
.alert-warning { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.alert-error   { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }
.alert-success { background: #f0fdf4; border-color: #86efac; color: #166534; }

/* ---- Spinner ---- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(15,23,42,.15);
  border-top-color: var(--c-emerald-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Tables (admin) ---- */
.table-wrap {
  border-radius: var(--radius);
  overflow: auto;
  border: 1px solid var(--c-line);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
table.t {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
table.t th, table.t td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--c-line);
  white-space: nowrap;
}
table.t th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--c-ink-muted);
  background: #f8fafc;
  position: sticky; top: 0;
  font-weight: 600;
}
table.t tbody tr { transition: background .15s; }
table.t tbody tr:hover { background: rgba(16,185,129,.04); }

/* ---- Admin layout ---- */
.admin-shell {
  position: relative;
  z-index: 2;
  min-height: 100vh;
}
.admin-side {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 240px;
  height: 100vh;
  border-right: 1px solid var(--c-line);
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(20px);
  padding: 22px 14px;
  overflow-y: auto;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.admin-side .brand { padding: 0 8px 18px; }
.admin-side a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  color: var(--c-ink-soft); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.admin-side a:hover, .admin-side a.active {
  background: #d1fae5;
  color: var(--c-emerald-700);
}
.admin-main {
  margin-left: 240px;
  padding: 28px 32px;
  min-width: 0;
  min-height: 100vh;
}

/* Mobile menu toggle (hidden on desktop) */
.admin-menu-toggle {
  display: none;
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-line);
  align-items: center;
  gap: 12px;
}
.admin-menu-toggle button {
  appearance: none;
  border: 1px solid var(--c-line);
  background: #fff;
  width: 38px; height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: grid; place-items: center;
  color: var(--c-ink);
}
.admin-menu-toggle button:hover { background: #ecfdf5; border-color: var(--c-emerald-300); }
.admin-menu-toggle .title { font-weight: 700; color: var(--c-ink); flex: 1; }
.admin-menu-toggle .logo {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff, #ecfdf5);
  display: grid; place-items: center;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(16,185,129,.3);
}
.admin-menu-toggle .logo img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }

@media (max-width: 800px) {
  .admin-menu-toggle { display: flex; }
  .admin-side {
    width: 280px;
    z-index: 80;
    background: #fff;
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.2,.7,.3,1);
    box-shadow: 0 0 40px -10px rgba(0,0,0,.2);
  }
  .admin-side.open { transform: translateX(0); }
  .admin-side .brand { display: flex; }
  .admin-side a { padding: 12px 14px; white-space: normal; }
  .admin-main {
    margin-left: 0;
    padding: 16px;
  }

  /* Backdrop when sidebar open */
  .admin-backdrop {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.4);
    backdrop-filter: blur(4px);
    z-index: 75;
    display: none;
    animation: m-fade .25s ease;
  }
  .admin-backdrop.open { display: block; }

  /* Tables: scroll horizontally rather than crushing */
  .table-wrap { max-width: 100%; }
  table.t { font-size: 13px; }
  table.t th, table.t td { padding: 10px 12px; }

  /* Modals fill more on mobile */
  .modal { max-height: 96vh; }
  .modal-body { padding: 16px; }
}
@media (max-width: 480px) {
  /* Stack action buttons */
  .row { gap: 8px; }
  .stat .value { font-size: 22px; }
}

/* ---- Misc ---- */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-border-2), transparent);
  margin: 28px 0;
}
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.row-end { justify-content: flex-end; }
.muted { color: var(--c-ink-muted); }
.small { font-size: 13px; }

input, select, textarea { font-family: inherit; }

/* Form fields (admin) */
.input, .select, .textarea {
  width: 100%;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--c-line);
  border-radius: 12px;
  color: var(--c-ink);
  font-size: 14px;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--c-emerald-500);
  box-shadow: 0 0 0 4px rgba(16,185,129,.12);
}
.label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--c-ink-muted);
  margin-bottom: 6px;
  font-weight: 600;
}

/* Stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat {
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  background: var(--c-bg-3);
  position: relative;
  overflow: hidden;
  transition: transform .25s, box-shadow .25s;
  box-shadow: var(--shadow-xs);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat::before {
  content: ''; position: absolute; inset: 0;
  background: var(--grad-card); opacity: .8;
}
.stat > * { position: relative; }
.stat .label { margin-bottom: 4px; }
.stat .value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; color: var(--c-ink); }

/* ============================================================
   Modal — used by admin pages
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: m-fade .25s ease;
}
.modal-backdrop.open { display: flex; }
@keyframes m-fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff;
  border: 1px solid var(--glass-border-2);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px -20px rgba(15, 23, 42, .25), 0 8px 24px -8px rgba(16, 185, 129, .12);
  animation: m-slide .35s cubic-bezier(.2,.7,.3,1);
}
@keyframes m-slide {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--c-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 100%);
  flex-shrink: 0;
}
.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--c-ink);
  line-height: 1.3;
}
.modal-header .subtitle {
  font-size: 13px;
  color: var(--c-ink-muted);
  margin-top: 2px;
}
.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--c-ink-muted);
  display: grid;
  place-items: center;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.modal-close:hover { background: rgba(15,23,42,.06); color: var(--c-ink); }

.modal-body {
  padding: 22px 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-section { margin-bottom: 22px; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--c-emerald-700);
  font-weight: 700;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-section-title::before {
  content: '';
  width: 18px; height: 2px;
  background: var(--c-emerald-500);
  border-radius: 2px;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.modal-grid .span-2 { grid-column: span 2; }

.modal-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--c-emerald-700);
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--c-line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  flex-shrink: 0;
}
.modal-footer .left { display: flex; gap: 8px; }
.modal-footer .right { display: flex; gap: 8px; }

.btn-danger {
  color: #dc2626;
  background: #fff;
  border: 1px solid rgba(239,68,68,.3);
}
.btn-danger:hover {
  background: #fef2f2;
  border-color: #ef4444;
  color: #b91c1c;
}

@media (max-width: 600px) {
  .modal-backdrop { padding: 12px; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal-grid .span-2 { grid-column: span 1; }
  .modal-header { padding: 16px 18px; }
  .modal-body { padding: 18px; }
  .modal-footer { padding: 12px 18px; flex-wrap: wrap; }
}

/* ============================================================
   Search tabs (homepage)
   ============================================================ */
.search-tabs {
  display: inline-flex;
  background: rgba(255,255,255,.7);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.search-tabs button {
  appearance: none;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--c-ink-soft);
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s, color .2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.search-tabs button.active {
  background: var(--c-emerald-500);
  color: #fff;
  box-shadow: 0 4px 12px -3px rgba(16,185,129,.5);
}
.search-tabs button:hover:not(.active) {
  color: var(--c-emerald-700);
}

.dual-field {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, .75);
  border: 1.5px solid var(--glass-border);
  border-radius: 999px;
  padding: 6px;
  transition: border-color .25s, box-shadow .25s, transform .25s, background .25s;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-xs);
}
.dual-field:focus-within {
  border-color: var(--c-emerald-500);
  background: #fff;
  box-shadow: 0 0 0 6px rgba(16,185,129,.12), 0 12px 36px -10px rgba(16,185,129,.35);
  transform: translateY(-1px);
}
.dual-field input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--c-ink);
  font-size: 16px;
  font-family: inherit;
  padding: 14px 20px;
  min-width: 0;
}
.dual-field input::placeholder { color: var(--c-ink-muted); }
.dual-field .divider-v {
  width: 1px;
  height: 28px;
  background: var(--c-line);
  flex-shrink: 0;
}
.dual-field .btn { flex-shrink: 0; }

@media (max-width: 580px) {
  .dual-field {
    flex-direction: column;
    border-radius: 22px;
    padding: 8px;
    align-items: stretch;
    gap: 4px;
  }
  .dual-field input {
    padding: 12px 16px;
    font-size: 15px;
    background: rgba(236,253,245,.4);
    border-radius: 14px;
    text-align: center;
  }
  .dual-field input:focus { background: #fff; box-shadow: 0 0 0 2px rgba(16,185,129,.18); }
  .dual-field .divider-v { display: none; }
  .dual-field .btn { width: 100%; margin-top: 4px; padding: 14px 24px; border-radius: 14px; }
}

/* Multi-match selection cards */
.match-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}
.match-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--glass-border);
  text-decoration: none;
  color: inherit;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.match-card:hover {
  transform: translateY(-2px);
  border-color: var(--c-emerald-400);
  box-shadow: var(--shadow);
}
.match-card .av {
  width: 56px; height: 56px;
  border-radius: 18px;
  background: var(--grad-accent);
  display: grid; place-items: center;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  flex-shrink: 0;
}
.match-card .info { flex: 1; min-width: 0; }
.match-card .info strong { display: block; color: var(--c-ink); font-size: 16px; margin-bottom: 2px; }
.match-card .info span { display: block; color: var(--c-ink-muted); font-size: 13px; }
.match-card .arrow { color: var(--c-emerald-500); flex-shrink: 0; }

/* Filter chips (admin tables) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255,255,255,.7);
  border: 1px solid var(--c-line);
  color: var(--c-ink-soft);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s, transform .15s;
}
.chip:hover {
  background: #ecfdf5;
  color: var(--c-emerald-700);
  border-color: var(--c-emerald-300);
}
.chip.active {
  background: var(--c-emerald-500);
  color: #fff;
  border-color: var(--c-emerald-600);
  box-shadow: 0 4px 12px -3px rgba(16,185,129,.45);
}

/* Live search row hide */
table.t tbody tr.hide-row { display: none; }

/* Quick pay toggle pills (payments table) */
.pay-pills {
  display: inline-flex;
  gap: 4px;
  background: rgba(15,23,42,.04);
  border-radius: 999px;
  padding: 3px;
}
.pay-pills button {
  appearance: none;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--c-ink-muted);
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.pay-pills button:hover { color: var(--c-ink); }
.pay-pills button.active.paid    { background: #d1fae5; color: var(--c-emerald-700); }
.pay-pills button.active.unpaid  { background: #fee2e2; color: #b91c1c; }
.pay-pills button.active.pending { background: #fef3c7; color: #92400e; }

/* Empty state */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--c-ink-muted);
}
.empty .icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: #ecfdf5;
  display: grid; place-items: center;
  margin: 0 auto 16px;
  color: var(--c-emerald-500);
}
.empty h3 { margin: 0 0 6px; color: var(--c-ink); font-size: 18px; }
.empty p { margin: 0 0 16px; font-size: 14px; }

/* ============================================================
   Admin override — professional dashboard look
   Applied via <body class="admin">
   ============================================================ */
body.admin {
  background: #f4f6f8;
  background-attachment: scroll;
  font-family: 'Inter', 'IBM Plex Sans Thai', system-ui, -apple-system, sans-serif;
  color: #0f172a;
}
body.admin::before,
body.admin::after { display: none; }
body.admin .bg-grid,
body.admin .bg-orbs { display: none; }

/* Sidebar */
body.admin .admin-side {
  background: #ffffff;
  border-right: 1px solid #e2e8f0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body.admin .admin-side a {
  color: #475569;
  font-size: 14px;
  font-weight: 500;
}
body.admin .admin-side a:hover {
  background: #f1f5f9;
  color: #0f172a;
}
body.admin .admin-side a.active {
  background: #ecfdf5;
  color: var(--c-emerald-700);
  font-weight: 600;
}

/* Cards (glass becomes plain white card) */
body.admin .glass,
body.admin .glass-strong {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
  border-radius: 10px;
}
body.admin .glass::before { display: none; }

/* Stat tiles */
body.admin .stat {
  padding: 16px 20px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(15,23,42,.04);
  border-radius: 10px;
}
body.admin .stat::before { display: none; }
body.admin .stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 6px;
}
body.admin .stat .value {
  font-size: 26px;
  color: #0f172a;
  font-weight: 700;
}

/* Buttons — flatter, less wow */
body.admin .btn-primary {
  background: var(--c-emerald-600);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
  font-size: 14px;
  padding: 10px 18px;
}
body.admin .btn-primary:hover {
  background: var(--c-emerald-700);
  transform: none;
  box-shadow: 0 3px 8px -2px rgba(16,185,129,.4);
}
body.admin .btn-primary::after { display: none; }
body.admin .btn-ghost {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 14px;
  padding: 10px 18px;
}
body.admin .btn-ghost:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}
body.admin .btn-lg { padding: 12px 22px; font-size: 14px; }
body.admin .btn-danger {
  background: #fff;
  border-color: #fecaca;
  color: #b91c1c;
}
body.admin .btn-danger:hover { background: #fef2f2; border-color: #fca5a5; }

/* Form inputs */
body.admin .input,
body.admin .select,
body.admin .textarea {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 12px;
  color: #0f172a;
  font-size: 14px;
  font-family: inherit;
}
body.admin .input::placeholder,
body.admin .textarea::placeholder { color: #94a3b8; opacity: 1; }
body.admin .input:focus,
body.admin .select:focus,
body.admin .textarea:focus {
  border-color: var(--c-emerald-500);
  box-shadow: 0 0 0 3px rgba(16,185,129,.15);
  outline: none;
}
body.admin .field {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 4px 4px 4px 16px;
  box-shadow: none;
}
body.admin .field:focus-within {
  border-color: var(--c-emerald-500);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(16,185,129,.15);
  transform: none;
}
body.admin .label {
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  color: #475569;
  font-weight: 600;
  margin-bottom: 4px;
}

/* Tables */
body.admin .table-wrap {
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(15,23,42,.04);
  border-radius: 10px;
}
body.admin table.t th {
  background: #f8fafc;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
  font-size: 11px;
  letter-spacing: .08em;
  font-weight: 600;
}
body.admin table.t td {
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}
body.admin table.t tbody tr:hover { background: #f8fafc; }

/* Eyebrow / chips in admin */
body.admin .eyebrow {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}
body.admin .chip {
  background: #fff;
  border-color: #e2e8f0;
  color: #475569;
}
body.admin .chip:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}
body.admin .chip.active {
  background: var(--c-emerald-600);
  border-color: var(--c-emerald-700);
  color: #fff;
  box-shadow: none;
}

/* Modal */
body.admin .modal-backdrop {
  background: rgba(15, 23, 42, .5);
}
body.admin .modal {
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 4px 16px -4px rgba(0,0,0,.1);
}
body.admin .modal-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 16px 22px;
}
body.admin .modal-header h2 { color: #0f172a; font-size: 16px; }
body.admin .modal-header .subtitle { color: #64748b; font-size: 12px; }
body.admin .modal-footer {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  padding: 12px 22px;
}
body.admin .modal-section-title {
  color: #475569;
  font-size: 11px;
  letter-spacing: .08em;
  font-weight: 700;
}
body.admin .modal-section-title::before { background: var(--c-emerald-500); }
body.admin .modal-hint { color: var(--c-emerald-700); font-size: 12px; background: #ecfdf5; padding: 8px 12px; border-radius: 6px; }
body.admin .label { font-size: 12px; color: #475569; text-transform: none; letter-spacing: 0; font-weight: 600; margin-bottom: 6px; }
body.admin .modal-close { color: #64748b; }
body.admin .modal-close:hover { background: #e2e8f0; color: #0f172a; }

/* Section title in admin */
body.admin h1 {
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
}
body.admin h2 { font-size: 18px; font-weight: 700; }
body.admin h3 { font-size: 15px; font-weight: 600; }

/* Top mobile bar */
body.admin .admin-menu-toggle {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  backdrop-filter: none;
}

/* Stat numbers — neutral if no explicit color */
body.admin .stat .value[style*="6FFFB0"] { color: var(--c-emerald-600) !important; }

/* Pay pills in admin (more subdued) */
body.admin .pay-pills {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
