:root {
  /* Gig Share palette — "Ink & Ember": near-black ink + single ember accent + gold highlight */
  --ink: #242220;
  --ink-2: #302D28;
  --ink-soft: #5C5750;
  /* --muted: text on light surfaces. #726C62 is ~5.2:1 on white / ~4.7:1 on paper,
     meets WCAG AA. Also used for a few dots/borders where darker reads fine. */
  --muted: #726C62;
  /* Lighter warm grey for muted text on DARK surfaces (sidebar, .kpi.feature). */
  --muted-on-dark: #C9C3B8;
  --line: #E3DDD0;
  --line-2: #EAE6DC;
  --paper: #F7F4EE;
  --paper-2: #EFEAE0;
  --card: #FFFFFF;
  --gold: #E7C878;
  --gold-soft: #F0DAA2;
  --gold-tint: #F7ECCF;
  --brand: #B8503A;
  --brand-soft: #F1A98C;
  --sidebar: #242220;
  --sidebar-strong: #1A1815;
  --desk: #D6D2C7;
  --r: #B8503A;
  --t: #6B655C;
  --m: #E7C878;
  --s: #3D3A34;
  --green: #3F7A54;
  --red: #A82F1E;
  /* Single accent system: ember (--brand/--r, ~4.9-5.0:1 on white) carries all
     primary actions and the R pillar; gold is a highlight-only secondary, never
     a second competing hue. --brand-strong goes darker still for gradients/hover
     on dark UI chrome. Both --brand-strong and --gold-strong are OVERRIDDEN
     per-tenant in config.js (app = dark orange #B4530A, admin = near-black,
     manager = dark purple). These are the base/Gig-Share fallbacks. Use
     --gold-strong for gold/orange TEXT and --brand-strong for solid buttons
     with white text — never the vivid --gold/--brand. --red stays a distinct
     deeper crimson from --brand so "danger" reads apart from "primary action". */
  --brand-strong: #8F3A28;
  --gold-strong: #A6791E;
  --shadow-sm: 0 1px 2px rgba(44,44,46,0.06), 0 1px 1px rgba(44,44,46,0.04);
  --shadow-md: 0 8px 24px rgba(44,44,46,0.08), 0 2px 6px rgba(44,44,46,0.04);
  --shadow-lg: 0 24px 60px rgba(44,44,46,0.12), 0 6px 16px rgba(44,44,46,0.06);
  /* Aliases for legacy variable names referenced across the file but never declared
     (previously fell back to invalid/empty → lost tints & shadows). */
  --bg: var(--paper);
  --bg-2: var(--paper-2);
  --soft: var(--paper-2);
  --shadow: var(--shadow-md);
  --orange: var(--gold);
  /* Layering scale — use these instead of magic z-index numbers. */
  --z-sticky: 20;
  --z-dropdown: 40;
  --z-overlay: 1000;
  --z-modal: 1100;
  --z-popup: 9000;
  --z-toast: 99999;
}

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

/* Visually hidden but available to screen readers (skip links, page headings). */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}
.sidebar :focus-visible {
  outline-color: var(--brand-soft);
}
body {
  font-family: 'IBM Plex Sans Thai', 'Prompt', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-wrap: pretty;
}
/* Pages with a sidebar (admin/manager/agent app): match body bg to the
   sidebar's dark color only in the LEFT gutter outside .app's centered
   max-width, so that strip reads as a continuation of the sidebar instead
   of a cream seam. The right gutter (and everything right of it) stays
   --paper — there's no sidebar there to justify a dark strip. Gutter width
   = half of (viewport - .app's 1440px max-width), clamped to 0 so pages
   narrower than 1440px (no gutter) fall back to a solid --paper body. */
body:has(.sidebar) {
  background: linear-gradient(
    to right,
    var(--sidebar) 0,
    var(--sidebar) max(0px, calc((100vw - 1440px) / 2)),
    var(--paper) 0
  );
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 1440px;
  margin: 0 auto;
  background: var(--paper);
  position: relative;
}

/* Floating circular toggle that collapses the labeled sidebar into an icon
   rail. Only meaningful on wide screens (≥1101px) where the full 260px sidebar
   shows; hidden below that, where the sidebar is already a rail. Sits on the
   seam between the sidebar rail and the main card. */
.sidebar-toggle { display: none; }
@media (min-width: 1101px) {
  .app-shell .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 225px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--line, rgba(15,26,46,0.12));
    background: #fff;
    color: var(--sidebar-strong);
    cursor: pointer;
    padding: 0;
    z-index: 30;
    box-shadow: 0 4px 12px rgba(44,44,46,0.16);
    transition: left 200ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease;
  }
  .app-shell .sidebar-toggle:hover {
    background: var(--sidebar);
    color: #fff;
  }
  .app-shell .sidebar-toggle svg { transition: transform 220ms ease; }
  .app-shell.sidebar-collapsed .sidebar-toggle { left: 81px; }
  .app-shell.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
}

/* ------- Sidebar ------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  background: var(--sidebar);
  color: #E3E5E9;
  padding: 28px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid var(--sidebar-strong);
  overflow-y: auto;
}
/* ซ่อน scrollbar ของ sidebar/nav แต่ยังเลื่อนได้ (Firefox + WebKit) */
.sidebar,
.sidebar .nav {
  scrollbar-width: none;         /* Firefox */
  -ms-overflow-style: none;      /* IE/Edge เก่า */
}
.sidebar::-webkit-scrollbar,
.sidebar .nav::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;                 /* Safari/Chrome */
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  width: 100%;
  max-width: 200px;
  border-radius: 14px;
  display: block;
  margin: 0 auto;
}
.brand-name {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.02em;
  color: #F4F5F7;
}
.brand-sub {
  font-size: 11px;
  color: var(--muted-on-dark);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 4px 4px 22px;
  border-bottom: 1px solid var(--sidebar-strong);
}
.sidebar-profile .agent-avatar {
  border: 3px solid rgba(94,164,133,0.55);
  box-shadow: 0 6px 18px rgba(15,26,46,0.28);
}
.sidebar-profile-name {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: #F4F5F7;
  line-height: 1.2;
}
.sidebar-profile-code {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted-on-dark);
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; }
.nav-label {
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--muted-on-dark);
  text-transform: uppercase;
  margin: 14px 8px 6px;
}
/* หัวข้อคั่นหมวดใน sidebar (Admin) — สืบทอด .nav-label + เส้นคั่นด้านบน */
.nav-group-label {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.nav-group-label:first-of-type {
  margin-top: 6px;
  padding-top: 0;
  border-top: none;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: #C7CBD2;
  font-size: 14px;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  font-family: inherit;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
  position: relative;
}
.nav-item .nav-icon { display: inline-flex; align-items: center; }
/* Desktop: ซ่อนไอคอนหน้าเมนู เหลือแค่เลขลำดับ + ชื่อ (มือถือยังโชว์ไอคอน) */
@media (min-width: 761px) {
  .nav-item .nav-icon { display: none; }
}
@keyframes nav-badge-pulse {
  0%, 100% { transform: scale(1);   box-shadow: 0 0 0 0 rgba(238,108,90,0.7); }
  50%       { transform: scale(1.1); box-shadow: 0 0 0 5px rgba(238,108,90,0);  }
}
@keyframes nav-badge-in {
  from { opacity: 0; transform: scale(0.5) translateY(-4px); }
  to   { opacity: 1; transform: scale(1)   translateY(0);    }
}
.nav-new-badge {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: var(--r, #EE6C5A);
  padding: 1px 5px;
  border-radius: 4px;
  line-height: 1.5;
  pointer-events: none;
  animation: nav-badge-in 300ms cubic-bezier(0.34,1.56,0.64,1) both,
             nav-badge-pulse 2s ease-in-out 400ms infinite;
}
.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: #F4F5F7;
  transform: translateX(2px);
}
.nav-item:focus-visible {
  outline: 2px solid var(--brand-soft);
  outline-offset: 2px;
}
.nav-item.active {
  background: linear-gradient(90deg, rgba(94,164,133,0.20), rgba(94,164,133,0));
  color: #F4F5F7;
  position: relative;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -22px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--brand);
  border-radius: 0 3px 3px 0;
}
.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: none;
  color: currentColor;
}

.sidebar-foot {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 18px;
  font-size: 11px;
  color: var(--muted-on-dark);
  line-height: 1.5;
}
.sidebar-foot strong { color: #DDE0E5; font-weight: 500; }

/* ------- Main ------- */
.main {
  padding: 0;
  background: var(--paper);
  overflow-x: hidden;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(246,245,241,0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 14px 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Floating rounded panels on wide screens (full 260px sidebar showing).
   Below 1101px the sidebar collapses / becomes a drawer, so keep it flush.
   Placed after the base .sidebar/.main/.topbar rules so it overrides them. */
@media (min-width: 1101px) {
  .app {
    gap: 0;
  }
  /* Sidebar sits flush against the viewport — no floating card, no desk
     gutter, no shadow, no rounded corners anywhere. */
  .sidebar {
    top: 0;
    height: 100dvh;
    align-self: start;
    min-height: 0;
    overflow-y: auto;
    border-right: none;
    position: sticky;
    z-index: 1;
  }
  /* Main sits flush next to the sidebar — no overlap, no rounding, no shadow. */
  .main {
    position: relative;
    z-index: 2;
  }

  /* App-shell (admin/manager): freeze the whole frame — the sidebar rail and
     the main panel stay put; only the content BELOW the topbar scrolls,
     inside the main panel. Scoped to .app-shell so the public/user app keeps
     window-scroll, which its in-page anchor navigation relies on. */
  .app-shell { height: 100dvh; }
  .app-shell .main {
    height: 100dvh;
    min-height: 0;          /* let the grid item shrink so overflow can scroll */
    overflow-y: auto;       /* content scrolls here; the frame stays fixed */
  }

  /* Collapsed state: shrink the labeled 260px sidebar down to a 64px icon rail,
     mirroring the automatic ≤1100px rail but triggered manually at any width. */
  .app-shell.sidebar-collapsed { grid-template-columns: 76px 1fr; }
  .app-shell.sidebar-collapsed .sidebar {
    padding: 22px 10px 20px;
    align-items: center;
    gap: 14px;
  }
  .app-shell.sidebar-collapsed .brand { justify-content: center; }
  .app-shell.sidebar-collapsed .brand-logo { max-width: 40px; }
  .app-shell.sidebar-collapsed .nav { align-items: center; gap: 4px; }
  .app-shell.sidebar-collapsed .nav-label { display: none; }
  .app-shell.sidebar-collapsed .sidebar-profile { display: none; }
  .app-shell.sidebar-collapsed .nav-item {
    width: 46px;
    height: 46px;
    padding: 0;
    justify-content: center;
    border-radius: 10px;
  }
  .app-shell.sidebar-collapsed .nav-item:hover { transform: none; }
  .app-shell.sidebar-collapsed .nav-item.active::before { display: none; }
  .app-shell.sidebar-collapsed .nav-item.active {
    background: rgba(231,200,120,0.22);
    color: #F4F5F7;
  }
  .app-shell.sidebar-collapsed .nav-text { display: none; }
  .app-shell.sidebar-collapsed .nav-icon { display: block; width: 20px; height: 20px; }
  .app-shell.sidebar-collapsed .nav-new-badge { right: 4px; top: 4px; }
  .app-shell.sidebar-collapsed .sidebar-foot {
    align-items: center;
    padding: 8px 0 4px;
  }
  .app-shell.sidebar-collapsed .sidebar-agent { display: none; }
  .app-shell.sidebar-collapsed .logout-btn,
  .app-shell.sidebar-collapsed .home-link {
    width: 46px;
    height: 46px;
    padding: 0;
    margin: 0;
    justify-content: center;
  }
}
.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(15, 26, 46, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  padding: 0;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.menu-btn:hover,
.menu-btn.open {
  background: var(--ink);
  border-color: var(--ink);
  box-shadow: var(--shadow-md);
}
.menu-btn span {
  position: absolute;
  left: 10px;
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 999px;
  transition: transform 160ms ease, opacity 120ms ease, background 140ms ease;
}
.menu-btn span:nth-child(1) { top: 13px; }
.menu-btn span:nth-child(2) { top: 19px; }
.menu-btn span:nth-child(3) { top: 25px; }
.menu-btn:hover span,
.menu-btn.open span {
  background: #F6F5F1;
}
.menu-btn.open span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.menu-btn.open span:nth-child(2) {
  opacity: 0;
}
.menu-btn.open span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}
.mobile-overlay {
  display: none;
}
.crumbs {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.crumbs strong { color: var(--ink); font-weight: 600; }
.topbar-meta {
  display: flex;
  gap: 18px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); display: inline-block; margin-right: 7px;
}

/* ===== Admin notification bell ===== */
.notif-bell-wrap {
  position: relative;
  display: inline-flex;
}
.notif-bell {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 120ms ease;
  box-shadow: var(--shadow-sm);
}
.notif-bell:hover {
  background: var(--paper);
  border-color: rgba(15, 26, 46, 0.18);
}
.notif-bell.has-unread {
  border-color: var(--gold-soft);
  animation: notif-bell-pulse 2.4s ease-in-out infinite;
}
@keyframes notif-bell-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 121, 32, 0.35); }
  50%      { box-shadow: 0 0 0 8px rgba(244, 121, 32, 0); }
}
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  border: 2px solid var(--card);
  letter-spacing: 0;
}
.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 30;
  animation: notif-panel-in 140ms ease;
}
@keyframes notif-panel-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.notif-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-2);
}
.notif-panel-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.notif-panel-head strong {
  font-size: 14px;
  color: var(--ink);
}
.notif-panel-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.notif-sound-toggle {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  flex: 0 0 auto;
}
.notif-sound-toggle:hover {
  background: var(--paper);
  border-color: rgba(15, 26, 46, 0.18);
}
.notif-sound-toggle.off { color: var(--muted); }
.notif-sound-toggle.on  { color: var(--brand); border-color: var(--gold-soft); }
.notif-list {
  max-height: 60vh;
  overflow-y: auto;
}
.notif-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: var(--card);
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid var(--line-2);
  transition: background 120ms ease;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--paper); }
.notif-item.unread { background: rgba(244, 121, 32, 0.06); }
.notif-item.unread:hover { background: rgba(244, 121, 32, 0.1); }
.notif-item-icon {
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1;
  margin-top: 2px;
}
.notif-item-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}
.notif-item-msg {
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  word-break: break-word;
}
.notif-item-meta {
  font-size: 11px;
  color: var(--muted);
}
@media (max-width: 720px) {
  .notif-panel {
    width: calc(100vw - 24px);
    right: -8px;
  }
}

section.scene {
  padding: 48px 48px 32px;
  scroll-margin-top: 80px;
  border-bottom: 1px solid var(--line-2);
}
section.scene:last-child { border-bottom: none; padding-bottom: 88px; }

.eyebrow {
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold-strong);
  font-weight: 600;
  margin: 0 0 12px;
}
h1.display {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 48px;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
  color: var(--ink);
}
h1.display em {
  font-family: 'DM Serif Display', serif;
  font-style: italic;
  font-weight: 400;
  color: var(--gold);
}
.temporary-register-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -4px 0 24px;
  flex-wrap: wrap;
}
.temporary-register-copy {
  margin: 0;
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}
.temporary-register-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-family: 'Prompt', sans-serif;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 16px 34px rgba(255,112,40,0.24);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.temporary-register-btn:hover {
  background: #d95f18;
  box-shadow: 0 20px 42px rgba(255,112,40,0.3);
  transform: translateY(-1px);
}
.temporary-register-btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
h2.section-title {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  color: var(--ink);
}
.section-sub {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 680px;
  margin: 0 0 28px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 28px;
  gap: 28px;
  flex-wrap: wrap;
}
.section-head .section-sub { margin-bottom: 0; }

/* ------- KPI cards ------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 28px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 20px 18px;
  position: relative;
  overflow: hidden;
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}
.kpi:hover {
  transform: translateY(-2px);
  border-color: rgba(15,26,46,0.16);
  box-shadow: var(--shadow-md);
}
.kpi.feature:hover { border-color: var(--ink); }
.kpi.feature {
  background: var(--ink);
  color: #F4F5F7;
  border-color: var(--ink);
}
.kpi.feature .kpi-label,
.kpi.feature .kpi-sub { color: var(--muted-on-dark); }
.kpi.feature .kpi-value { color: #F4F5F7; }
.kpi.feature .kpi-value em { color: var(--gold-soft); }
.kpi-label {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.kpi-value {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 34px;
  line-height: 1.08;
  margin: 8px 0 2px;
  letter-spacing: -0.02em;
}
.kpi-value em {
  font-family: 'DM Serif Display', serif;
  font-style: italic;
  font-weight: 400;
  font-size: 19px;
  color: var(--gold-strong);
  margin-left: 4px;
  letter-spacing: 0;
}
.kpi-sub {
  font-size: 12px;
  color: var(--muted);
}
.kpi-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: var(--line-2);
}
.kpi-bar-fill {
  height: 100%;
  background: var(--gold);
  width: 8%;
  transition: width 600ms ease;
}
.kpi.feature .kpi-bar { background: rgba(255,255,255,0.06); }
.kpi.feature .kpi-bar-fill { background: var(--gold-soft); }

/* ------- RTMS pillars ------- */
.rtms-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.pillar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 22px 22px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 160ms, box-shadow 160ms, border-color 160ms;
}
.pillar:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.pillar.active {
  border-color: var(--ink);
  box-shadow: var(--shadow-md);
}
.pillar-letter {
  font-family: 'DM Serif Display', serif;
  font-size: 84px;
  line-height: 1;
  font-style: italic;
  position: absolute;
  right: 14px;
  top: 4px;
  opacity: 0.08;
  color: var(--ink);
}
.pillar.r .pillar-letter { color: var(--r); opacity: 0.14; }
.pillar.t .pillar-letter { color: var(--t); opacity: 0.14; }
.pillar.m .pillar-letter { color: var(--m); opacity: 0.18; }
.pillar.s .pillar-letter { color: var(--s); opacity: 0.14; }
.pillar-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.pillar-tag::before {
  content: '';
  width: 22px; height: 1px;
  background: currentColor;
}
.pillar.r .pillar-tag { color: var(--r); }
.pillar.t .pillar-tag { color: var(--t); }
.pillar.m .pillar-tag { color: var(--m); }
.pillar.s .pillar-tag { color: var(--s); }
.pillar h3 {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 22px;
  margin: 14px 0 6px;
  letter-spacing: -0.01em;
}
.pillar-desc {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-bottom: 18px;
  min-height: 60px;
}
.pillar-metric {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 1px solid var(--line-2);
  padding-top: 14px;
}
.pillar-metric-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.pillar-metric-value {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 18px;
}

/* ------- Weekly grid ------- */
.view-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin: 4px 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}
.view-switch button {
  min-width: 116px;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
.view-switch button:hover {
  color: var(--ink);
}
.view-switch button.active {
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.week-grid {
  display: grid;
  grid-template-columns: 70px repeat(7, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.week-head {
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.week-head.today {
  color: var(--ink);
  font-weight: 600;
}
.week-head.weekend { color: #B6AC93; }
/* Thai traditional day-of-week colors — soft pastels for parchment theme */
.week-head.day-1, .month-weekday.day-1 { background: #FFF5C2; color: #8A6B0E; border-bottom-color: #E6CE6B; } /* จันทร์ — เหลือง */
.week-head.day-2, .month-weekday.day-2 { background: #FFD9E4; color: #9C3A60; border-bottom-color: #E8A4BD; } /* อังคาร — ชมพู */
.week-head.day-3, .month-weekday.day-3 { background: #D6F1DE; color: #2F6B47; border-bottom-color: #88C9A1; } /* พุธ — เขียว */
.week-head.day-4, .month-weekday.day-4 { background: #FFE0BE; color: #8A4D14; border-bottom-color: #E8B47A; } /* พฤหัส — ส้ม */
.week-head.day-5, .month-weekday.day-5 { background: #CFE6FA; color: #1F4A78; border-bottom-color: #82B6E2; } /* ศุกร์ — ฟ้า */
.week-head.day-6, .month-weekday.day-6 { background: #E2D4F4; color: #4A2D7A; border-bottom-color: #B79CE0; } /* เสาร์ — ม่วง */
.week-head.day-7, .month-weekday.day-7 { background: #FBD2D2; color: #8A1F1F; border-bottom-color: #E08C8C; } /* อาทิตย์ — แดง */
.week-head[class*="day-"], .month-weekday[class*="day-"] { border-radius: 8px 8px 0 0; font-weight: 600; }
.week-head span {
  display: block;
  margin-top: 4px;
  letter-spacing: 0;
  text-transform: none;
  font-size: 10px;
  color: var(--ink-soft);
}
.time-col {
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  color: var(--muted);
  padding: 14px 4px;
  text-align: right;
  border-right: 1px solid var(--line-2);
  letter-spacing: 0.04em;
}
.slot {
  min-height: 78px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.slot-empty {
  border-radius: 8px;
  border: 1px dashed transparent;
}
.club-chip {
  border-radius: 8px;
  padding: 9px 11px;
  background: var(--card);
  border: 1px solid var(--line);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 120ms, box-shadow 120ms;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.club-chip:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.club-chip::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--ink);
}
.club-chip.r::before { background: var(--r); }
.club-chip.t::before { background: var(--t); }
.club-chip.m::before { background: var(--m); }
.club-chip.s::before { background: var(--s); }
.club-chip.tm::before { background: linear-gradient(180deg, var(--t) 50%, var(--m) 50%); }
.club-chip.ts::before { background: linear-gradient(180deg, var(--t) 50%, var(--s) 50%); }
.club-chip.rm::before { background: linear-gradient(180deg, var(--r) 50%, var(--m) 50%); }
.club-name {
  font-size: 12px;
  font-weight: 600;
  font-family: 'Prompt', sans-serif;
  letter-spacing: -0.005em;
  color: var(--ink);
  line-height: 1.2;
}
.club-meta {
  font-size: 10px;
  color: var(--muted);
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}
.club-meta .pill {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--gold-tint);
  color: var(--gold);
  letter-spacing: 0.04em;
  font-weight: 500;
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  margin-left: 8px;
  padding: 2px 7px;
  border: 1px solid rgba(180, 58, 44, 0.24);
  border-radius: 999px;
  background: rgba(180, 58, 44, 0.1);
  color: var(--red);
  font-family: 'Prompt', sans-serif;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  text-transform: uppercase;
}
.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 0 rgba(180, 58, 44, 0.52);
  animation: live-pulse 1.1s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(180, 58, 44, 0.52);
  }
  50% {
    opacity: 0.42;
    transform: scale(0.76);
    box-shadow: 0 0 0 5px rgba(180, 58, 44, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot {
    animation: none;
  }
}

/* Highlight calendar cells of clubs that are currently live */
.club-chip.live,
.month-event.live {
  position: relative;
  border-color: rgba(180, 58, 44, 0.55) !important;
  background: linear-gradient(135deg, rgba(180, 58, 44, 0.14), rgba(180, 58, 44, 0.04));
  animation: live-cell-pulse 1.6s ease-in-out infinite;
}
@keyframes live-cell-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(180, 58, 44, 0.55); }
  50%      { box-shadow: 0 0 0 6px rgba(180, 58, 44, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .club-chip.live,
  .month-event.live { animation: none; }
}

/* Dim sessions whose time has already passed */
.club-chip.past,
.month-event.past {
  background: var(--paper-2);
  border-color: var(--line);
  opacity: 0.55;
  filter: grayscale(1);
}
.club-chip.past:hover,
.month-event.past:hover {
  opacity: 0.78;
}
.club-chip.past::before,
.month-event.past::before {
  background: var(--muted) !important;
}
.club-chip.past .club-name,
.club-chip.past .club-meta,
.month-event.past strong,
.month-event.past span {
  color: var(--muted);
}

.monthly-club-panel {
  width: 100%;
  max-width: none;
  display: grid;
  gap: 12px;
}
.monthly-club-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.month-picker {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
}
.month-picker.current {
  grid-template-columns: 1fr;
}
.month-picker button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.month-picker button:hover {
  border-color: var(--ink-soft);
  background: var(--paper-2);
}
.month-picker button:active { transform: scale(0.96); }
.month-picker div {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.month-picker span {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.month-picker strong {
  font-family: 'Prompt', sans-serif;
  font-size: 24px;
  color: var(--ink);
}
.monthly-club-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-2);
}
.monthly-club-head span {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.monthly-club-head strong {
  font-family: 'Prompt', sans-serif;
  font-size: 20px;
  color: var(--ink);
}
.monthly-club-total {
  margin: 12px 0;
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold-strong);
}
.monthly-club-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.month-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(96px, 1fr));
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) var(--paper-2);
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}
.month-calendar::-webkit-scrollbar {
  height: 8px;
}
.month-calendar::-webkit-scrollbar-track {
  border-radius: 999px;
  background: var(--paper-2);
}
.month-calendar::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--gold);
}
.month-weekday {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  text-align: center;
}
.month-weekday.weekend {
  color: #B6AC93;
}
.month-day {
  min-height: 118px;
  padding: 8px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--paper-2);
}
.month-day.blank {
  border-color: transparent;
  background: transparent;
}
.month-date {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  font-weight: 600;
}
.month-events {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}
.month-event {
  position: relative;
  padding: 6px 6px 6px 9px;
  border-radius: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  overflow: hidden;
}
.month-event::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--ink);
}
.month-event.r::before { background: var(--r); }
.month-event.t::before { background: var(--t); }
.month-event.m::before { background: var(--m); }
.month-event.s::before { background: var(--s); }
.month-event.tm::before { background: linear-gradient(180deg, var(--t) 50%, var(--m) 50%); }
.month-event strong {
  display: block;
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-size: 10px;
  line-height: 1.25;
}
.month-event span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.2;
}
.month-event .live-badge {
  display: inline-flex;
  margin-top: 4px;
  margin-left: 0;
}
.monthly-club-item {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-height: 58px;
  padding: 8px 8px 8px 12px;
  border-radius: 8px;
  background: var(--soft);
  overflow: hidden;
}
.monthly-club-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--ink);
}
.monthly-club-item.r::before { background: var(--r); }
.monthly-club-item.t::before { background: var(--t); }
.monthly-club-item.m::before { background: var(--m); }
.monthly-club-item.s::before { background: var(--s); }
.monthly-club-item.tm::before { background: linear-gradient(180deg, var(--t) 50%, var(--m) 50%); }
.monthly-club-item strong {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  line-height: 1.25;
  color: var(--ink);
}
.monthly-club-item span {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.35;
}
.monthly-club-item em {
  flex: 0 0 auto;
  align-self: flex-start;
  padding: 3px 6px;
  border-radius: 999px;
  background: var(--gold-tint);
  color: var(--gold);
  font-style: normal;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.month-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.month-dots button {
  min-width: 52px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}
.month-dots button:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}
.month-dots button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

/* ------- Activity rows (external activities, simplified list) ------- */
.activity-list {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}
.activity-row {
  --act-accent: #DDBB72;
  --act-tint: #F7E8C2;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s;
}
.activity-row:hover { border-color: color-mix(in srgb, var(--act-accent) 45%, var(--line)); }
.activity-row.tone-0 { --act-accent: #8E7AE6; --act-tint: #DDD6FF; }
.activity-row.tone-1 { --act-accent: #E2AA4C; --act-tint: #FFE2A4; }
.activity-row.tone-2 { --act-accent: #4A9C91; --act-tint: #BFE7DF; }
.activity-row.tone-3 { --act-accent: #CE7A91; --act-tint: #F2C7D4; }
.activity-row.tone-4 { --act-accent: #6D98C7; --act-tint: #CAE1F7; }
.activity-row-thumb {
  flex: none;
  border: none;
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  background: var(--act-tint);
}
.activity-row-thumb.landscape { width: 120px; aspect-ratio: 3 / 2; }
.activity-row-thumb.portrait { width: 80px; aspect-ratio: 2 / 3; }
.activity-row-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.activity-row-thumb.poster-trigger { cursor: zoom-in; }
.activity-row-thumb.poster-trigger:hover { filter: brightness(0.95); }
.activity-row-thumb.poster-trigger:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--act-accent) 42%, transparent);
  outline-offset: 2px;
}
.activity-row-thumb.empty {
  display: grid;
  place-items: center;
  color: color-mix(in srgb, var(--act-accent) 70%, var(--ink));
  font-family: 'Prompt', sans-serif;
  font-weight: 700;
  font-size: 11px;
}
.activity-row-main {
  flex: 1;
  min-width: 0;
}
.activity-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.activity-row-top h3 {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-row-tag {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--act-tint) 55%, #fff);
  color: color-mix(in srgb, var(--act-accent) 78%, var(--ink));
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  font-weight: 700;
}
.activity-row-main p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-row-date {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 12.5px;
  color: var(--muted);
}
.activity-row-date strong {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}
@media (max-width: 640px) {
  .activity-row { flex-wrap: wrap; }
  .activity-row-thumb.landscape { width: 96px; }
  .activity-row-thumb.portrait { width: 68px; }
  .activity-row-date {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding-left: 104px;
  }
}

/* ------- Club detail cards ------- */
.club-card-list {
  display: grid;
  gap: 12px;
  margin-top: 22px;
  padding-bottom: 4px;
}
.club-schedule-card {
  --club-accent: #DDBB72;
  --club-tint: #F7E8C2;
  --club-rail: 0px;
  display: grid;
  grid-template-columns: var(--club-rail) minmax(0, 1fr) minmax(240px, 360px);
  grid-template-rows: auto auto auto;
  column-gap: clamp(16px, 2.2vw, 26px);
  row-gap: 8px;
  align-items: start;
  min-height: 0;
  padding: clamp(16px, 2vw, 22px) clamp(14px, 1.8vw, 20px) clamp(14px, 1.8vw, 18px) 0;
  border: 1px solid color-mix(in srgb, var(--club-accent) 28%, var(--line));
  border-radius: 18px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--club-tint) 42%, transparent) 0 var(--club-rail), transparent var(--club-rail)),
    var(--card);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.club-schedule-card > * {
  position: relative;
  z-index: 1;
}
.club-schedule-card.has-poster:hover {
  border-color: color-mix(in srgb, var(--club-accent) 58%, var(--line));
}
.club-schedule-card.tone-0 { --club-accent: #8E7AE6; --club-tint: #DDD6FF; }
.club-schedule-card.tone-1 { --club-accent: #E2AA4C; --club-tint: #FFE2A4; }
.club-schedule-card.tone-2 { --club-accent: #4A9C91; --club-tint: #BFE7DF; }
.club-schedule-card.tone-3 { --club-accent: #CE7A91; --club-tint: #F2C7D4; }
.club-schedule-card.tone-4 { --club-accent: #6D98C7; --club-tint: #CAE1F7; }
.club-schedule-card.live {
  border-color: color-mix(in srgb, var(--club-accent) 38%, var(--line));
  box-shadow: var(--shadow-sm);
}
/* คลาสที่ถูกงด/เลื่อน — แถบคาดแดงตัวใหญ่บนหัวการ์ด */
.club-schedule-card.postponed {
  border-color: var(--red);
  padding-top: 58px;
}
.club-postponed-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 10px 20px;
  background: repeating-linear-gradient(45deg, var(--red) 0 22px, #7A2216 22px 44px);
  color: #fff;
  box-shadow: 0 2px 10px rgba(226, 59, 59, 0.35);
}
.club-postponed-banner .cpb-label {
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.club-postponed-banner .cpb-date {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.95;
}
.club-schedule-card.postponed .club-schedule-poster img {
  opacity: 0.55;
  filter: grayscale(0.35);
}
.club-schedule-num {
  grid-column: 1;
  grid-row: 1 / -1;
  align-self: start;
  justify-self: center;
  padding-top: 16px;
  font-family: 'DM Serif Display', serif;
  font-style: italic;
  font-size: clamp(24px, 2vw, 32px);
  line-height: 1;
  color: color-mix(in srgb, var(--club-accent) 70%, var(--ink));
}
.club-schedule-num::after {
  content: "";
  display: block;
  width: 24px;
  height: 2px;
  margin: 8px auto 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--club-accent) 76%, #fff);
}
.club-schedule-main {
  grid-column: 2 / -1;
  grid-row: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(220px, 340px);
  gap: clamp(14px, 1.8vw, 22px);
  min-width: 0;
  align-items: start;
  align-self: start;
  justify-items: start;
  text-align: left;
}
.club-schedule-postcol {
  justify-self: stretch;
  align-self: start;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1vw, 12px);
}
.club-schedule-copy {
  text-align: left;
  align-self: stretch;
  display: flex;
  flex-direction: column;
}
/* ปุ่มเข้าเรียน Zoom / เช็คอิน อยู่ในคอลัมน์ซ้าย ปักไว้ก้นพื้นที่ว่างให้ลงตัวกับโปสเตอร์
   (margin-top:auto ดันลงล่างเมื่อมีที่ว่าง) */
.club-schedule-copy .schedule-zoom-btn {
  align-self: flex-start;
  margin-top: auto;
  margin-bottom: 2px;
}
/* ข้อความแจ้งผลเช็คอิน (เฉพาะตอน error) — วางใต้ปุ่ม ไม่ดันตำแหน่งปุ่ม */
.club-checkin-msg {
  display: block;
  margin-top: 6px;
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  font-weight: 600;
}
.club-checkin-msg.error { color: var(--red); }
.club-checkin-msg.ok { color: var(--green); }
.club-checkin-msg.info { color: var(--ink-soft); }
.club-schedule-copy h3 {
  margin: 10px 0 0;
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-size: clamp(20px, 2vw, 27px);
  font-weight: 700;
  line-height: 1.14;
}
.club-schedule-copy p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: clamp(13px, 1.3vw, 16px);
  line-height: 1.42;
}
.club-status-pill,
.club-feature-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  font-family: 'Prompt', sans-serif;
  font-weight: 700;
}
.club-status-pill {
  gap: 7px;
  padding: 5px 11px;
  background: color-mix(in srgb, var(--green) 12%, #fff);
  color: #2F6F5F;
  font-size: 12px;
}
.club-status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}
.club-status-pill.offline {
  background: color-mix(in srgb, var(--gold) 16%, #fff);
  color: #8A641E;
}
.club-status-pill.offline::before { background: var(--gold); }
.club-feature-pill {
  gap: 7px;
  margin-top: 12px;
  padding: 6px 11px;
  background: color-mix(in srgb, var(--club-tint) 44%, #fff);
  color: color-mix(in srgb, var(--club-accent) 78%, var(--ink));
  font-size: 12px;
}
.club-note {
  display: inline-flex;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  vertical-align: middle;
}
.club-note.gold { color: var(--gold); background: var(--gold-tint); }
.club-note.red { color: var(--red); background: rgba(180, 58, 44, 0.1); }
.club-spotlight {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--gold) 34%, var(--line));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--gold-tint) 70%, transparent), transparent 70%),
    color-mix(in srgb, var(--card) 88%, var(--gold-tint));
}
.club-spotlight-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Prompt', sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--gold);
  text-transform: uppercase;
}
.club-spotlight-star { font-size: 12px; line-height: 1; }
.club-spotlight-today {
  margin-left: 2px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gold);
  color: #FFFFFF;
  font-size: 10px;
  letter-spacing: 0.04em;
}
.club-spotlight-body {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.club-spotlight-body .avatar-name {
  font-size: 13px;
  font-weight: 600;
}
.club-spotlight-topics {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.club-spotlight-topics-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.club-spotlight-topic {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--gold) 30%, var(--line));
  background: rgba(255, 255, 255, 0.6);
  color: color-mix(in srgb, var(--gold) 30%, var(--ink));
  font-size: 12px;
  font-weight: 500;
}
.club-schedule-poster {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  max-height: none;
  border: 1px solid color-mix(in srgb, var(--club-accent) 34%, var(--line));
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255,255,255,0.72);
  box-shadow: 0 8px 18px rgba(15, 26, 46, 0.07);
}
.club-schedule-poster.portrait { aspect-ratio: 2 / 3; }
.club-schedule-poster.poster-trigger {
  padding: 0;
  cursor: zoom-in;
}
.club-schedule-poster.poster-trigger:hover {
  border-color: color-mix(in srgb, var(--club-accent) 58%, var(--line));
}
.club-schedule-poster.poster-trigger:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--club-accent) 42%, transparent);
  outline-offset: 3px;
}
.club-schedule-poster img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
}
.club-schedule-poster.empty {
  display: grid;
  place-items: center;
  color: color-mix(in srgb, var(--club-accent) 70%, var(--ink));
  font-family: 'Prompt', sans-serif;
  font-weight: 700;
  font-size: 18px;
}
.club-checkins {
  grid-column: 2 / -1;
  grid-row: 3;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: -2px;
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--club-accent) 22%, var(--line));
  border-radius: 13px;
  background: rgba(255,255,255,0.58);
}
.club-checkins-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-family: 'Prompt', sans-serif;
}
.club-checkins-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.club-checkin-list {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: clamp(8px, 1.3vw, 14px);
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.club-checkin-person {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  max-width: 132px;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--club-accent) 9%, #fff);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  min-width: 0;
}
.club-checkin-person span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.club-checkin-more {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--club-accent) 14%, #fff);
  color: color-mix(in srgb, var(--club-accent) 65%, var(--ink));
  cursor: pointer;
  font-family: 'Prompt', sans-serif;
  font-size: 15px;
  font-weight: 700;
}
.club-checkin-more:hover {
  background: color-mix(in srgb, var(--club-accent) 24%, #fff);
}
.club-checkin-modal {
  width: min(520px, 94vw);
  max-height: min(680px, 86vh);
  overflow: auto;
  position: relative;
  padding: 24px;
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.club-checkin-modal-head {
  padding-right: 34px;
  margin-bottom: 16px;
}
.club-checkin-modal-head span,
.club-checkin-modal-head em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}
.club-checkin-modal-head strong {
  display: block;
  margin: 2px 0;
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-size: 22px;
  line-height: 1.25;
}
.club-checkin-modal-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}
.club-checkin-modal-person {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}
.club-checkin-modal-person div {
  min-width: 0;
}
.club-checkin-modal-person strong,
.club-checkin-modal-person span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.club-checkin-modal-person strong {
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
}
.club-checkin-modal-person span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}
.club-schedule-meta {
  grid-column: 2 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  margin-top: -2px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--club-accent) 18%, var(--line));
  border-radius: 13px;
  background: rgba(255,255,255,0.68);
}
.club-schedule-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding-inline: 13px;
  border-right: 1px solid color-mix(in srgb, var(--club-accent) 16%, var(--line));
}
.club-schedule-info:first-child { padding-left: 0; }
.club-schedule-info:last-child {
  padding-right: 0;
  border-right: 0;
}
.club-schedule-info span,
.club-schedule-owners > span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
}
.club-schedule-info strong {
  display: block;
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-size: clamp(13px, 1.2vw, 16px);
  font-weight: 650;
  line-height: 1.25;
}
.club-mini-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--club-tint) 50%, #fff);
  color: color-mix(in srgb, var(--club-accent) 72%, var(--ink));
}
.club-mini-icon svg {
  width: 18px;
  height: 18px;
}
.club-feature-pill .club-mini-icon {
  width: 15px;
  height: 15px;
  border-radius: 0;
  background: transparent;
}
.club-feature-pill .club-mini-icon svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}
.club-schedule-owners {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  width: 100%;
  font-size: 12px;
  color: var(--ink-soft);
}
.club-schedule-owners > span { margin-bottom: 0; }
.club-schedule-owners .avatar-stack {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px 8px;
}
.club-schedule-owners .avatar {
  gap: 6px;
}
.club-schedule-owners .avatar-circle {
  width: 32px;
  height: 32px;
  font-size: 12px;
}
.club-schedule-owners .avatar-name { display: none; }
.club-schedule-actions {
  position: absolute;
  right: 24px;
  bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.club-schedule-card .schedule-zoom-btn {
  position: static;
}
.club-schedule-card.live .schedule-zoom-btn {
  background: #2d8cff;
  box-shadow: 0 10px 22px rgba(45, 140, 255, 0.24);
  animation: club-live-cta 2.8s ease-in-out infinite;
}
.club-schedule-card.live .schedule-zoom-btn:hover {
  background: #1a6fd4;
  box-shadow: 0 14px 28px rgba(45, 140, 255, 0.3);
}
@keyframes club-live-cta {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) {
  .club-schedule-card.live .schedule-zoom-btn {
    animation: none;
  }
}
/* นับถอยหลังก่อนถึงเวลาคลาส (โผล่ภายใน 30 นาทีก่อนเริ่ม) */
.class-countdown {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  gap: 6px;
  height: 26px;
  margin-left: 8px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(216, 178, 91, 0.42);
  background: linear-gradient(135deg, rgba(253, 232, 213, 0.9), rgba(251, 176, 122, 0.22));
  color: #8A5A18;
  font-family: 'Prompt', sans-serif;
  white-space: nowrap;
}
.class-countdown-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 0 rgba(244, 121, 32, 0.5);
  animation: countdown-pulse 1.4s ease-in-out infinite;
}
.class-countdown-label {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.8;
}
.class-countdown-time {
  display: inline-flex;
  align-items: baseline;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.class-countdown-time b { font-weight: 700; }
.class-countdown-time i {
  font-style: normal;
  padding: 0 1px;
  animation: countdown-blink 1s step-end infinite;
}
.class-countdown-unit {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.8;
}
@keyframes countdown-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 121, 32, 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(244, 121, 32, 0); }
}
@keyframes countdown-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
@media (prefers-reduced-motion: reduce) {
  .class-countdown-dot,
  .class-countdown-time i { animation: none; }
}
.poster-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 26, 46, 0.76);
  backdrop-filter: blur(6px);
}
.poster-modal {
  position: relative;
  max-width: min(96vw, 1100px);
  max-height: 92vh;
}
.poster-modal img {
  display: block;
  max-width: 100%;
  max-height: 92vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0,0,0,0.32);
}
.poster-modal-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

/* ------- Avatar ------- */
.avatar-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 10px;
}
.avatar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: #FFFFFF;
  letter-spacing: -0.01em;
  flex-shrink: 0;
  background: var(--ink);
  position: relative;
  overflow: hidden;
}
.avatar-circle::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(135deg, #2F6F93 0%, #6FAFD1 34%, #D8B25B 68%, #F3DE9A 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.avatar-circle.lg {
  width: 56px;
  height: 56px;
  font-size: 20px;
}
.avatar-circle.lg + .avatar-name {
  font-size: 13px;
}
.avatar-circle.has-photo {
  background-size: cover;
  background-position: center top;
  background-color: var(--bg-2);
  color: transparent;
}
.avatar-circle::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 50%;
  background: linear-gradient(160deg, rgba(255,255,255,0.18), rgba(0,0,0,0.08));
}
.avatar-name {
  font-size: 11px;
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-weight: 500;
  line-height: 1.2;
}
.avatar-name small {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: 10px;
  margin-top: 2px;
}

/* color rotation */
.avatar-c0 { background: #5EA485; }
.avatar-c1 { background: #C9A94E; }
.avatar-c2 { background: #4C4A7D; }
.avatar-c3 { background: #EE6C5A; }
.avatar-c4 { background: #6E4F8C; }
.avatar-c5 { background: #565E6B; }
.avatar-c6 { background: #B68A3E; }
.avatar-c7 { background: #4A6F4C; }
.avatar-c8 { background: #A04A66; }
.avatar-c9 { background: #2C7387; }

.instructor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.instructor-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 14px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}
.instructor-card:hover {
  transform: translateY(-2px);
  border-color: rgba(15,26,46,0.16);
  box-shadow: var(--shadow-sm);
}
.instructor-card .role {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.instructor-card .nm {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}
.instructor-card .clubs {
  font-size: 10px;
  color: var(--ink-soft);
  line-height: 1.4;
  margin-top: 2px;
}
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Prompt', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--gold-tint);
  color: var(--gold-strong);
  text-transform: uppercase;
}
.tag.r { background: rgba(194,85,43,0.12); color: var(--r); }
.tag.t { background: rgba(47,106,90,0.12); color: var(--t); }
.tag.m { background: rgba(231,200,120,0.14); color: var(--m); }
.tag.s { background: rgba(59,91,140,0.12); color: var(--s); }

/* ------- Activity cards ------- */
.activities {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.act-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}
.act-card:hover {
  transform: translateY(-2px);
  border-color: rgba(15,26,46,0.16);
  box-shadow: var(--shadow-md);
}
.act-card .tag { align-self: flex-start; }
.act-card h4 {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 20px;
  margin: 0;
  letter-spacing: -0.01em;
}
.act-card p {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.55;
}
.act-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line-2);
  font-size: 12px;
}
.act-meta dt {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.act-meta dd {
  margin: 0;
  font-family: 'Prompt', sans-serif;
  font-weight: 500;
  font-size: 14px;
  color: var(--ink);
}

/* ------- LMS ------- */
.lms-shell {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
}
.lms-lessons {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
}
.lms-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 10px;
  border-bottom: 1px solid var(--line);
}
.lms-sidebar-head strong {
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  font-weight: 600;
}
.lms-sidebar-head span {
  font-size: 11px;
  color: var(--muted);
}
.lms-progress-bar {
  height: 3px;
  background: var(--line-2);
  overflow: hidden;
  margin: -10px -10px 0;
}
.lms-progress-bar div {
  height: 100%;
  background: var(--t);
}
.lms-group {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.04);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.lms-group.open,
.lms-group.has-active {
  border-color: rgba(67, 97, 238, 0.34);
  box-shadow: 0 12px 24px rgba(67, 97, 238, 0.08);
}
.lms-group-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px 12px;
  background: transparent;
  border: none;
  color: var(--ink);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}
.lms-group-head:hover { background: rgba(244, 243, 239, 0.72); }
.lms-group-copy { min-width: 0; }
.lms-group-kicker {
  margin-bottom: 4px;
  color: var(--r);
  font-family: 'Prompt', sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.lms-group-head strong {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}
.lms-group-head span {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}
.lms-group-status {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-items: end;
  gap: 1px 8px;
  flex-shrink: 0;
  color: var(--ink);
}
.lms-group-status strong {
  font-size: 13px;
  line-height: 1;
}
.lms-group-status span {
  grid-column: 1;
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}
.lms-group-chevron {
  grid-column: 2;
  grid-row: 1 / span 2;
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.2s;
}
.lms-group-chevron.open { transform: rotate(180deg); }
.lms-group-progress {
  height: 3px;
  background: var(--line-2);
}
.lms-group-progress div {
  height: 100%;
  background: var(--brand);
}
.lms-group-panel {
  padding: 6px;
  border-top: 1px solid var(--line-2);
}
.lms-lesson {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  border-left: 3px solid transparent;
  border-radius: 7px;
  padding: 9px 10px 9px 9px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}
.lms-lesson:hover { background: var(--paper-2); }
.lms-lesson.active {
  background: color-mix(in srgb, var(--brand) 12%, var(--card));
  border-left-color: var(--brand);
}
.lms-lesson-text { flex: 1; min-width: 0; }
.lms-lesson b {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.35;
}
.lms-lesson small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}
.lms-lesson.done small { color: var(--t); }
.lms-lesson-icon { flex-shrink: 0; color: var(--muted); }
.lms-lesson.active .lms-lesson-icon,
.lms-lesson.done .lms-lesson-icon { color: var(--brand); }
.lms-player {
  min-width: 0;
}
.lesson-screen {
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--ink), var(--ink-2));
  color: #F4F5F7;
  overflow: hidden;
  position: relative;
}
.locked-video,
.locked-video video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
}
.locked-video video {
  display: block;
  object-fit: contain;
}
.locked-video-hit {
  position: absolute;
  inset: 0;
  z-index: 1;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.locked-video-play {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 3;
  width: 70px;
  height: 70px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.32);
  border-radius: 999px;
  background: rgba(15,26,46,0.78);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 18px 46px rgba(0,0,0,0.28);
}
.locked-video-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: auto auto minmax(80px, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 42px 18px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,0.78));
  color: #fff;
  font-size: 13px;
}
.locked-video-controls button {
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 8px 10px;
  cursor: pointer;
}
.locked-video-controls button:hover {
  background: rgba(255,255,255,0.2);
}
.locked-video-progress {
  height: 5px;
  padding: 9px 0;
  box-sizing: content-box;
  border-radius: 999px;
  background: rgba(255,255,255,0.26);
  background-clip: content-box;
  cursor: pointer;
  touch-action: none;
}
.locked-video-progress div {
  height: 5px;
  border-radius: inherit;
  background: #fff;
  pointer-events: none;
}
.youtube-screen iframe {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
.lesson-main {
  margin-top: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 26px;
}
.lesson-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.lesson-meta { font-size: 12px; color: var(--muted); }
.lesson-main h3 {
  font-family: 'Prompt', sans-serif;
  font-size: 21px;
  line-height: 1.3;
  margin: 14px 0 8px;
}
.lesson-desc {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}
.lesson-link {
  color: var(--accent, #4C4A7D);
  text-decoration: underline;
  font-weight: 600;
}
.lesson-link:hover {
  opacity: 0.8;
}
.complete-btn {
  margin-top: 18px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #F4F5F7;
  border-radius: 9px;
  padding: 11px 20px;
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.complete-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.complete-btn:active { transform: translateY(0); }
.complete-btn.done {
  background: var(--t);
  border-color: var(--t);
}
.lesson-divider {
  height: 1px;
  background: var(--line-2);
  margin: 22px 0;
}
.lesson-section-title {
  font-family: 'Prompt', sans-serif;
  font-size: 15px;
  margin: 0 0 14px;
}
.lesson-outcomes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lesson-outcomes li {
  position: relative;
  padding-left: 28px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}
.lesson-outcomes li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 1px;
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(47, 106, 90, 0.14);
  color: var(--t);
  font-size: 11px;
  font-weight: 700;
}
.resource-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.resource-list span {
  padding: 8px 10px;
  background: var(--paper-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 12px;
}
/* ลิงก์ดาวน์โหลดเอกสารแนบ (หน้าตัวแทน + ผู้จัดการ) */
.resource-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--paper-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}
.resource-file:hover {
  border-color: var(--t);
  background: color-mix(in srgb, var(--t) 8%, var(--paper-2));
  transform: translateY(-1px);
}
.resource-file-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(47, 106, 90, 0.14);
  color: var(--t);
  font-size: 12px;
}
.resource-file em {
  color: var(--muted);
  font-style: normal;
  font-weight: 400;
}
/* รายการไฟล์แนบในฟอร์มแอดมิน LMS */
.lms-attach-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.lms-attach-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  background: var(--paper-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  font-size: 12px;
}
.lms-attach-item.pending {
  border-style: dashed;
  border-color: var(--t);
}
.lms-attach-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lms-attach-remove {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
}
.lms-attach-remove:hover { color: var(--red); }

/* ------- Roadmap ------- */
.roadmap-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 14px;
  margin-bottom: 20px;
}
.roadmap-summary div {
  background: var(--ink);
  color: #F4F5F7;
  border-radius: 10px;
  padding: 18px 20px;
}
.roadmap-summary span {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--muted-on-dark);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.roadmap-summary strong {
  font-family: 'Prompt', sans-serif;
  font-size: 18px;
  font-weight: 600;
}
.month-roadmap {
  display: grid;
  grid-template-columns: repeat(7, minmax(220px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.month-card {
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}
.month-card:hover {
  transform: translateY(-2px);
  border-color: rgba(15,26,46,0.16);
  box-shadow: var(--shadow-md);
}
.month-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.month-step {
  display: block;
  margin-bottom: 4px;
  font-family: 'Prompt', sans-serif;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.14em;
}
.month-top h3 {
  margin: 0;
  font-family: 'Prompt', sans-serif;
  font-size: 28px;
  line-height: 1;
}
.month-top strong {
  white-space: nowrap;
  color: var(--gold-strong);
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
}
.month-phase {
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.month-card p {
  margin: 0;
  min-height: 64px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}
.month-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.month-actions {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.65;
}
.month-check {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line-2);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}
.month-check span {
  display: block;
  margin-bottom: 3px;
  color: var(--gold);
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  font-weight: 600;
}

/* ------- Pillar focus panel ------- */
.pillar-detail {
  margin-top: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 30px 26px;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 32px;
  box-shadow: var(--shadow-sm);
}
.pillar-detail h3 {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 22px;
  margin: 6px 0 12px;
}
.pillar-detail .lead {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 16px;
}
.bullet {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px dashed var(--line);
  font-size: 13px;
}
.bullet:first-of-type { border-top: 1px solid var(--line); margin-top: 8px;}
.bullet b { font-weight: 600; }
.bullet .b-icon {
  font-family: 'DM Serif Display', serif;
  font-style: italic;
  color: var(--gold);
  text-align: center;
  font-size: 14px;
}
.linked-list { display: flex; flex-direction: column; gap: 6px; }
.linked-list .li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--paper-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  font-size: 13px;
}
.linked-list .li .nm {
  font-family: 'Prompt', sans-serif;
  font-weight: 500;
}
.linked-list .li .freq {
  font-size: 11px;
  color: var(--muted);
}

/* ------- Hero diagram ------- */
.hero {
  max-width: 880px;
}

/* ------- Launch countdown ------- */
.countdown {
  margin-top: 8px;
  padding: 18px 22px;
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink-2) 100%);
  border: 1px solid rgba(217, 185, 118, 0.35);
  border-radius: 14px;
  color: #F4ECD8;
  box-shadow: 0 18px 40px -28px rgba(15, 26, 46, 0.55);
  max-width: 560px;
}
.countdown-label {
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #D9B976;
  margin-bottom: 12px;
}
.countdown-grid {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.countdown-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
}
.countdown-num {
  font-family: 'DM Serif Display', serif;
  font-size: 38px;
  line-height: 1;
  color: #F4F5F7;
  font-variant-numeric: tabular-nums;
}
.countdown-tag {
  font-family: 'Prompt', sans-serif;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted-on-dark);
  margin-top: 6px;
}
.countdown-sep {
  font-family: 'DM Serif Display', serif;
  font-size: 32px;
  line-height: 1;
  color: rgba(217, 185, 118, 0.55);
  padding-top: 2px;
}
.countdown-live .countdown-title {
  font-family: 'DM Serif Display', serif;
  font-size: 24px;
  color: #F4F5F7;
}
@media (max-width: 640px) {
  .countdown-num { font-size: 30px; }
  .countdown-sep { font-size: 24px; }
  .countdown-unit { min-width: 44px; }
}

/* ------- Misc ------- */
.divider-label {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 36px 0 18px;
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.note {
  background: var(--paper-2);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 24px;
}
.note strong { color: var(--ink); font-weight: 600; }

button.cta {
  font-family: 'Prompt', sans-serif;
  background: var(--ink);
  color: #F4F5F7;
  border: none;
  padding: 13px 22px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
button.cta:hover {
  background: var(--ink-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
button.cta:active { transform: translateY(0); }
button.cta .arrow {
  font-family: 'DM Serif Display', serif;
  font-style: italic;
  color: var(--gold-soft);
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend .sw {
  width: 10px; height: 10px;
  border-radius: 50%;
}

.app-footer {
  padding: 24px 48px 32px;
  border-top: 1px solid var(--line-2);
  color: var(--muted);
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lms-page {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper);
}
.lms-page-head {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 76px;
  padding: 14px 48px;
  background: var(--ink);
  color: #F4F5F7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--sidebar-strong);
}
.lms-page-head .brand-name { color: #F4F5F7; }
.back-link {
  color: #C7CBD2;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
}
.back-link:hover {
  color: #F4F5F7;
  border-color: var(--gold-soft);
}
.lms-page-main section.scene {
  border-bottom: none;
}

/* ===== Agent login + dashboard ===== */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 22px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 18px;
  padding: 38px 34px 30px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: block;
  width: 96px;
  border-radius: 14px;
  margin: 0 auto 20px;
}
.login-title {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 24px;
  text-align: center;
  margin: 0 0 6px;
  color: var(--ink);
}
.login-sub {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 24px;
}
.login-field { display: block; }
.login-field span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.login-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: 'Prompt', sans-serif;
  font-size: 22px;
  letter-spacing: 0.05em;
  text-align: center;
  color: var(--ink);
  background: var(--paper);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.login-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-tint);
}
.login-input.has-error { border-color: var(--red); }
.login-input[type="email"],
.login-input[type="password"],
.login-input[type="text"],
.login-input[type="date"],
.login-input.select-input {
  letter-spacing: 0;
  text-align: left;
  font-size: 16px;
}
.login-input::placeholder {
  letter-spacing: 0.2em;
  color: #C9C5BC;
  font-size: 16px;
}

.slip-input {
  height: auto;
  min-height: 56px;
  padding-block: 14px;
  letter-spacing: 0;
  font-size: 13px;
  text-align: left;
}
.register-file-hint {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}
.bank-info {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(193, 158, 95, 0.35);
  background: rgba(193, 158, 95, 0.08);
  border-radius: 12px;
}
.bank-info-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 10px;
  letter-spacing: 0.04em;
}
.bank-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  padding: 4px 0;
}
.bank-info-row + .bank-info-row {
  border-top: 1px dashed rgba(193, 158, 95, 0.2);
}
.bank-info-label {
  color: var(--muted);
  flex-shrink: 0;
}
.bank-info-value {
  color: var(--ink);
  font-weight: 500;
  text-align: right;
}
.bank-info-acct {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}
.bank-info-copy {
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.bank-info-copy:hover {
  background: var(--gold);
  color: #fff;
}
.login-error {
  margin-top: 10px;
  font-size: 13px;
  color: var(--red);
  text-align: center;
}
.login-btn {
  width: 100%;
  margin-top: 18px;
  border: none;
  background: var(--brand-strong);
  color: #fff;
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 15px;
  padding: 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.login-btn:hover {
  background: #e06d12;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(244,121,32,0.28);
}
.login-btn:active { transform: translateY(0); }
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 16px;
  color: var(--muted);
  font-size: 12px;
}
.login-divider::before, .login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-weight: 500;
  font-size: 14px;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 140ms ease;
}
.google-btn:hover { background: var(--paper); }
.google-btn:disabled { opacity: .6; cursor: default; }
.admin-only-note {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
}
.login-hint {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line-2);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.login-hint span {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.login-hint code {
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  background: var(--paper-2);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--ink-soft);
}
.login-foot {
  display: inline-flex;
}
.login-foot a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--gold);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.login-foot a:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.login-foot a::before {
  content: '→';
  font-weight: 800;
}

.main section.scene { border-bottom: none; }

.dash-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
}
.agent-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--gold-soft);
  display: grid;
  place-items: center;
  font-family: 'Prompt', sans-serif;
  font-size: 28px;
  flex: 0 0 auto;
}
.dash-hero .section-title { margin: 0 0 6px; }
.dash-hero-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}
.dash-hero-meta strong {
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
}
.kpi-status { margin: 14px 0 8px; }

.next-class {
  margin-top: 20px;
  background: var(--ink);
  color: #F4F5F7;
  border-radius: 14px;
  padding: 22px 24px;
}
.next-class-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-on-dark);
  margin-bottom: 10px;
}
.next-class-body strong {
  font-family: 'Prompt', sans-serif;
  font-size: 18px;
}
.next-class-meta {
  margin-top: 6px;
  font-size: 13px;
  color: #DDE0E5;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 560px;
}
.dash-table th {
  text-align: left;
  font-family: 'Prompt', sans-serif;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
  white-space: nowrap;
}
.dash-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-2);
  color: var(--ink-soft);
  vertical-align: middle;
}
.dash-table tbody tr:last-child td { border-bottom: none; }
.dash-table tbody tr:hover { background: var(--paper); }
.dash-table .nowrap { white-space: nowrap; }
.dash-table th.num, .dash-table td.num { text-align: right; }
.dash-table tfoot td {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  font-family: 'Prompt', sans-serif;
  color: var(--ink);
  background: var(--paper-2);
}

.schedule-next-card {
  margin-bottom: 18px;
  padding: 20px 22px;
  border-radius: 12px;
  background: var(--ink);
  color: #F4F5F7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}
.schedule-next-card span:first-child {
  display: block;
  margin-bottom: 8px;
  color: var(--muted-on-dark);
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.schedule-next-card strong {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 20px;
}
.schedule-next-card p {
  margin: 6px 0 0;
  color: #DDE0E5;
  font-size: 13px;
}
.schedule-table { min-width: 840px; }
.schedule-course strong,
.schedule-course span,
.schedule-course small {
  display: block;
}
.schedule-course strong {
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  font-weight: 600;
}
.schedule-course span {
  margin-top: 2px;
  color: var(--ink-soft);
}
.schedule-course small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.schedule-window {
  font-family: 'Prompt', sans-serif;
  color: var(--ink);
}
.schedule-zoom-btn {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  min-height: 34px;
  border-radius: 8px;
  background: #2d8cff;
  color: #fff;
  font-family: 'Prompt', sans-serif;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.schedule-zoom-btn {
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.schedule-zoom-btn:hover {
  background: #1a6fd4;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(45,140,255,0.28);
}
.schedule-zoom-btn:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
  box-shadow: none;
}
.schedule-checked {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}
.schedule-checked strong {
  color: var(--green);
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  font-weight: 600;
}
.schedule-empty {
  height: 96px;
  text-align: center;
  color: var(--muted);
}
.schedule-error {
  margin-top: 12px;
  border: 1px solid rgba(180,58,44,0.18);
  border-radius: 10px;
  background: rgba(180,58,44,0.08);
  color: var(--red);
  font-size: 13px;
  padding: 11px 14px;
}

.status-pill {
  display: inline-block;
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.status-pill.ok { background: rgba(47,106,90,0.12); color: var(--green); }
.status-pill.pending { background: var(--gold-tint); color: #9A7A1E; }
.status-pill.miss { background: rgba(180,58,44,0.12); color: var(--red); }
.status-pill.active { background: rgba(59,91,140,0.12); color: var(--s); }

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.history-item {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 16px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.history-item:hover {
  border-color: rgba(15,26,46,0.16);
  box-shadow: var(--shadow-sm);
}
.history-date {
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  color: var(--muted);
}
.history-body { display: flex; flex-direction: column; gap: 4px; }
.history-body strong {
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  color: var(--ink);
}
.history-body > span { font-size: 12px; color: var(--muted); }
.history-body .tag { align-self: flex-start; margin-bottom: 2px; }
.history-points {
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  color: var(--gold-strong);
  white-space: nowrap;
}

.profile-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  max-width: 560px;
}
.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line-2);
}
.profile-row:last-child { border-bottom: none; }
.profile-label { font-size: 13px; color: var(--muted); }
.profile-value {
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  color: var(--ink);
  text-align: right;
}
.profile-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

.sidebar-agent { margin-bottom: 12px; }
.sidebar-agent strong {
  color: #F4F5F7;
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  display: block;
}
.sidebar-agent div {
  color: var(--muted-on-dark);
  font-size: 11px;
  margin-top: 2px;
}
.logout-btn {
  width: 100%;
  border: 1px solid rgba(215,205,180,0.35);
  background: var(--ink);
  color: #C7CBD2;
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.logout-btn:hover {
  background: var(--ink-2);
  border-color: rgba(215,205,180,0.6);
  color: #F4F5F7;
}
.home-link {
  display: block;
  width: 100%;
  margin-top: 8px;
  text-align: center;
  border: 1px solid rgba(215,205,180,0.18);
  background: transparent;
  color: var(--muted-on-dark);
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  padding: 10px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.home-link:hover {
  background: rgba(215,205,180,0.06);
  border-color: var(--gold-soft);
  color: var(--gold-soft);
}

/* responsive */
@media (max-width: 1100px) {
  .app { grid-template-columns: 64px 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 64px;
    height: 100vh;
  height: 100dvh;
    padding: 16px 8px;
    gap: 14px;
    overflow-y: auto;
    transform: none;
    box-shadow: none;
    align-items: center;
  }
  .sidebar .brand { justify-content: center; }
  .sidebar .brand-logo { max-width: 36px; border-radius: 8px; }
  .sidebar .nav { gap: 4px; width: 100%; align-items: center; }
  .sidebar .nav-label { display: none; }
  .sidebar .sidebar-profile { display: none; }
  .sidebar .nav-item {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
    border-radius: 10px;
  }
  .sidebar .nav-item:hover { transform: none; }
  .sidebar .nav-item.active::before { display: none; }
  .sidebar .nav-item.active {
    background: rgba(231,200,120,0.22);
    color: #F4F5F7;
  }
  .sidebar .nav-text { display: none; }
  .sidebar .nav-icon { display: block; width: 20px; height: 20px; }
  .sidebar .sidebar-foot {
    border-top: none;
    padding: 8px 0 4px;
    margin-top: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
  .sidebar .sidebar-agent { display: none; }
  .sidebar .logout-btn,
  .sidebar .home-link {
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .mobile-overlay { display: none !important; }
  .menu-btn { display: none !important; }
  section.scene { padding: 36px 24px 24px; }
  .topbar {
    padding: 10px 16px;
    gap: 12px;
    justify-content: flex-start;
  }
  /* On tablet/mobile keep the notification bell visible but hide the
     admin-name text to save horizontal space. */
  .topbar-meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
  }
  .topbar-meta > span { display: none; }
  .crumbs {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .app-footer { padding: 24px; }
  .lms-page-head { padding: 14px 24px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .rtms-grid { grid-template-columns: repeat(2, 1fr); }
  .activities { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; gap: 28px; }
  .week-grid { grid-template-columns: 60px repeat(7, minmax(110px, 1fr)); overflow-x: auto; }
  .monthly-club-panel,
  .monthly-club-card,
  .month-picker,
  .month-picker div {
    min-width: 0;
  }
  .monthly-club-panel {
    max-width: 100%;
    overflow: hidden;
  }
  .monthly-club-card {
    width: 100%;
    overflow: hidden;
    padding: 14px;
  }
  .monthly-club-list { grid-template-columns: 1fr; }
  .month-calendar {
    width: 100%;
    grid-template-columns: repeat(7, minmax(108px, 1fr));
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }
  .month-picker { grid-template-columns: 38px minmax(0, 1fr) 38px; }
  .month-picker.current { grid-template-columns: 1fr; }
  .month-picker button { width: 38px; height: 38px; }
  .lms-shell { grid-template-columns: 1fr; }
  .lesson-screen { width: 100%; }
  h1.display { font-size: 40px; }
  .pillar-detail { grid-template-columns: 1fr; }
  /* Class cards: keep the desktop side-by-side layout on tablet & mobile, scaled down */
  .club-schedule-card {
    --club-rail: clamp(38px, 8vw, 60px);
    grid-template-columns: var(--club-rail) minmax(0, 1fr) minmax(118px, 340px);
    column-gap: clamp(8px, 2.4vw, 26px);
    row-gap: 8px;
    min-height: 0;
    min-width: 0;
    padding: clamp(12px, 3vw, 22px) clamp(11px, 2.4vw, 20px) clamp(11px, 2.4vw, 18px) 0;
    border-radius: 16px;
  }
  .club-schedule-num {
    grid-column: 1;
    grid-row: 1 / -1;
    font-size: clamp(19px, 5vw, 32px);
    padding-top: clamp(11px, 3vw, 16px);
  }
  .club-schedule-num::after { width: 20px; margin-top: 6px; }
  .club-schedule-main {
    grid-column: 2 / -1;
    grid-row: 1;
    grid-template-columns: minmax(0, 1fr) minmax(112px, 0.82fr);
    gap: clamp(8px, 2.4vw, 22px);
    align-items: start;
  }
  .club-schedule-postcol { gap: clamp(6px, 1.5vw, 10px); }
  .club-schedule-copy h3 {
    font-size: clamp(15px, 4.4vw, 27px);
    line-height: 1.14;
  }
  .club-schedule-copy p {
    font-size: clamp(11px, 3vw, 16px);
    line-height: 1.4;
  }
  .club-status-pill { padding: 4px 9px; font-size: clamp(10px, 2.6vw, 12px); }
  .club-feature-pill {
    margin-top: clamp(8px, 2vw, 12px);
    padding: 5px 9px;
    font-size: clamp(10px, 2.6vw, 12px);
  }
  .club-schedule-poster {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    aspect-ratio: 3 / 2;
    max-height: none;
    border-radius: clamp(10px, 2vw, 14px);
  }
  .club-schedule-poster img { max-height: none; }
  .club-schedule-meta {
    grid-column: 2 / -1;
    grid-row: 2;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: clamp(8px, 2vw, 10px) clamp(9px, 2vw, 14px);
  }
  .club-schedule-info {
    flex-direction: row;
    align-items: center;
    gap: clamp(7px, 1.6vw, 10px);
    padding: 0 clamp(7px, 1.6vw, 13px);
    border-right: 1px solid color-mix(in srgb, var(--club-accent) 16%, var(--line));
    border-bottom: 0;
  }
  .club-schedule-info:first-child { padding-left: 0; }
  .club-schedule-info:last-child { padding-right: 0; border-right: 0; }
  .club-mini-icon {
    width: clamp(26px, 6vw, 32px);
    height: clamp(26px, 6vw, 32px);
    border-radius: clamp(8px, 1.8vw, 10px);
  }
  .club-mini-icon svg {
    width: clamp(15px, 3.6vw, 18px);
    height: clamp(15px, 3.6vw, 18px);
  }
  .club-checkins {
    grid-column: 2 / -1;
    grid-row: 3;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: -2px;
    width: 100%;
    padding: clamp(9px, 2vw, 11px) clamp(10px, 2vw, 14px);
    border-radius: clamp(10px, 2vw, 13px);
  }
  .club-checkins-head {
    min-width: 0;
  }
  .club-checkins-head span,
  .club-schedule-info span { font-size: clamp(10px, 2.6vw, 12px); }
  .club-checkin-list {
    flex-wrap: nowrap;
    min-width: 0;
    overflow-x: auto;
    gap: clamp(7px, 1.8vw, 12px);
  }
  .club-checkin-person {
    flex: 0 0 auto;
    max-width: clamp(76px, 28vw, 118px);
    min-height: 27px;
    padding: 4px 9px;
    font-size: clamp(10px, 2.6vw, 12px);
  }
  .club-checkin-more {
    width: clamp(32px, 8vw, 40px);
    height: clamp(32px, 8vw, 40px);
    font-size: clamp(12px, 3vw, 15px);
  }
  .club-schedule-info strong {
    font-size: clamp(12px, 3vw, 16px);
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .club-schedule-owners {
    width: 100%;
    justify-content: flex-end;
    gap: 6px;
  }
  .club-schedule-owners .avatar-stack {
    display: flex;
    flex-wrap: nowrap;
    gap: clamp(4px, 1.5vw, 8px);
    justify-content: flex-end;
  }
  .club-schedule-owners > span {
    margin-bottom: 0;
    font-size: clamp(9px, 2.4vw, 12px);
  }
  .club-schedule-owners .avatar {
    gap: 4px;
  }
  .club-schedule-owners .avatar-circle {
    width: clamp(24px, 6vw, 32px);
    height: clamp(24px, 6vw, 32px);
    font-size: clamp(10px, 2.6vw, 13px);
  }
  .club-schedule-owners .avatar-name { display: none; }
  .club-schedule-actions {
    right: clamp(10px, 3vw, 20px);
    bottom: clamp(10px, 3vw, 16px);
    gap: clamp(5px, 1.6vw, 8px);
  }
  .club-schedule-card .schedule-zoom-btn {
    min-width: clamp(56px, 16vw, 78px);
    min-height: clamp(28px, 7vw, 34px);
    font-size: clamp(10px, 2.6vw, 12px);
  }
  .class-countdown {
    height: clamp(28px, 7vw, 34px);
    padding: 0 clamp(7px, 2.2vw, 12px);
    gap: 5px;
  }
  .class-countdown-label { display: none; }
  .class-countdown-time { font-size: clamp(13px, 3.4vw, 16px); }
  .poster-modal-backdrop { padding: 14px; }
  .poster-modal-close { top: 8px; right: 8px; }
  .history-item { grid-template-columns: 1fr; gap: 8px; }
  .history-end { justify-self: start; }
  .profile-value { text-align: left; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-head { padding: 20px 16px 16px; }
  .tab-row { padding: 0 16px 12px; }
}

/* On small phones the meta cells stack icon-above-text so 3 columns still fit */
@media (max-width: 560px) {
  .club-schedule-info {
    flex-direction: column;
    align-items: flex-start;
    gap: clamp(3px, 1.2vw, 6px);
    padding: 0 clamp(5px, 1.4vw, 10px);
  }
}

/* ======= Admin Panel ======= */

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,26,46,0.55);
  backdrop-filter: blur(2px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  position: relative;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line-2);
  font-size: 17px;
  font-weight: 600;
}
.modal-title {
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
  color: var(--ink);
}
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 24px;
  color: var(--muted);
  padding: 0 4px;
  line-height: 1;
  min-width: 32px;
  min-height: 32px;
}
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 20px 24px 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }

/* Form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sch-day-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.sch-day-pill {
  border: 1.5px solid var(--line); background: #fff; color: var(--muted);
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.sch-day-pill.on { border-color: var(--brand-strong); background: var(--brand-strong); color: #fff; }
.form-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.form-field.full { grid-column: 1 / -1; }
.form-input {
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  background: var(--paper);
  outline: none;
  width: 100%;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.form-input:hover { border-color: rgba(15,26,46,0.18); }
.form-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--gold-tint);
  background: var(--card);
}
.form-input:disabled { opacity: 0.5; cursor: not-allowed; }
.form-error { font-size: 13px; color: var(--red); margin-top: 6px; }

/* Admin toolbar */
.admin-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.search-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.search-input:hover { border-color: rgba(15,26,46,0.18); }
.search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--gold-tint);
}

/* Action buttons */
.action-btns { display: flex; gap: 6px; }
.btn-edit, .btn-delete, .btn-approve {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}
.btn-edit { border: 1.5px solid var(--brand); background: none; color: var(--brand); }
.btn-edit:hover { background: var(--brand-strong); color: #fff; }
.btn-delete { border: 1.5px solid var(--red); background: none; color: var(--red); }
.btn-delete:hover { background: var(--red); color: #fff; }
.btn-approve { border: 1.5px solid var(--green); background: none; color: var(--green); }
.btn-approve:hover { background: var(--green); color: #fff; }
.btn-outline {
  padding: 10px 18px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: none;
  color: var(--ink-soft);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}
.btn-outline:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--paper-2);
}
.admin-textarea {
  min-height: 92px;
  resize: vertical;
}
.admin-schedule-table { min-width: 720px; }

.attendance-toolbar .form-input {
  max-width: 320px;
}
.attendance-grid {
  display: grid;
  gap: 22px;
}
/* Grid items default to min-width:auto, which lets the 760px-min tables blow
   out the track past the viewport (then .main overflow-x:hidden clips it and
   kills horizontal scroll). min-width:0 lets each .table-wrap shrink to the
   column and scroll its wide table internally instead. */
.attendance-grid > * {
  min-width: 0;
}
.attendance-grid .table-wrap {
  max-width: 100%;
}
.attendance-grid .member-section h3 {
  margin: 0 0 12px;
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-size: 16px;
}
.attendance-table {
  min-width: 760px;
}
.attendance-code {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

/* Admin overview */
.overview-page .section-head { margin-bottom: 20px; }
.overview-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.overview-kpis > div {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.overview-kpis span,
.overview-kpis small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.overview-kpis strong {
  display: block;
  margin: 4px 0 2px;
  font-family: 'Prompt', sans-serif;
  font-size: 24px;
  line-height: 1.2;
  color: var(--ink);
}
.overview-toolbar { align-items: stretch; }
.overview-select {
  width: auto;
  min-width: 160px;
  padding: 10px 12px;
}
.overview-table { min-width: 1080px; }
.overview-table td { vertical-align: top; }
.overview-agent {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.overview-agent strong {
  display: block;
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
}
.overview-agent span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}
.overview-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 340px;
}
.overview-chip {
  max-width: 220px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.overview-chip.ok {
  background: rgba(47,106,90,0.10);
  color: var(--green);
}
.overview-chip.more {
  background: rgba(15,26,46,0.06);
  color: var(--muted);
}
.overview-chip small {
  display: block;
  margin-top: 2px;
  color: inherit;
  font-size: 10px;
  opacity: 0.72;
}
.overview-progress {
  width: 86px;
  height: 6px;
  margin-top: 7px;
  margin-left: auto;
  border-radius: 999px;
  background: var(--line-2);
  overflow: hidden;
}
.overview-progress > div {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}
.overview-table td.num small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}
.overview-mini-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
}
.overview-line {
  display: block;
  max-width: 220px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.overview-line small {
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
}
.overview-more-text,
.muted-cell {
  color: var(--muted);
  font-size: 12px;
}
.overview-card-list { display: none; }
.overview-agent-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.overview-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.overview-score {
  flex: 0 0 auto;
  text-align: right;
}
.overview-score strong {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 18px;
  color: var(--ink);
}
.overview-score span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.overview-mobile-progress {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}
.overview-mobile-progress .overview-progress {
  width: 100%;
  margin: 6px 0 0;
}
.overview-card-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.overview-card-stats > div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
.overview-card-stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.overview-card-stats strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-size: 15px;
  line-height: 1.2;
}
.overview-card-block {
  margin-top: 12px;
}
.overview-card-block b,
.overview-card-grid b {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 12px;
  font-family: 'Prompt', sans-serif;
}
.overview-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

/* Clickable rows */
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: var(--paper-2); }
.row-pending td { background: #fffbf0; }
.row-pending:hover td { background: #fff5dc; }

/* Detail panel */
.detail-panel { padding: 0; }
.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 8px;
}
.back-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  padding: 6px 0;
  white-space: nowrap;
  font-family: inherit;
  flex-shrink: 0;
  transition: color 0.15s;
}
.back-btn:hover { color: var(--ink); }

/* Tab row */
.tab-row { display: flex; gap: 4px; padding: 16px 32px; }
.admin-slip-panel {
  margin: 0 32px 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 260px);
  align-items: center;
  gap: 18px;
  background: var(--paper-2);
}
.admin-slip-panel strong,
.admin-slip-panel span {
  display: block;
}
.admin-slip-panel strong {
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-size: 15px;
}
.admin-slip-panel span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.admin-slip-panel a {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.admin-slip-panel img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
}
@media (max-width: 760px) {
  .admin-slip-panel {
    margin: 0 16px 16px;
    grid-template-columns: 1fr;
  }
}

.admin-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--ink);
  color: #F4ECD8;
  font-family: 'Prompt', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  vertical-align: middle;
}

/* ------- Finance panel: agent payment slips table ------- */
.schedule-past-row { opacity: 0.55; }
.schedule-past-tag {
  display: inline-block;
  margin-left: 8px;
  font-size: 10px;
  font-weight: 600;
  color: #8A4D14;
  background: #fff1e0;
  border: 1px solid #E8B47A;
  border-radius: 6px;
  padding: 1px 6px;
  vertical-align: middle;
}
.schedule-admin-tag {
  display: inline-block;
  margin-left: 8px;
  font-size: 10px;
  font-weight: 600;
  color: #5B21B6;
  background: #F1ECFE;
  border: 1px solid #C4B5FD;
  border-radius: 6px;
  padding: 1px 6px;
  vertical-align: middle;
}
.schedule-title-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.schedule-poster-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #ddd;
  flex-shrink: 0;
  display: block;
}
.schedule-poster-link {
  display: inline-block;
  margin-top: 6px;
}
/* FinancePanel uses .admin-panel (not the .scene wrapper every other panel
   uses), which has no padding. Its inner rows already carry their own 0 32px
   horizontal padding, but the top edge and the SectionHead had none — so the
   header text butted against the panel/sidebar edge. Match the scene inset. */
.admin-panel { padding: 48px 0 32px; }
.admin-panel > .section-head { padding: 0 32px; }

.finance-summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 0 32px 24px;
}
.finance-summary-card {
  background: var(--paper);
  border: 1.5px solid var(--line-2);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.finance-summary-card span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.finance-summary-card strong { font-size: 22px; font-weight: 700; color: var(--ink); font-family: 'Prompt', sans-serif; }
.finance-summary-card small { font-size: 11px; color: var(--muted); }
.finance-summary-card.highlight { border-color: var(--brand); background: var(--gold-tint); }
.finance-summary-card.highlight strong { color: var(--brand); }
.finance-summary-card.ok { border-color: #A9D4BF; background: #EAF4EF; }
.finance-summary-card.ok strong { color: #2F6B47; }
.finance-summary-card.missing { border-color: #E8B47A; background: #fff8f0; }
.finance-summary-card.missing strong { color: #8A4D14; }
@media (max-width: 760px) {
  .finance-summary-row { grid-template-columns: repeat(2, 1fr); padding: 0 16px 16px; }
}
.finance-section {
  margin-bottom: 26px;
}
.finance-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 32px 12px;
}
.finance-section-head h3 {
  margin: 0;
  font-family: 'Prompt', sans-serif;
  font-size: 20px;
  color: var(--ink);
}
.finance-section-head span {
  font-size: 13px;
  color: var(--muted);
}
.finance-table-wrap {
  margin: 0 32px 32px;
}
.finance-table {
  min-width: 720px;
}
.finance-table th,
.finance-table td {
  vertical-align: middle;
}
.finance-agent-cell strong {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  color: var(--ink);
}
.finance-agent-cell span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}
.finance-slip-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.finance-slip-status.ok {
  background: rgba(47,106,90,0.10);
  color: var(--green);
}
.finance-slip-status.missing {
  background: rgba(148,137,108,0.14);
  color: var(--muted);
}
.finance-missing-row td {
  background: var(--paper-2);
}
.finance-slip-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}
.finance-slip-link:hover span {
  text-decoration: underline;
}
.finance-slip-link img {
  display: block;
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}
.finance-empty-inline {
  color: var(--muted);
  font-size: 12px;
}
.finance-slip-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.finance-slip-upload-btn {
  padding: 4px 12px;
  border-radius: 7px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.finance-slip-upload-btn:hover { background: var(--ink); color: #F4F5F7; }
.finance-slip-upload-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.finance-slip-err { font-size: 11px; margin: 0; }
@media (max-width: 760px) {
  .admin-panel { padding: 28px 0 24px; }
  .admin-panel > .section-head { padding: 0 16px; }
  .finance-slip-cell { align-items: flex-end; }
  .finance-section { margin-bottom: 18px; }
  .finance-section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    padding: 0 16px 10px;
  }
  .finance-table-wrap {
    margin: 0 16px 16px;
    overflow: visible;
  }
  .finance-table {
    min-width: 0;
    border-spacing: 0 8px;
  }
  .finance-table thead {
    display: none;
  }
  .finance-table,
  .finance-table tbody,
  .finance-table tr,
  .finance-table td {
    display: block;
    width: 100%;
  }
  .finance-table tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }
  .finance-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
  }
  .finance-table td:last-child {
    border-bottom: 0;
  }
  .finance-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 11px;
  }
  .finance-table td:first-child {
    align-items: flex-start;
  }
  .finance-table td:first-child::before {
    display: none;
  }
  .finance-slip-link img {
    width: 44px;
    height: 44px;
  }
}
.tab-btn {
  padding: 8px 20px;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}
.tab-btn:hover { border-color: var(--ink-soft); color: var(--ink); }
.tab-btn.active { border-color: var(--brand); color: var(--brand); background: var(--gold-tint); font-weight: 500; }

/* Loading */
.loading-msg { text-align: center; padding: 48px; color: var(--muted); font-size: 15px; }

/* Upload overlay */
.upload-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.92);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  border-radius: inherit; z-index: 20;
}
.upload-spinner {
  width: 52px; height: 52px;
  border: 5px solid #e5e7eb;
  border-top-color: var(--brand, #2563eb);
  border-radius: 50%;
  animation: lms-spin 0.75s linear infinite;
}
@keyframes lms-spin { to { transform: rotate(360deg); } }
.upload-overlay-title {
  font-size: 16px; font-weight: 700; color: var(--brand, #2563eb);
}
.upload-overlay-sub {
  font-size: 13px; color: var(--muted); margin-top: -10px;
}

/* LMS module section */
.lms-module-block { margin-bottom: 28px; }
.lms-module-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-radius: 10px 10px 0 0;
  background: var(--surface2, #f3f4f6);
  border: 1px solid var(--line-2, #e5e7eb);
  border-bottom: none; gap: 10px; flex-wrap: wrap;
}
.lms-module-header-left { display: flex; align-items: center; gap: 10px; }
.lms-module-name { font-weight: 700; font-size: 15px; }
.lms-module-count {
  font-size: 12px; color: var(--muted);
  background: var(--card, #fff); padding: 2px 8px;
  border-radius: 10px; border: 1px solid var(--line-2, #e5e7eb);
}
.lms-module-block .table-wrap {
  border-radius: 0 0 10px 10px; border: 1px solid var(--line-2, #e5e7eb);
  overflow: hidden;
}
.lms-module-block .dash-table { border-radius: 0; }

/* Register link */
.login-register-link { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.link-btn { background: none; border: none; cursor: pointer; color: var(--brand); font-size: 14px; font-family: inherit; font-weight: 500; padding: 0; text-decoration: underline; }
.link-btn:hover { opacity: 0.8; }

/* ===== Admin member cards (mobile) ===== */
.member-page {
  padding-top: 30px;
}
.member-page .section-head {
  margin-bottom: 18px;
  gap: 16px;
}
.member-page .eyebrow {
  font-size: 10px;
  margin-bottom: 7px;
}
.member-page h2.section-title {
  font-size: 23px;
  margin-bottom: 4px;
}
.member-page .section-sub {
  font-size: 13px;
  line-height: 1.45;
}
.member-toolbar {
  gap: 8px;
  margin-bottom: 14px;
}
.member-toolbar .search-input {
  padding: 7px 10px;
  font-size: 12px;
  min-width: 180px;
}
.member-toolbar .btn-edit,
.member-toolbar .login-btn {
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 12px;
}
.admin-table-desktop { display: block; }
.admin-card-list     { display: none;  }
.member-section {
  margin-bottom: 18px;
}
.member-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px 7px;
}
.member-section-head h3 {
  margin: 0;
  font-family: 'Prompt', sans-serif;
  font-size: 16px;
  color: var(--ink);
}
.member-section-head span {
  font-size: 11px;
  color: var(--muted);
}
.member-section .table-wrap {
  border-radius: 8px;
}
.member-section .dash-table {
  font-size: 12px;
  min-width: 820px;
}
.member-section .dash-table th {
  font-size: 9.5px;
  letter-spacing: 0.07em;
  padding: 8px 10px;
}
.member-section .dash-table td {
  padding: 8px 10px;
}
.member-section .status-pill {
  font-size: 10px;
  padding: 2px 7px;
}
.member-section .admin-tag {
  font-size: 9px;
  padding: 2px 5px;
}
.member-section .action-btns {
  gap: 4px;
}
.member-section .btn-edit,
.member-section .btn-delete,
.member-section .btn-approve {
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
}

@media (max-width: 760px) {
  .attendance-toolbar .form-input,
  .attendance-toolbar .btn-outline {
    width: 100%;
    max-width: none;
  }
  .overview-page { padding: 16px 0 32px; }
  .overview-page .section-head,
  .overview-page .admin-toolbar,
  .overview-page .form-error,
  .overview-page .loading-msg {
    margin-left: 16px;
    margin-right: 16px;
  }
  .overview-page h2.section-title { font-size: 21px; }
  .overview-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0 16px 14px;
  }
  .overview-kpis > div { padding: 12px; }
  .overview-kpis strong { font-size: 20px; }
  .overview-toolbar {
    gap: 8px;
    margin-bottom: 14px;
  }
  .overview-select,
  .overview-toolbar .search-input,
  .overview-toolbar .btn-edit {
    width: 100%;
    min-width: 0;
  }
  .overview-table-desktop { display: none; }
  .overview-card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 16px;
  }
  .overview-chip-list { max-width: none; }
  .overview-chip-list.full {
    display: grid;
    grid-template-columns: 1fr;
  }
  .overview-chip {
    max-width: 100%;
    white-space: normal;
  }
  .overview-chip-list.full .overview-chip {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    line-height: 1.45;
  }
  .overview-card-grid { grid-template-columns: 1fr; }
  .overview-mini-list.full {
    gap: 6px;
  }
  .overview-mini-list.full .overview-line {
    padding: 7px 9px;
    border-radius: 8px;
    background: var(--paper);
    border: 1px solid var(--line);
  }
  .overview-line {
    max-width: 100%;
    white-space: normal;
  }
  .overview-line small {
    display: inline-block;
    margin-top: 2px;
  }
  .member-page { padding-top: 16px; }
  .member-page .section-head { margin-bottom: 12px; }
  .member-page h2.section-title { font-size: 21px; }
  .member-toolbar {
    gap: 6px;
    margin-bottom: 12px;
  }
  .admin-table-desktop { display: none; }
  .admin-card-list     { display: flex; flex-direction: column; gap: 8px; }
  .member-section {
    margin-bottom: 14px;
    padding: 0 16px;
  }
  .member-section-head {
    padding: 0 0 8px;
  }
  .schedule-next-card {
    align-items: flex-start;
    flex-direction: column;
  }
  .schedule-next-card strong { font-size: 18px; }
}

.admin-member-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}
.admin-member-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.admin-member-card.card-pending { background: #fffbf0; border-color: #f0d080; }

/* คำขออนุมัติ — กล่องเด่นด้านบนสุดของหน้าจัดการสมาชิก */
.member-section-pending {
  background: #fff9ec;
  border: 1.5px solid #f0d080;
  border-radius: 12px;
  padding: 14px 0 6px;
  margin-bottom: 22px;
}
.member-section-pending .member-section-head h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #9a6b00;
}
.member-section-pending .member-section-head span {
  color: #9a6b00;
  font-weight: 600;
}
.member-section-pending .pending-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--orange, #e8821e);
  box-shadow: 0 0 0 4px rgba(232, 130, 30, 0.18);
  animation: pending-pulse 1.6s ease-in-out infinite;
}
@keyframes pending-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(232, 130, 30, 0.22); }
  50% { box-shadow: 0 0 0 6px rgba(232, 130, 30, 0.05); }
}
.member-section-pending .admin-member-card { background: #fff; }

.amc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 9px;
  padding: 10px 12px 8px;
}
.amc-identity {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.amc-identity strong {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.amc-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}
.amc-sub code {
  font-family: monospace;
  font-weight: 600;
  color: var(--ink-soft);
}
.amc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line-2);
  background: var(--paper);
}
.amc-date { font-size: 11px; color: var(--muted); }

/* ===== Schedule / LMS mobile cards — reuse .admin-member-card shell (โชว์ ≤760px) ===== */
.amc-idtext { min-width: 0; flex: 1; }
.sched-card, .lms-lesson-card { cursor: default; }
.sched-card:hover, .lms-lesson-card:hover { transform: none; box-shadow: none; border-color: var(--line); }
.lms-lesson-card .amc-identity { align-items: flex-start; }
.sched-card .amc-identity strong,
.lms-lesson-card .amc-identity strong {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sched-card .amc-sub,
.lms-lesson-card .amc-sub { flex-wrap: wrap; row-gap: 4px; }
.amc-note-line {
  padding: 0 12px 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.admin-card-empty {
  padding: 22px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
/* ▲▼ ปุ่มจัดลำดับ (แทน drag-to-reorder บนสัมผัส) */
.lms-move-btns {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}
.lms-move-btn {
  width: 36px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--line-2);
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  font-size: 11px;
  cursor: pointer;
  line-height: 1;
}
.lms-move-btn:disabled { opacity: 0.35; cursor: default; }
.lms-move-btn:not(:disabled):active { background: var(--gold-tint); }
/* module reorder: ใช้ drag บน desktop, ปุ่ม ▲▼ บนมือถือ */
.lms-module-move { display: none; }

/* ===== Agent avatar (photo support) ===== */
.agent-avatar {
  position: relative;
  overflow: hidden;
}
.agent-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Avatar upload widget */
.avatar-upload-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.cartoon-picker {
  width: 100%;
  border-top: 1px solid var(--line-2);
  padding-top: 14px;
  margin-top: 4px;
}
.cartoon-picker-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.cartoon-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.cartoon-avatar-btn {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.1s;
}
.cartoon-avatar-btn img { width: 100%; height: 100%; display: block; border-radius: 50%; }
.cartoon-avatar-btn:hover { border-color: var(--brand); transform: scale(1.06); }
.cartoon-avatar-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.avatar-upload-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.avatar-upload-btn {
  padding: 8px 16px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.avatar-upload-btn:hover { background: var(--ink); color: #F4F5F7; }
.avatar-upload-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.avatar-upload-hint { font-size: 11px; color: var(--muted); }
.admin-avatar-upload {
  gap: 12px;
  margin-top: 12px;
}
.admin-avatar-upload .avatar-upload-btn {
  padding: 6px 12px;
  font-size: 12px;
}

/* APE Sales Card */
.ape-sales-card {
  margin-top: 20px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  background: var(--card);
}
.ape-sales-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}
.ape-sales-header strong { font-size: 15px; }
.ape-sales-sub { font-size: 12px; color: var(--muted); }
.ape-stat-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.ape-stat {
  flex: 1;
  min-width: 100px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ape-stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.ape-stat strong { font-size: 20px; font-family: 'Prompt', sans-serif; }
.ape-stat em { font-size: 11px; color: var(--muted); font-style: normal; }
.ape-form-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.ape-form-row .form-input { flex: 1; min-width: 120px; }
.ape-date-field {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ape-date-field span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.ape-date-field .form-input {
  width: 100%;
}
.ape-save-btn {
  width: auto !important;
  padding: 10px 20px !important;
  white-space: nowrap;
  flex-shrink: 0;
}
.proof-upload-btn {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 10px 14px;
  border: 1.5px solid var(--brand);
  border-radius: 8px;
  background: var(--card);
  color: var(--brand);
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.proof-upload-btn:hover { background: var(--gold-tint); }
.proof-upload-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.activity-proof-link {
  display: inline-flex;
  margin-left: 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
}

/* My Goals / Dreams */
.goals-card {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.goals-block {
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  background: var(--card);
}
.goals-block-head {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 14px;
}
.goals-money-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.goals-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  flex: 1;
  min-width: 200px;
}
.goals-money-input { position: relative; }
.goals-money-input .form-input {
  padding-right: 96px;
  font-family: 'Prompt', sans-serif;
}
.goals-money-input em {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-style: normal;
  color: var(--muted);
  pointer-events: none;
}
.goals-textarea {
  min-height: 72px;
  resize: vertical;
  line-height: 1.6;
}
.goals-timeline {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.goals-year {
  align-self: flex-start;
  padding: 3px 13px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.goals-save-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}
.goals-saved { font-size: 13px; color: var(--green); font-weight: 600; }
.goals-save-btn {
  width: auto !important;
  padding: 11px 28px !important;
  flex-shrink: 0;
}

/* Dream summary view (read-only) */
.dream-summary { gap: 20px; }
.dream-hero {
  border-radius: 16px;
  padding: 28px 24px;
  background: linear-gradient(135deg, var(--sidebar) 0%, var(--sidebar-strong) 100%);
  color: #F4F5F7;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.dream-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 0%, rgba(244,121,32,0.18), transparent 55%);
  pointer-events: none;
}
.dream-hero-eyebrow {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-soft);
  margin-bottom: 8px;
  position: relative;
}
.dream-hero-title {
  margin: 0;
  font-family: 'Prompt', sans-serif;
  font-size: 26px;
  font-weight: 600;
  color: #F4F5F7;
  position: relative;
}
.dream-hero-sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: #DDE0E5;
  position: relative;
}
.dream-block { background: var(--card); }
.dream-money-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.dream-stat {
  flex: 1;
  min-width: 200px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.dream-stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.dream-stat-value {
  font-family: 'Prompt', sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.dream-stat-value em {
  font-style: normal;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
}
.dream-wish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.dream-wish-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper-2);
  display: flex;
  flex-direction: column;
}
.dream-wish-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--line-2);
}
.dream-wish-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.dream-wish-body { padding: 14px 16px; }
.dream-wish-title {
  font-family: 'Prompt', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 10px;
}
.dream-wish-fields {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 13px;
}
.dream-wish-fields dt {
  color: var(--muted);
  font-weight: 400;
}
.dream-wish-fields dd {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
}
.dream-timeline {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dream-timeline-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.dream-timeline-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
  white-space: pre-wrap;
}
.dream-edit-btn {
  background: transparent !important;
  color: var(--ink) !important;
  border: 1.5px solid var(--ink) !important;
}
.dream-edit-btn:hover {
  background: var(--ink) !important;
  color: #F4F5F7 !important;
}

/* Wish items picker */
.wish-empty {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
}
.wish-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.wish-list:not(:empty) { margin-bottom: 14px; }
.wish-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--bg);
}
.wish-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.wish-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.wish-remove {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.wish-remove:hover { border-color: var(--red); color: var(--red); }
.wish-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.wish-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
}
.wish-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.wish-add-btn {
  padding: 8px 14px;
  border: 1.5px dashed var(--line);
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, border-style 0.15s;
}
.wish-add-btn:hover {
  border-style: solid;
  border-color: var(--brand);
  color: var(--brand);
}
.wish-image-field { margin-bottom: 12px; }
.wish-image-add {
  width: 100%;
  padding: 22px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.wish-image-add:hover { border-color: var(--brand); color: var(--brand); }
.wish-image-add:disabled { opacity: 0.6; cursor: default; }
.wish-image-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
}
.wish-image-wrap img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
}
.wish-image-actions {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 6px;
}
.wish-image-actions button {
  padding: 5px 12px;
  border-radius: 7px;
  border: none;
  background: rgba(15, 26, 46, 0.82);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.wish-image-actions button:hover { background: rgba(15, 26, 46, 0.96); }
.wish-image-actions button:disabled { opacity: 0.6; cursor: default; }

/* Admin read-only goals view */
/* ---- My Money Need (team view) ---- */
.money-need-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 0 24px;
}
.money-need-card {
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  overflow: hidden;
}
.money-need-card.open { border-color: var(--orange); }
.money-need-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.money-need-row:hover { background: var(--bg); }
.money-need-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.money-need-id strong { font-size: 15px; color: var(--ink); }
.money-need-id span { font-size: 12px; color: var(--muted); }
.money-need-figs {
  display: flex;
  gap: 22px;
  margin-left: auto;
  flex-wrap: wrap;
}
.money-need-figs > div { display: flex; flex-direction: column; gap: 2px; text-align: right; }
.money-need-figs span { font-size: 11px; color: var(--muted); }
.money-need-figs strong { font-size: 16px; font-family: 'Prompt', sans-serif; color: var(--ink); }
.money-need-empty-tag {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.money-need-caret { font-size: 11px; color: var(--muted); }
.money-need-card .admin-goals { padding: 4px 16px 18px; }
.money-need-card .mn-form { padding: 4px 16px 18px; }
/* มือถือ: หยุดบีบคอลัมน์ชื่อ (unit ตัดทีละตัวอักษร) — ดันตัวเลขลงบรรทัดใหม่เต็มความกว้าง */
@media (max-width: 640px) {
  .money-need-row { flex-wrap: wrap; align-items: center; row-gap: 10px; }
  .money-need-id { flex: 1 1 auto; min-width: 0; }
  .money-need-id span { white-space: normal; overflow-wrap: anywhere; }
  .money-need-figs {
    order: 5;              /* ดันไปบรรทัดใหม่ (id/tag/caret คงอยู่บรรทัดแรก) */
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
    gap: 28px;
    padding-left: 52px;    /* จัดตัวเลขให้ตรงกับข้อความ (เลี่ยงใต้ avatar) */
  }
  .money-need-figs > div { text-align: left; }
}
/* read-only worksheet (manager/admin) — layout เดิม แต่เรียบเหมือนกรอกลงกระดาษ */
.mn-readonly { gap: 4px; }
.mn-readonly .mn-card { background: transparent; border: none; border-radius: 0; padding: 10px 2px 14px; border-bottom: 1px solid var(--line); }
.mn-readonly .mn-card:last-of-type { border-bottom: none; }
.mn-readonly .mn-card-head { font-size: 14px; color: var(--ink); margin-bottom: 10px; padding-bottom: 5px; border-bottom: 1.5px solid var(--ink); }
.mn-readonly input { background: transparent; border: none; border-bottom: 1px dotted var(--ink-soft, #c2c2cc); border-radius: 0; padding: 2px 2px; cursor: default; pointer-events: none; color: var(--ink); }
.mn-readonly .mn-amt input { text-align: right; }
.mn-readonly .mn-total { border-top: 1.5px solid var(--ink); }
.mn-readonly .mn-total strong { color: var(--ink); font-size: 18px; }
.mn-readonly .mn-conv-out > strong,
.mn-readonly .mn-conv-cell > strong { color: var(--ink); }
.mn-readonly .mn-arrow { color: var(--ink); }
.mn-readonly .mn-funnel-cell { background: transparent; border: 1px solid var(--line); border-radius: 6px; }
.mn-readonly .mn-funnel-cell strong { color: var(--ink); }
.mn-readonly .mn-weekly { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); border-radius: 6px; }
.mn-readonly .mn-weekly-title { opacity: 1; }
.mn-readonly .mn-weekly-nums strong { color: var(--ink); }
.mn-readonly .mn-colon { color: var(--ink-soft, #c2c2cc); opacity: 1; }
.mn-readonly .mn-footer { border-top: 1px dashed var(--line); padding-top: 12px; }

.mn-print-actions { display: flex; justify-content: flex-end; margin-bottom: 4px; }
.mn-print-btn { font-size: 13px; }

/* พิมพ์เฉพาะ worksheet — ซ่อน UI อื่นทั้งหมด แล้วจัดเป็นกระดาษเต็มหน้า */
@media print {
  @page { margin: 14mm; }
  body.printing-mn * { visibility: hidden; }
  body.printing-mn .mn-print-target,
  body.printing-mn .mn-print-target * { visibility: visible; }
  body.printing-mn .mn-print-target {
    position: absolute; left: 0; top: 0; width: 100%; padding: 0; margin: 0;
  }
  body.printing-mn .mn-print-actions { display: none !important; }
  /* บังคับให้ออกมาเป็นกระดาษเรียบ (ใช้กับฟอร์มตัวแทนตอนพิมพ์ด้วย) */
  body.printing-mn .mn-print-target .mn-card { background: transparent !important; border: none !important; box-shadow: none; padding: 8px 0 12px; }
  body.printing-mn .mn-print-target .mn-card-head { border-bottom: 1.5px solid #000; color: #000; }
  body.printing-mn .mn-print-target input { border: none !important; border-bottom: 1px dotted #999 !important; background: transparent !important; color: #000 !important; -webkit-print-color-adjust: exact; }
  body.printing-mn .mn-print-target .mn-total { border-top: 1.5px solid #000; }
  body.printing-mn .mn-print-target .mn-total strong,
  body.printing-mn .mn-print-target .mn-conv-cell > strong,
  body.printing-mn .mn-print-target .mn-funnel-cell strong { color: #000 !important; }
  body.printing-mn .mn-print-target .mn-funnel-cell { background: transparent !important; border: 1px solid #999; }
  body.printing-mn .mn-print-target .mn-weekly { background: transparent !important; color: #000 !important; border: 1.5px solid #000; }
  body.printing-mn .mn-print-target .mn-weekly-nums strong,
  body.printing-mn .mn-print-target .mn-weekly-title,
  body.printing-mn .mn-print-target .mn-colon { color: #000 !important; }
}

/* ---- ปุ่มพิมพ์ / PDF ประจำหน้า admin (PagePrintButton ใน components.jsx) ---- */
.page-print-btn { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; white-space: nowrap; flex: none; }
.page-print-btn svg { width: 15px; height: 15px; }
/* หัว/ท้ายรายงาน + ก้อน print-only — โผล่เฉพาะตอนสั่งพิมพ์ */
.print-head, .print-foot, .print-only { display: none; }

/* พิมพ์ทั้งหน้า (.scene ที่ถูกทำเครื่องหมาย .print-target) เป็นรายงาน A4 ขาวสะอาด */
@media print {
  body.printing-page * { visibility: hidden; }
  body.printing-page .print-target,
  body.printing-page .print-target * { visibility: visible; }
  body.printing-page .print-target {
    position: absolute; left: 0; top: 0; width: 100%; margin: 0; padding: 0 0 40px;
    background: #fff; color: #000;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  /* ซ่อนเครื่องมือบนจอ — เหลือแต่เนื้อรายงาน */
  body.printing-page .print-target .no-print,
  body.printing-page .print-target .sales-admin-toolbar,
  body.printing-page .print-target .admin-toolbar,
  body.printing-page .print-target .attendance-toolbar,
  body.printing-page .print-target .sales-agent-chip,
  body.printing-page .print-target .sales-period-range,
  body.printing-page .print-target .ts-seg,
  body.printing-page .print-target .ts-target-controls,
  body.printing-page .print-target .ts-target-msg,
  body.printing-page .print-target .wa-std-card,
  body.printing-page .print-target .wa-trend-link,
  body.printing-page .print-target .mn-print-actions,
  body.printing-page .print-target .money-need-caret,
  body.printing-page .print-target .ts-c-caret,
  body.printing-page .print-target .link-btn { display: none !important; }
  /* หัวรายงานมาตรฐานแทนหัวข้อบนจอ */
  body.printing-page .print-target .section-head { display: block; margin: 0 0 16px; }
  body.printing-page .print-target .section-head > div:first-child { display: none; }
  body.printing-page .print-target .print-head {
    display: flex; justify-content: space-between; align-items: flex-end; gap: 18px;
    border-bottom: 2px solid #000; padding-bottom: 10px;
  }
  body.printing-page .print-target .print-head-id { display: flex; flex-direction: column; gap: 2px; }
  body.printing-page .print-target .print-head-brand { font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); }
  body.printing-page .print-target .print-head-title { font-family: 'Prompt', sans-serif; font-size: 21px; color: #000; line-height: 1.25; }
  body.printing-page .print-target .print-head-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-size: 10.5px; color: #444; text-align: right; }
  /* ท้ายกระดาษ (position:fixed = ติดทุกหน้าตอนพิมพ์) */
  body.printing-page .print-target .print-foot {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; justify-content: space-between;
    font-size: 9.5px; color: #777; border-top: 1px solid #bbb; padding-top: 4px; background: #fff;
  }
  body.printing-page .print-target .print-only { display: block; break-inside: avoid; }
  /* ถอดเงา + กันการ์ด/แถว/กราฟถูกหั่นกลางหน้ากระดาษ */
  body.printing-page .print-target .ts-card,
  body.printing-page .print-target .ts-kpis,
  body.printing-page .print-target .ts-target,
  body.printing-page .print-target .wa-chart-card,
  body.printing-page .print-target .wa-quad-card,
  body.printing-page .print-target .wa-detail-card,
  body.printing-page .print-target .sales-agent-card,
  body.printing-page .print-target .sales-funnel,
  body.printing-page .print-target .sales-gallery-card,
  body.printing-page .print-target .money-need-card,
  body.printing-page .print-target .member-section,
  body.printing-page .print-target .overview-kpis { box-shadow: none !important; break-inside: avoid; }
  body.printing-page .print-target tr,
  body.printing-page .print-target .ts-row,
  body.printing-page .print-target .money-need-row,
  body.printing-page .print-target .sales-funnel-row { break-inside: avoid; }
  /* ตาราง/ก้อนที่เลื่อนแนวนอนบนจอ ต้องกางเต็มตอนพิมพ์ */
  body.printing-page .print-target .table-wrap,
  body.printing-page .print-target .ts-table-scroll { overflow: visible !important; max-height: none !important; }
}

/* (money-need มือถือ ≤640px ย้ายไปรวมที่บล็อกใกล้ .money-need-figs แล้ว —
   บล็อกเดิมตั้ง width:100% แต่ .money-need-row ไม่มี flex-wrap เลยไม่ยุบจริง) */

/* ---- My Money Needs worksheet (agent form) ---- */
.mn-form { display: flex; flex-direction: column; gap: 18px; padding-bottom: 24px; }
.mn-card { border: 1.5px solid var(--line); border-radius: 14px; background: var(--card); padding: 16px 18px; }
.mn-card-head { font-weight: 700; color: var(--ink); margin-bottom: 12px; font-size: 15px; }
.mn-exp-headrow { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 600; padding: 0 0 6px 26px; }
.mn-exp-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mn-exp-no { width: 22px; text-align: right; color: var(--muted); font-size: 13px; flex: none; }
.mn-exp-label { flex: 1 1 auto; min-width: 0; }
.mn-amt { display: flex; align-items: center; gap: 6px; flex: none; }
.mn-amt input { width: 120px; text-align: right; }
.mn-amt em { font-style: normal; color: var(--muted); font-size: 13px; }
.mn-exp-savings .mn-savings-label { display: flex; align-items: center; font-weight: 600; color: var(--ink); }
.mn-exp-savings { margin-top: 4px; padding-top: 10px; border-top: 1px dashed var(--line); }
.mn-total { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--line); }
.mn-total span { font-weight: 600; color: var(--ink); }
.mn-total strong { font-family: 'Prompt', sans-serif; font-size: 20px; color: var(--brand); }
.mn-conv-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.mn-conv-cell { display: flex; flex-direction: column; gap: 3px; min-width: 120px; }
.mn-conv-cell > span { font-size: 11px; color: var(--muted); }
.mn-conv-cell > strong { font-family: 'Prompt', sans-serif; font-size: 17px; color: var(--ink); padding: 6px 0; }
.mn-conv-out > strong { color: var(--brand); }
.mn-input-cell .mn-amt input { width: 90px; }
.mn-op { font-size: 15px; color: var(--muted); padding-bottom: 8px; font-weight: 600; }
.mn-arrow { font-size: 18px; color: var(--brand); padding-bottom: 6px; }
.mn-funnel { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; padding-top: 14px; border-top: 1px dashed var(--line); }
.mn-funnel-cell { display: flex; flex-direction: column; gap: 2px; text-align: center; background: var(--bg); border-radius: 10px; padding: 8px 12px; min-width: 84px; }
.mn-funnel-cell span { font-size: 11px; color: var(--muted); }
.mn-funnel-cell strong { font-family: 'Prompt', sans-serif; font-size: 18px; color: var(--ink); }
.mn-weekly { background: var(--ink); color: #fff; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.mn-weekly-title { font-weight: 700; font-size: 14px; opacity: 0.9; }
.mn-weekly-nums { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-left: auto; }
.mn-weekly-nums > div { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mn-weekly-nums span { font-size: 11px; opacity: 0.75; }
.mn-weekly-nums strong { font-family: 'Prompt', sans-serif; font-size: 26px; line-height: 1; }
.mn-colon { font-size: 22px; opacity: 0.5; }
.mn-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mn-foot-field { display: flex; flex-direction: column; gap: 4px; }
.mn-foot-field > span { font-size: 12px; color: var(--muted); }
.mn-foot-field > strong { font-size: 15px; color: var(--ink); padding: 4px 0; }
@media (max-width: 640px) {
  .mn-amt input { width: 96px; }
  .mn-weekly-nums { margin-left: 0; }
  .mn-weekly-nums strong { font-size: 22px; }
  .mn-footer { grid-template-columns: 1fr; }
}

/* ---- My Money Needs — admin read-only view ---- */
.admin-mn { display: flex; flex-direction: column; gap: 14px; }
.admin-mn-empty { text-align: center; padding: 24px; color: var(--muted); }
.admin-mn-kpis { display: flex; flex-wrap: wrap; gap: 10px; }
.admin-mn-kpis > div { flex: 1 1 120px; background: var(--bg); border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.admin-mn-kpis span { font-size: 11px; color: var(--muted); }
.admin-mn-kpis strong { font-family: 'Prompt', sans-serif; font-size: 17px; color: var(--ink); }
.admin-mn-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-mn-table th, .admin-mn-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.admin-mn-table th.num, .admin-mn-table td.num { text-align: right; font-family: 'Prompt', sans-serif; }
.admin-mn-table thead th { font-size: 12px; color: var(--muted); }
.admin-mn-total td { font-weight: 700; color: var(--brand); border-top: 2px solid var(--line); }
.admin-mn-funnel { display: flex; flex-wrap: wrap; gap: 10px; }
.admin-mn-funnel > div { flex: 1 1 100px; text-align: center; background: var(--bg); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.admin-mn-funnel span { font-size: 11px; color: var(--muted); }
.admin-mn-funnel strong { font-family: 'Prompt', sans-serif; font-size: 18px; color: var(--ink); }
.admin-mn-sub { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: -6px; }
.admin-mn-foot { font-size: 12px; color: var(--muted); }

.admin-goals {
  padding: 4px 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.admin-goals-block {
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  background: var(--card);
}
.admin-goals-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.admin-goals-stats > div {
  flex: 1;
  min-width: 180px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-goals-stats span { font-size: 12px; color: var(--muted); }
.admin-goals-stats strong { font-size: 19px; font-family: 'Prompt', sans-serif; }
.admin-wish-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-wish-fields > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.admin-wish-fields span { color: var(--muted); }
.admin-wish-fields strong { color: var(--ink); text-align: right; }
.admin-goals-years {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.admin-goals-years > div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.admin-goals-years p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.6;
  white-space: pre-wrap;
}

@media (min-width: 761px) and (max-width: 1100px) and (orientation: portrait) {
  .app {
    display: block;
    padding-top: calc(90px + env(safe-area-inset-top));
  }
  .sidebar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 40;
    width: 100%;
    height: auto;
    padding: calc(10px + env(safe-area-inset-top)) 8px 10px;
    border-right: 0;
    border-top: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 14px 34px rgba(15,26,46,0.18);
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: safe center;
    gap: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* ขอบจางซ้าย-ขวา บอกใบ้ว่าแถบแท็บเลื่อนแนวนอนได้ (มี 14+ แท็บ) */
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%);
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar .brand,
  .sidebar .nav-label,
  .sidebar .sidebar-agent,
  .sidebar .sidebar-profile {
    display: none;
  }
  .sidebar .nav,
  .sidebar .sidebar-foot {
    display: contents;
  }
  .sidebar .nav-item,
  .sidebar .home-link,
  .sidebar .logout-btn {
    flex: 0 0 auto;
    width: 92px;
    height: 64px;
    margin: 0;
    padding: 8px 6px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    border-radius: 12px;
    scroll-snap-align: start;
  }
  .sidebar .nav-icon { width: 20px; height: 20px; }
  .sidebar .nav-text {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1.1;
  }
  .sidebar .brand-logo { max-width: 32px; }
  .public-app .sidebar {
    justify-content: stretch;
    overflow-x: hidden;
  }
  .public-app .sidebar .nav-item {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    padding-inline: 3px;
  }
  .public-app .sidebar .nav-text {
    display: -webkit-box;
    font-size: 10px;
    line-height: 1.05;
    text-align: center;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
}

/* ===== Mobile UI scale-down (phones) ===== */
@media (max-width: 760px), (max-height: 500px) and (orientation: landscape) {
  body { font-size: 12px; line-height: 1.45; }

  section.scene { padding: 18px 12px 14px; }
  .app-footer { padding: 14px 12px; }

  h1.display { font-size: 24px; margin: 0 0 10px; line-height: 1.1; }
  h2.section-title { font-size: 18px; margin: 0 0 4px; }
  .section-sub { font-size: 12px; margin: 0 0 16px; }
  .section-head { margin-bottom: 14px; gap: 12px; }

  /* KPI cards */
  .kpi { padding: 11px 12px 10px; border-radius: 10px; }
  .kpi-label { font-size: 9px; letter-spacing: 0.12em; }
  .kpi-value { font-size: 21px; margin: 4px 0 1px; }
  .kpi-value em { font-size: 13px; }
  .kpi-sub { font-size: 10px; }
  .kpi-row { gap: 8px; margin-top: 12px; }

  /* RTMS pillars */
  .rtms-grid { gap: 8px; }
  .pillar { padding: 13px 12px 12px; border-radius: 10px; }
  .pillar-letter { font-size: 44px; }
  .pillar-tag { font-size: 9px; letter-spacing: 0.16em; }
  .pillar h3 { font-size: 15px; margin: 8px 0 3px; }
  .pillar-desc { font-size: 11px; margin-bottom: 10px; }

  /* Topbar / crumbs */
  .topbar { padding: 6px 10px; gap: 8px; }
  .crumbs { font-size: 11px; }

  /* Sidebar becomes a single horizontally scrollable row on phones */
  .app {
    display: block;
    padding-top: calc(90px + env(safe-area-inset-top));
  }
  .sidebar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 40;
    width: 100%;
    height: auto;
    padding: calc(10px + env(safe-area-inset-top)) 8px 10px;
    border-right: 0;
    border-top: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 14px 34px rgba(15,26,46,0.18);
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: safe center;
    gap: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* ขอบจางซ้าย-ขวา บอกใบ้ว่าแถบแท็บเลื่อนแนวนอนได้ (มี 14+ แท็บ) */
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%);
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar .brand,
  .sidebar .nav-label,
  .sidebar .sidebar-agent,
  .sidebar .sidebar-profile {
    display: none;
  }
  .sidebar .nav,
  .sidebar .sidebar-foot {
    display: contents;
  }
  .sidebar .nav-item,
  .sidebar .home-link,
  .sidebar .logout-btn {
    flex: 0 0 auto;
    width: 92px;
    height: 64px;
    margin: 0;
    padding: 8px 6px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    border-radius: 12px;
    scroll-snap-align: start;
  }
  .sidebar .nav-icon { width: 20px; height: 20px; }
  .sidebar .nav-text {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1.1;
  }
  .sidebar .brand-logo { max-width: 32px; }

  .public-app .sidebar {
    justify-content: stretch;
    overflow-x: hidden;
  }
  .public-app .sidebar .nav-item {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    padding-inline: 3px;
  }
  .public-app .sidebar .nav-text {
    display: -webkit-box;
    font-size: 10px;
    line-height: 1.05;
    text-align: center;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  /* Forms / inputs */
  .form-input { font-size: 13px; padding: 8px 11px; }
  .form-field { font-size: 11px; }
  .search-input { font-size: 12px; padding: 8px 11px; }

  /* Buttons */
  .btn-outline { padding: 7px 12px; font-size: 12px; }
  .tab-btn { padding: 6px 14px; font-size: 12px; }

  /* Modal */
  .modal-head { font-size: 14px; padding: 14px 16px 10px; }
  .modal-body { padding: 14px 16px 16px; }
  .modal-close { font-size: 20px; }

  /* Detail panels */
  .detail-head { padding: 14px 12px 10px; gap: 10px; }
  .tab-row { padding: 10px 12px; }
  .admin-goals { padding: 4px 12px 16px; }
  .admin-slip-panel { margin: 0 12px 14px; padding: 12px; }

  .month-picker {
    grid-template-columns: 32px minmax(0, 1fr) 32px;
    gap: 6px;
  }
  .month-picker button {
    width: 32px;
    height: 32px;
    font-size: 21px;
    border-radius: 7px;
  }
  .month-picker div {
    min-height: 40px;
    gap: 7px;
  }
  .month-picker span {
    font-size: 11px;
    letter-spacing: 0.13em;
  }
  .month-picker strong {
    font-size: 20px;
  }

  /* Monthly calendar — fit all 7 days, no horizontal scroll */
  .month-calendar {
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    overflow-x: visible;
    padding-bottom: 4px;
  }
  .month-weekday {
    font-size: 9px;
    padding: 5px 2px;
    letter-spacing: 0;
  }
  .month-day {
    min-height: 64px;
    padding: 3px;
    border-radius: 5px;
  }
  .month-date {
    min-width: 0;
    height: 16px;
    padding: 0 4px;
    font-size: 9px;
    border-radius: 999px;
  }
  .month-events {
    gap: 2px;
    margin-top: 3px;
  }
  .month-event {
    padding: 2px 3px 2px 5px;
    border-radius: 4px;
  }
  .month-event::before { width: 2px; }
  .month-event strong {
    font-size: 9px;
    line-height: 1.08;
    white-space: normal;
    overflow: hidden;
    text-overflow: clip;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .month-event span { display: none; }
  .month-event .live-badge { font-size: 9px; padding: 0 4px; margin-top: 2px; }
  .monthly-club-card { padding: 12px 10px; }
  .monthly-club-list { grid-template-columns: 1fr; gap: 6px; }
  .monthly-club-item { padding: 7px 8px 7px 11px; min-height: 0; }
  .monthly-club-item strong { font-size: 10px; }
  .monthly-club-item span { font-size: 9px; }
  .monthly-club-item em { font-size: 9px; padding: 2px 5px; }

  /* Weekly schedule — fit all 7 days, no horizontal scroll */
  .week-grid {
    grid-template-columns: 30px repeat(7, 1fr);
    gap: 3px;
    overflow-x: visible;
  }
  .week-head {
    font-size: 9px;
    letter-spacing: 0.04em;
    padding: 6px 0;
  }
  .week-head span { font-size: 11px; margin-top: 2px; }
  .time-col {
    font-size: 11px;
    padding: 6px 2px;
    letter-spacing: 0;
  }
  .time-col > div { font-size: 11px !important; }
  .slot { min-height: 54px; padding: 2px; gap: 2px; }
  .club-chip {
    padding: 5px 4px 5px 7px;
    border-radius: 6px;
  }
  .club-chip::before { width: 2px; }
  .club-name { font-size: 11px; line-height: 1.15; }
  .club-meta { font-size: 11px; margin-top: 3px; gap: 3px; }
  .club-meta .pill { font-size: 11px; padding: 0 4px; }
  .live-badge { font-size: 10px; padding: 1px 5px; margin-left: 4px; }
  .live-dot { width: 5px; height: 5px; }
}

/* ===== Reward / Leaderboard ===== */

/* Leaderboard — podium + card list */
.leaderboard-scene { padding-bottom: 24px; }

.lb-metric-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 4px 16px 0;
}
.lb-metric-tab {
  border: 1.5px solid var(--line, #e6e6ee);
  background: #fff;
  color: var(--muted);
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.lb-metric-tab:hover { border-color: var(--ink-soft); color: var(--ink); }
.lb-metric-tab.active {
  border-color: var(--brand-strong);
  background: var(--brand-strong);
  color: #fff;
}

.lb-podium {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  align-items: end;
  gap: 14px;
  padding: 20px 32px 32px;
  max-width: 720px;
  margin: 0 auto;
}
.lb-podium-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.lb-podium-slot.empty { visibility: hidden; }
.lb-podium-slot.first { padding-bottom: 8px; }
.lb-podium-avatar {
  position: relative;
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.lb-podium-slot.gold   .lb-podium-avatar { box-shadow: 0 6px 20px rgba(201, 146, 10, 0.35); }
.lb-podium-slot.silver .lb-podium-avatar { box-shadow: 0 4px 14px rgba(122, 143, 166, 0.28); }
.lb-podium-slot.bronze .lb-podium-avatar { box-shadow: 0 4px 14px rgba(160, 97, 74, 0.28); }
.lb-podium-medal {
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  width: 28px; height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Prompt', sans-serif;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  border: 3px solid var(--card);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.lb-podium-slot.gold   .lb-podium-medal { background: linear-gradient(135deg, #FFC93C, #C9920A); }
.lb-podium-slot.silver .lb-podium-medal { background: linear-gradient(135deg, #C8D3DE, #7A8FA6); }
.lb-podium-slot.bronze .lb-podium-medal { background: linear-gradient(135deg, #D89A7F, #A0614A); }
.lb-podium-name {
  display: block;
  margin-top: 14px;
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-podium-slot.first .lb-podium-name { font-size: 16px; }
.lb-podium-points {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.lb-list {
  display: flex;
  flex-direction: column;
  padding: 0 32px 8px;
  max-width: 720px;
  margin: 0 auto;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-2);
  background: transparent;
  border-radius: 14px;
  transition: background 120ms ease;
}
.lb-row:last-child { border-bottom: 0; }
.lb-row.is-me {
  background: var(--gold-tint);
  border-bottom-color: transparent;
}
.lb-row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lb-row-body strong {
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-row-body span {
  font-size: 11px;
  color: var(--muted);
}
.lb-me-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.lb-me-pill.inline {
  height: 18px; padding: 0 8px;
  margin-left: 6px;
  font-size: 10px;
}
.lb-rank-badge {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.lb-rank-badge.color-red    { background: #EF4444; }
.lb-rank-badge.color-blue   { background: #38BDF8; }
.lb-rank-badge.color-green  { background: #34D399; }
.lb-rank-badge.color-yellow { background: #FACC15; color: #5C4A00; }
.lb-rank-badge.color-purple { background: #A78BFA; }
.lb-rank-badge.color-teal   { background: #2DD4BF; }
.lb-rank-badge.color-pink   { background: #F472B6; }
.lb-rank-badge.color-orange { background: #FB923C; }

.lb-divider {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.4em;
  padding: 6px 0;
}

/* ---- Live sales recognition feed (public home page) ---- */
.sales-feed-summary {
  display: flex;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto 16px;
  padding: 0 32px;
}
.sales-feed-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.sales-feed-stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.sales-feed-stat strong { font-family: 'Prompt', sans-serif; font-size: 24px; font-weight: 800; color: var(--gold); }
.sales-feed-stat em { font-size: 11px; color: var(--muted); font-style: normal; }

.sales-feed-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 32px 8px;
}
.sales-feed-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.sales-feed-row:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(15,26,46,0.06); }

.sales-feed-avatar {
  flex-shrink: 0;
  border-radius: 999px;
  object-fit: cover;
  background: var(--line-2);
}
.sales-feed-avatar.fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: 'Prompt', sans-serif;
  font-weight: 700;
  font-size: 18px;
}

.sales-feed-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sales-feed-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sales-feed-name {
  font-family: 'Prompt', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sales-feed-unit {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
  background: var(--line-2);
  padding: 2px 8px;
  border-radius: 999px;
}
.sales-feed-meta {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sales-feed-amount {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}
.sales-feed-amount strong {
  font-family: 'Prompt', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--t);
}
.sales-feed-amount em { font-size: 10px; color: var(--muted); font-style: normal; letter-spacing: 0.06em; }
.sales-feed-row.recruit { border-left: 3px solid var(--r); }
.sales-feed-amount.recruit strong { color: var(--r); }

.sales-feed-empty {
  text-align: center;
  padding: 32px;
  color: var(--muted);
  font-size: 15px;
  max-width: 720px;
  margin: 0 auto;
}

@media (max-width: 760px) {
  .sales-feed-summary { padding: 0 12px; gap: 8px; margin-bottom: 12px; }
  .sales-feed-stat { padding: 10px 8px; border-radius: 12px; }
  .sales-feed-stat strong { font-size: 20px; }
  .sales-feed-list { padding: 0 12px 8px; gap: 6px; }
  .sales-feed-row { padding: 10px 12px; gap: 10px; border-radius: 12px; }
  .sales-feed-name { font-size: 14px; }
  .sales-feed-amount strong { font-size: 16px; }
}

@media (max-width: 760px) {
  .lb-podium { padding: 12px 12px 24px; gap: 8px; }
  .lb-podium-slot.first .lb-podium-name { font-size: 14px; }
  .lb-podium-name { font-size: 12px; }
  .lb-podium-points { font-size: 10px; }
  .lb-list { padding: 0 12px 8px; }
  .lb-row { padding: 10px 12px; gap: 10px; }
  .lb-row-body strong { font-size: 13px; }
  .lb-rank-badge { width: 34px; height: 34px; font-size: 12px; }
}

/* Points balance header */
.reward-page {
  padding-bottom: 28px;
}
.reward-page .section-head {
  margin-bottom: 18px;
}
.reward-page .section-sub {
  max-width: 520px;
}
.reward-summary {
  display: grid;
  grid-template-columns: minmax(220px, 1.25fr) minmax(180px, 0.8fr) minmax(180px, 1fr);
  gap: 12px;
  padding: 0 32px;
  margin-bottom: 16px;
}
.reward-summary > div {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.reward-summary-main {
  padding: 18px 18px 16px;
  background: linear-gradient(135deg, var(--ink), var(--ink-2)) !important;
  color: #fff;
}
.reward-summary span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 5px;
}
.reward-summary-main span { color: rgba(255,255,255,0.72); }
.reward-summary strong {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-size: 21px;
  line-height: 1.15;
  color: var(--ink);
}
.reward-summary-main strong {
  font-size: 34px;
  color: var(--gold-soft);
}
.reward-summary small {
  display: block;
  margin-top: 7px;
  font-size: 12px;
  color: var(--muted);
}
.reward-summary-main small { color: rgba(255,255,255,0.72); }
.reward-summary-side {
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
}
.reward-summary-side > div {
  padding: 13px 14px;
}
.reward-summary-side > div + div {
  border-top: 1px solid var(--line);
}
.reward-next {
  padding: 14px 16px;
  background: var(--gold-tint) !important;
  border-color: var(--gold-soft) !important;
}
.reward-next strong {
  font-size: 17px;
}
.points-rule-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0 32px 12px;
  padding: 10px 12px;
  border: 1px solid var(--gold-soft);
  border-radius: 10px;
  background: var(--gold-tint);
}
.points-rule-card strong {
  font-size: 13px;
  color: var(--ink);
}
.points-rule-card > small {
  font-size: 11px;
  color: var(--ink-soft);
}
.points-rule-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 1px 0 0;
  padding: 0;
  list-style: none;
}
.points-rule-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.5);
}
.points-rule-list .prl-act {
  font-size: 12px;
  color: var(--ink);
}
.points-rule-list .prl-pts {
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-strong, var(--ink));
  white-space: nowrap;
}
.reward-tabs {
  display: inline-flex;
  gap: 4px;
  margin: 0 32px 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-2);
}
.reward-tabs .tab-btn {
  border: none;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 13px;
}
.reward-tabs .tab-btn.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.balance-header {
  display: flex; gap: 20px; flex-wrap: wrap;
  padding: 18px 22px; margin: 0 32px;
  background: linear-gradient(135deg, var(--ink), var(--ink-2));
  color: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}
.balance-header > div { display: flex; flex-direction: column; gap: 4px; }
.balance-header span { font-size: 12px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.5px; }
.balance-header strong { font-size: 28px; font-weight: 700; color: var(--gold-soft); }

/* Reward shop */
.reward-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 0 32px 32px;
}
.reward-card {
  display: flex; flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}
.reward-card:not(.disabled):hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.reward-card.disabled { opacity: 0.55; }
.reward-img {
  aspect-ratio: 4 / 3;
  background: var(--paper-2);
  overflow: hidden;
}
.reward-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reward-img-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 60px; color: var(--muted);
}
.reward-body {
  padding: 12px; display: flex; flex-direction: column; gap: 8px; flex: 1;
}
.reward-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.reward-title-row strong {
  font-size: 15px;
  color: var(--ink);
  line-height: 1.35;
}
.reward-title-row span {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(47,106,90,0.12);
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
}
.reward-body p {
  margin: 0; font-size: 12px; color: var(--muted); line-height: 1.4;
  flex: 1;
}
.reward-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px;
}
.reward-cost { font-weight: 700; color: var(--brand); }
.reward-stock {
  font-size: 12px; color: var(--muted);
  padding: 2px 8px; border-radius: 999px;
  background: var(--line-2);
}
.reward-stock.out { color: var(--red); background: rgba(180,58,44,0.1); }
.reward-history {
  padding: 0 32px 32px;
}
.reward-history-cards {
  display: none;
}
.reward-history-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}
.reward-history-card > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 9px;
}
.reward-history-card strong {
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  color: var(--ink);
}
.reward-history-card span,
.reward-history-card p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.reward-history-card .link-btn {
  margin-top: 9px;
}
.reward-history-empty {
  padding: 26px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 960px) {
  .reward-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .reward-page {
    padding-top: 18px;
  }
  .reward-page .section-head {
    margin-bottom: 12px;
  }
  .reward-page h2.section-title {
    font-size: 22px;
  }
  .reward-page .section-sub {
    font-size: 13px;
    line-height: 1.45;
  }
  .reward-summary {
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 0 16px;
    margin-bottom: 12px;
  }
  .reward-summary-main {
    padding: 16px;
  }
  .reward-summary-main strong {
    font-size: 32px;
  }
  .reward-summary-side {
    grid-template-columns: 1fr 1fr;
  }
  .reward-summary-side > div + div {
    border-top: none;
    border-left: 1px solid var(--line);
  }
  .reward-next {
    display: none;
  }
  .reward-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin: 0 16px 12px;
  }
  .reward-tabs .tab-btn {
    padding: 8px 4px;
    font-size: 12px;
  }
  .reward-grid { padding: 0 16px 16px; gap: 8px; }
  .reward-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .reward-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .reward-img {
    height: auto;
    aspect-ratio: 4 / 3;
  }
  .reward-img-empty {
    font-size: 34px;
  }
  .reward-body {
    padding: 9px;
    gap: 5px;
  }
  .reward-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
  .reward-title-row strong {
    font-size: 12px;
  }
  .reward-title-row span {
    font-size: 9px;
    padding: 1px 6px;
  }
  .reward-body p {
    font-size: 10.5px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .reward-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
  }
  .reward-stock {
    font-size: 10px;
    padding: 1px 6px;
  }
  .reward-body .login-btn {
    padding: 7px 8px;
    border-radius: 7px;
    font-size: 12px;
  }
  .reward-history {
    padding: 0 16px 18px;
  }
  .reward-history-table {
    display: none;
  }
  .reward-history-cards {
    display: flex;
    flex-direction: column;
    gap: 9px;
  }
  .balance-header { margin: 0 16px; padding: 14px 16px; gap: 14px; }
  .balance-header strong { font-size: 22px; }
}

/* ===== Reward Journey (Game-style Path) ===== */
.reward-journey-wrap { padding: 0 32px 48px; }
@media (max-width: 640px) { .reward-journey-wrap { padding: 0 16px 32px; } }

/* Hero — next milestone preview */
.journey-hero {
  display: flex; flex-direction: column; gap: 10px;
  margin: 16px 0 24px;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--gold-tint), var(--paper));
  border: 1px solid var(--gold-soft);
  border-radius: 14px;
}
.journey-hero-text { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.journey-hero-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--brand); font-weight: 600;
}
.journey-hero-text strong { font-size: 18px; }
.journey-hero-needed { font-size: 13px; color: var(--muted); margin-left: auto; }
.journey-hero-needed strong { font-size: 16px; color: var(--brand); }
.journey-hero-bar {
  position: relative;
  height: 14px; background: rgba(0,0,0,0.06);
  border-radius: 999px; overflow: hidden;
}
.journey-hero-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-soft), var(--gold));
  border-radius: 999px;
  transition: width 0.6s ease;
}
.journey-hero-pct {
  position: absolute; top: 50%; right: 10px;
  transform: translateY(-50%);
  font-size: 10px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* The path itself */
.reward-journey {
  display: flex; flex-direction: column;
  align-items: center;
  position: relative;
}
.reward-rung {
  position: relative;
  display: flex; align-items: center; gap: 18px;
  width: 100%; max-width: 540px;
  padding: 8px 0;
}
/* Zig-zag: odd rungs flip so the node alternates left ↔ right */
.reward-rung:nth-child(even) { flex-direction: row-reverse; }
@media (max-width: 600px) {
  .reward-rung, .reward-rung:nth-child(even) { flex-direction: row; }
}

/* The circular node holding the icon */
.reward-rung-node {
  flex-shrink: 0;
  position: relative;
  width: 78px; height: 78px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--card);
  border: 3px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}
.reward-rung-icon { font-size: 34px; line-height: 1; }
.reward-rung-step {
  position: absolute; bottom: -8px;
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: var(--ink); color: #fff;
  letter-spacing: 0.5px;
}

/* Connector between rungs (vertical line behind nodes) */
.reward-journey::before {
  content: "";
  position: absolute;
  top: 24px; bottom: 24px;
  left: 50%; transform: translateX(-50%);
  width: 4px;
  background: repeating-linear-gradient(
    to bottom,
    var(--line) 0 6px,
    transparent 6px 10px
  );
  z-index: 0;
}
.reward-rung > * { position: relative; z-index: 1; }
.reward-rung-connector { display: none; }

/* Card — title, cost, action */
.reward-rung-card {
  flex: 1;
  display: flex; gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.reward-rung-img {
  flex-shrink: 0;
  width: 56px; height: 56px;
  border-radius: 8px; overflow: hidden;
  background: var(--paper-2);
}
.reward-rung-img img { width: 100%; height: 100%; object-fit: cover; }
.reward-rung-body { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.reward-rung-body strong { font-size: 15px; }
.reward-rung-cost { font-size: 13px; color: var(--brand); font-weight: 600; }

.reward-rung-tag {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  align-self: flex-start;
}
.reward-rung-tag.claimed   { background: rgba(47,106,90,0.12); color: var(--green); }
.reward-rung-tag.pending   { background: var(--gold-tint); color: #9A7A1E; }
.reward-rung-tag.reached   { background: rgba(0,0,0,0.06); color: var(--muted); }
.reward-rung-tag.locked    { background: rgba(0,0,0,0.06); color: var(--muted); }
.reward-rung-stock {
  font-size: 11px; color: var(--muted); margin-top: 2px;
}

/* Extra info badges (claim count / pending count / stock) */
.reward-rung-extras {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 4px;
}
.reward-rung-badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(0,0,0,0.04); color: var(--muted);
}
.reward-rung-badge.claimed { background: rgba(47,106,90,0.10); color: var(--green); }
.reward-rung-badge.pending { background: var(--gold-tint); color: #9A7A1E; }
.reward-rung-badge.stock   { background: rgba(0,0,0,0.04); color: var(--muted); }

.reward-rung-claim {
  align-self: flex-start;
  background: linear-gradient(135deg, var(--brand-strong), #8F4008);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(244,121,32,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.reward-rung-claim:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(244,121,32,0.45); }
.reward-rung-claim:active { transform: translateY(0); }

/* Per-state visuals */
.reward-rung.state-claimed .reward-rung-node {
  border-color: var(--green);
  background: linear-gradient(135deg, #DEEFE9, #fff);
}
.reward-rung.state-claimed .reward-rung-icon { filter: none; }

.reward-rung.state-available .reward-rung-node {
  border-color: var(--gold);
  background: linear-gradient(135deg, var(--gold-tint), #fff);
  animation: rung-pulse 1.6s ease-in-out infinite;
}
.reward-rung.state-available .reward-rung-card {
  border-color: var(--gold-soft);
}

.reward-rung.state-pending .reward-rung-node {
  border-color: var(--gold-soft);
  background: var(--gold-tint);
}

.reward-rung.state-reached .reward-rung-node {
  border-color: var(--line);
  background: var(--paper-2);
}
.reward-rung.state-reached .reward-rung-icon { opacity: 0.6; }

.reward-rung.state-locked .reward-rung-node {
  border-color: var(--line);
  background: var(--paper-2);
}
.reward-rung.state-locked .reward-rung-icon { filter: grayscale(1); opacity: 0.45; }
.reward-rung.state-locked .reward-rung-card { opacity: 0.75; }

.reward-rung.rung-current .reward-rung-card {
  box-shadow: 0 0 0 3px var(--gold-tint), var(--shadow-md);
}

@keyframes rung-pulse {
  0%, 100% { box-shadow: var(--shadow-sm); transform: scale(1); }
  50%      { box-shadow: 0 0 0 8px var(--gold-tint), var(--shadow-md); transform: scale(1.04); }
}

@media (max-width: 640px) {
  .reward-rung-node { width: 64px; height: 64px; }
  .reward-rung-icon { font-size: 28px; }
  .reward-rung-card { padding: 12px; }
  .reward-rung-img { width: 48px; height: 48px; }
}

/* ------- Daily Challenges public section (homepage) ------- */
.pub-challenge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.pub-challenge-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.pub-challenge-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(244,121,32,0.3);
}
.pub-challenge-icon {
  font-size: 32px;
  line-height: 1;
  flex-shrink: 0;
}
.pub-challenge-body { flex: 1; min-width: 0; }
.pub-challenge-title {
  font-family: 'Prompt', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 4px;
}
.pub-challenge-desc {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-bottom: 6px;
}
.pub-challenge-reward {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-strong);
  background: var(--gold-tint);
  padding: 2px 10px;
  border-radius: 999px;
  margin-top: 4px;
}
.pub-challenge-condition {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 4px;
}
.pub-challenge-challenger {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.pub-challenge-empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  background: var(--paper-2);
  border: 1px dashed var(--line);
  border-radius: 14px;
  margin-bottom: 20px;
}

.pub-challenge-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  padding: 28px 24px;
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink-2) 100%);
  border-radius: 16px;
  text-align: center;
}
.pub-challenge-cta p {
  margin: 0;
  color: rgba(244,245,247,0.8);
  font-size: 15px;
}
.pub-challenge-btn {
  display: inline-block;
  padding: 12px 28px;
  background: var(--brand-strong);
  color: #fff;
  font-family: 'Prompt', sans-serif;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}
.pub-challenge-btn:hover { background: #e06510; transform: translateY(-1px); }
.pub-challenge-btn:active { transform: translateY(0); }

@media (max-width: 640px) {
  .pub-challenge-grid { grid-template-columns: 1fr; }
}

/* ------- Daily Challenges ------- */
.challenge-section { margin-top: 0; }

.challenge-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.challenge-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.challenge-card:hover { border-color: rgba(15,26,46,0.18); box-shadow: var(--shadow-sm); }
.challenge-card.done {
  background: rgba(47,106,90,0.07);
  border-color: rgba(47,106,90,0.25);
}
.challenge-card.pending {
  background: rgba(244,121,32,0.06);
  border-color: rgba(244,121,32,0.24);
}

.challenge-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
  width: 40px;
  text-align: center;
}

.challenge-body { flex: 1; min-width: 0; }
.challenge-title {
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}
.challenge-desc {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.challenge-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 5px;
}
.challenge-type-tag {
  font-size: 10px;
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--line-2);
  color: var(--muted);
}
.challenge-condition {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.challenge-progress {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(15,26,46,0.06);
  border-radius: 999px;
  padding: 2px 8px;
}
.challenge-progress.ok {
  color: var(--t);
  background: rgba(47,106,90,0.10);
}
.challenge-reward {
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-strong);
}

.challenge-action { flex-shrink: 0; }
.challenge-claim-btn {
  background: var(--brand-strong);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.challenge-claim-btn:hover { background: #e06510; transform: translateY(-1px); }
.challenge-claim-btn:active { transform: translateY(0); }
.challenge-claim-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.challenge-done-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--t);
  white-space: nowrap;
}
.challenge-pending-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}
.challenge-pending-badge.muted { color: var(--muted); }
.challenge-challenger {
  font-size: 11px;
  color: var(--muted);
}

.challenge-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: block;
}

/* Challenge image upload in admin form */
.challenge-img-upload-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0 18px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 16px;
}
.challenge-img-preview {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.challenge-img-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: var(--paper-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
}
.challenge-img-placeholder span { font-size: 28px; line-height: 1; }
.challenge-img-placeholder small { font-size: 9px; color: var(--muted); }
.challenge-img-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.challenge-img-pick-btn {
  display: inline-block;
  padding: 7px 14px;
  background: var(--ink);
  color: #F4F5F7;
  font-family: 'Prompt', sans-serif;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.challenge-img-pick-btn:hover { background: var(--ink-2); }
.challenge-img-hint { font-size: 11px; color: var(--muted); }

/* Admin panel */
.challenge-approval-panel {
  margin-bottom: 20px;
  padding: 14px;
  background: rgba(244,121,32,0.06);
  border: 1px solid rgba(244,121,32,0.24);
  border-radius: 12px;
}
.challenge-approval-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.challenge-approval-head strong {
  font-family: 'Prompt', sans-serif;
  font-size: 15px;
}
.challenge-approval-head span {
  font-size: 12px;
  color: var(--muted);
}
.challenge-admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.challenge-admin-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.challenge-admin-row.inactive { opacity: 0.6; }

.challenge-admin-body { flex: 1; min-width: 0; }
.challenge-admin-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.challenge-admin-title strong { font-size: 14px; font-family: 'Prompt', sans-serif; }
.challenge-admin-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}
.challenge-admin-desc { font-size: 12px; color: var(--muted); margin-top: 3px; }
.challenge-admin-actions { flex-shrink: 0; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* form-grid-2 (shared by challenge form) */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  margin-bottom: 20px;
}
.form-grid-2 .full { grid-column: 1 / -1; }


@media (max-width: 640px) {
  .challenge-card { gap: 10px; }
  .challenge-icon { font-size: 24px; width: 32px; }
  .challenge-admin-row { flex-wrap: wrap; }
  .challenge-admin-actions { width: 100%; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-2 .full { grid-column: 1; }
}

/* =========================================================================
   iPad / tablet enhancements  (appended — overrides earlier rules by order)
   1) Touch: neutralise sticky :hover transforms (no real hover pointer)
   2) iPad 761–1100px: persistent labeled vertical sidebar (both orientations)
   ========================================================================= */

/* 1) On pure-touch devices a :hover state sticks after a tap. Cancel the
   "lift" transforms so tapped cards/buttons don't stay shifted. */
@media (hover: none) {
  .nav-item:hover,
  .temporary-register-btn:hover,
  .kpi:hover,
  .pillar:hover,
  .club-chip:hover,
  .instructor-card:hover,
  .act-card:hover,
  .complete-btn:hover,
  .month-card:hover,
  button.cta:hover,
  .login-btn:hover,
  .login-foot a:hover,
  .schedule-zoom-btn:hover,
  .admin-member-card:hover,
  .cartoon-avatar-btn:hover,
  .reward-card:not(.disabled):hover,
  .reward-rung-claim:hover,
  .pub-challenge-card:hover,
  .pub-challenge-btn:hover,
  .challenge-claim-btn:hover {
    transform: none;
  }
}

/* 2) iPad LANDSCAPE: there is enough width for a real labeled vertical
   sidebar — override the 64px icon-rail with a compact desktop-style
   sidebar. Labels (.nav-text) already exist in markup — just re-shown here.
   PORTRAIT is intentionally left to the top-bar block (≈L4676) per user
   preference (menu as a top strip on portrait iPad). */
@media (min-width: 761px) and (max-width: 1100px) and (orientation: landscape) {
  .app {
    display: grid;
    grid-template-columns: 210px 1fr;
    padding-top: 0;                                   /* undo top-bar offset */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    background: var(--paper);
  }
  .sidebar {
    position: sticky;
    inset: auto;
    top: 0;
    z-index: 20;
    width: auto;
    height: 100vh;
    height: 100dvh;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 24px;
    padding: 22px 16px calc(18px + env(safe-area-inset-bottom));
    padding-left: calc(16px + env(safe-area-inset-left));
    border-right: 1px solid var(--sidebar-strong);
    border-bottom: 0;
    box-shadow: none;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .sidebar .brand { display: flex; justify-content: center; }
  .sidebar .brand-logo { max-width: 150px; border-radius: 12px; }
  .sidebar .nav-label { display: block; }
  .sidebar .nav { display: flex; flex-direction: column; gap: 2px; width: 100%; align-items: stretch; }
  .sidebar .sidebar-foot { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
  .sidebar .sidebar-agent { display: flex; }
  .sidebar .nav-item,
  .sidebar .home-link,
  .sidebar .logout-btn {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 8px;
    font-size: 14px;
    text-align: left;
  }
  .sidebar .nav-icon { width: 18px; height: 18px; }
  .sidebar .nav-text {
    display: block;
    flex: 1;
    font-size: 14px;
    line-height: 1.2;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: none;
  }
  /* sidebar is persistent here — no hamburger / overlay */
  .menu-btn { display: none !important; }
  .mobile-overlay { display: none !important; }
  /* the public app stretched nav items across a top bar — reset to a column */
  .public-app .sidebar { justify-content: flex-start; overflow-x: hidden; }
  .public-app .sidebar .nav-item { flex: 0 0 auto; width: 100%; min-width: 0; padding-inline: 12px; }
  .public-app .sidebar .nav-text {
    display: block;
    -webkit-box-orient: initial;
    -webkit-line-clamp: none;
    white-space: nowrap;
    text-align: left;
    font-size: 14px;
    line-height: 1.2;
  }
}

/* =========================================================================
   Phase 2 — iPad content density (uses the room the compact sidebar frees)
   Cascades after the base max-width:1100 block, so these win in the iPad band.
   ========================================================================= */

/* Wide iPad band (landscape ~1024, 12.9" portrait) — desktop-like room */
@media (min-width: 900px) and (max-width: 1100px) {
  .activities { grid-template-columns: repeat(3, 1fr); }
  .monthly-club-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* calendars fit the available width — no horizontal scroll needed */
  .week-grid { grid-template-columns: 60px repeat(7, minmax(0, 1fr)); }
  .month-calendar { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  /* restore the two-pane lesson layout (list + detail) */
  .lms-shell { grid-template-columns: minmax(0, 1fr) 280px; }
}

/* Narrow iPad band (portrait 768–834) — two-up where one-up wastes space */
@media (min-width: 761px) and (max-width: 899px) {
  .activities { grid-template-columns: repeat(2, 1fr); }
  .monthly-club-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* iPad (761–1100): the admin overview table is min-width:1080px so it
   horizontal-scrolls even in landscape (1024). The card view already renders
   in the DOM (only display:none by default) — show it 2-up to use the width.
   Width-based like the existing ≤760 card rule (not pointer-gated). */
@media (min-width: 761px) and (max-width: 1100px) {
  .overview-table-desktop { display: none; }
  .overview-card-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 0 16px;
  }
  .overview-card-grid { grid-template-columns: 1fr; }
}

/* Wide iPad band on TOUCH only (11" landscape ~1194, 12.9" 1366).
   These widths sit ABOVE the 1100 density cap and fall into desktop layout:
   .kpi-row auto-fits 4-up and the dark feature card's number ("18.96 M APE")
   + progress line wrap. Scoped to pointer:coarse so real desktops keep 4-up. */
@media (min-width: 1101px) and (max-width: 1366px) and (pointer: coarse) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .rtms-grid { grid-template-columns: repeat(2, 1fr); }
  /* calendars fit the width instead of horizontal-scrolling */
  .week-grid { grid-template-columns: 60px repeat(7, minmax(0, 1fr)); }
  .month-calendar { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  /* keep the two-pane lesson layout (list + detail) */
  .lms-shell { grid-template-columns: minmax(0, 1fr) 280px; }
}

/* =========================================================================
   Phase 3 — touch ergonomics (iPad / phones)  [targets real classes]
   A) Modals: safe-area aware padding + dynamic viewport height + contained
      scroll. Real modal classes are .modal-backdrop/.modal-box (login+admin)
      and .poster-modal-backdrop/.poster-modal (image zoom in sections).
   B) @media (pointer: coarse) only: >=44px touch targets + 16px text inputs
      (stops iOS focus-zoom). Desktop mouse pointers keep the compact sizing.
   ========================================================================= */

/* A) Modal chrome — applies everywhere (env()=0 on non-notch screens) */
.modal-backdrop {
  padding: max(20px, env(safe-area-inset-top))
           max(20px, env(safe-area-inset-right))
           max(20px, env(safe-area-inset-bottom))
           max(20px, env(safe-area-inset-left));
}
.modal-box {
  max-height: 90dvh;                 /* falls back to base 90vh if unsupported */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.poster-modal-backdrop {
  padding: max(24px, env(safe-area-inset-top))
           max(24px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom))
           max(24px, env(safe-area-inset-left));
}
.poster-modal { max-height: min(88dvh, 760px); }
.poster-modal img { max-height: 88dvh; }

/* B) Touch devices only — finger-sized targets */
@media (pointer: coarse) {
  /* standalone icon / close buttons */
  .modal-close,
  .poster-modal-close,
  .schedule-zoom-btn,
  .cartoon-avatar-btn {
    min-width: 44px;
    min-height: 44px;
  }
  .wish-remove { min-width: 40px; min-height: 40px; }

  /* segmented controls / tabs */
  .tab-btn,
  .view-switch button,
  .reward-tabs .tab-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* primary / action buttons */
  .btn-outline,
  .complete-btn,
  .login-btn,
  .pub-challenge-btn,
  .challenge-claim-btn,
  .reward-rung-claim,
  .schedule-line-share-btn,
  .temporary-register-btn {
    min-height: 44px;
  }

  /* text inputs: 16px stops iOS Safari from auto-zooming on focus.
     (.form-input also styles <select>/<textarea>; safe to bump font.) */
  .form-input,
  .login-input,
  .search-input,
  .goals-money-input {
    font-size: 16px;
  }
  /* 44px min only on single-line controls — exclude <textarea> so it keeps
     its taller min-height from base rules. */
  input.form-input,
  select.form-input,
  .login-input,
  .search-input,
  .goals-money-input {
    min-height: 44px;
  }

  /* icon/row action buttons that previously slipped below 44px on touch */
  .btn-edit,
  .btn-delete,
  .btn-approve,
  .announce-close,
  .announce-lb-close,
  .notif-sound-toggle,
  .bank-info-copy,
  .sales-cust-btn,
  .sales-move-btn,
  .ts-sort,
  .lms-attach-remove,
  .month-picker button {
    min-width: 44px;
    min-height: 44px;
  }
  .wish-remove { min-width: 44px; min-height: 44px; }

  /* carousel dots stay small visually but get a 44px invisible tap area */
  .announce-dot { position: relative; }
  .announce-dot::after {
    content: "";
    position: absolute;
    inset: -18px;
  }
}

/* ---- Announcement Banner ---- */
.announce-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  border-bottom: 2px solid #c0a060;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.announce-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(192,160,96,0.08), transparent);
  animation: announce-shimmer 3s infinite;
}
@keyframes announce-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.announce-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1.5px solid #c0a060;
  flex-shrink: 0;
}
.announce-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.announce-tag {
  font-size: 11px;
  font-weight: 700;
  color: #f0c060;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.announce-msg {
  font-size: 13px;
  color: #e8e8f0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.announce-close {
  background: none;
  border: none;
  color: #a0a0b0;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  flex-shrink: 0;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s;
  position: relative;
  z-index: 1;
}
.announce-close:hover { color: #fff; }

/* Carousel dots */
.announce-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  padding: 0 4px;
  position: relative;
  z-index: 1;
}
.announce-dot {
  width: 7px;
  height: 7px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.announce-dot:hover { background: rgba(255,255,255,0.55); }
.announce-dot.active {
  background: #f0c060;
  transform: scale(1.25);
}

/* Lightbox */
.announce-lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-popup);
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.announce-lightbox img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
  object-fit: contain;
}
.announce-lb-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0,0,0,0.6);
  border: 1.5px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.announce-lb-close:hover { background: rgba(0,0,0,0.85); }

/* ---- Ad poster popup (full-screen, opt-in announcements) ---- */
.ad-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-popup);
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: ad-popup-fade 0.2s ease;
}
@keyframes ad-popup-fade { from { opacity: 0; } to { opacity: 1; } }
.ad-popup-card {
  position: relative;
  max-width: min(92vw, 440px);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 56px rgba(0,0,0,0.55);
  animation: ad-popup-pop 0.24s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes ad-popup-pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.ad-popup-img {
  display: block;
  width: 100%;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 16px 16px 0 0;
}
/* image-only popup (no text card after it) → round all corners */
.ad-popup-img:last-child { border-radius: 16px; }
.ad-popup-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 20px 20px;
}
.ad-popup-tag {
  align-self: flex-start;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand);
  background: var(--gold-tint, #FDE8D5);
  padding: 3px 10px;
  border-radius: 999px;
}
.ad-popup-msg { font-size: 15px; line-height: 1.5; color: var(--ink, #171717); }
.ad-popup-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  background: rgba(0,0,0,0.55);
  border: 1.5px solid rgba(255,255,255,0.35);
  color: #fff;
  font-size: 18px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.ad-popup-close:hover { background: rgba(0,0,0,0.82); }

/* ==========================================================================
   Sales Tracking (ติดตามการขาย) — ฝั่งตัวแทน + ฝั่งแอดมิน/ผู้จัดการ
   ========================================================================== */

/* stage colours */
.sales-stage-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--paper-2); color: var(--ink-soft); white-space: nowrap;
}
.sales-stage-pill.st-prospect     { background: #EEF1F5; color: #5B6B82; }
.sales-stage-pill.st-appointment  { background: color-mix(in srgb, var(--s) 14%, var(--card)); color: var(--s); }
.sales-stage-pill.st-meeting      { background: #E7F0EB; color: var(--green); }
.sales-stage-pill.st-presentation { background: var(--gold-tint); color: var(--r); }
.sales-stage-pill.st-won          { background: #DDEFE6; color: #2E7D57; }
.sales-stage-pill.st-lost         { background: #FBE5E1; color: var(--red); }
/* Recruiting stages เพิ่มเติม (contact/bop/interview/exam) — reuse st-prospect/won/lost ของเดิม */
.sales-stage-pill.st-contact      { background: color-mix(in srgb, var(--s) 14%, var(--card)); color: var(--s); }
.sales-stage-pill.st-bop          { background: #E7F0EB; color: var(--green); }
.sales-stage-pill.st-interview    { background: var(--gold-tint); color: var(--r); }
.sales-stage-pill.st-exam         { background: color-mix(in srgb, var(--s) 14%, var(--card)); color: var(--s); }

.sales-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sales-empty { padding: 28px; text-align: center; color: var(--muted); font-size: 14px; }

/* summary cards */
.sales-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.sales-sum-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 2px;
}
.sales-sum-card span { font-size: 12px; color: var(--muted); }
.sales-sum-card strong { font-size: 24px; color: var(--ink); font-family: "DM Serif Display", serif; }
.sales-sum-card em { font-size: 11px; color: var(--muted); font-style: normal; }

/* view switch (segmented) */
.sales-viewswitch { display: inline-flex; background: var(--paper-2); border-radius: 10px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.sales-viewswitch button {
  border: none; background: none; padding: 7px 16px; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600; color: var(--muted);
}
.sales-viewswitch button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }

/* stage filter tabs */
.sales-stage-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 12px; }
.sales-stage-tabs button {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: 6px;
}
.sales-stage-tabs button i { font-style: normal; background: var(--paper-2); border-radius: 999px; padding: 1px 7px; font-size: 11px; color: var(--muted); }
.sales-stage-tabs button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.sales-stage-tabs button.active i { background: rgba(255,255,255,0.2); color: #fff; }

/* deal board grid */
.sales-deal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.sales-deal-card {
  text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
  font-family: inherit; box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .15s;
}
.sales-deal-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.sales-deal-top { display: flex; align-items: center; justify-content: space-between; }
.sales-deal-ape { font-size: 13px; font-weight: 700; color: var(--brand); }
.sales-deal-card strong { font-size: 15px; color: var(--ink); }
.sales-deal-cust { font-size: 13px; color: var(--ink-soft); }
.sales-deal-prod { font-size: 12px; color: var(--muted); }

/* customer list */
.sales-cust-list { display: flex; flex-direction: column; gap: 10px; }
.sales-cust-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; box-shadow: var(--shadow-sm);
}
.sales-cust-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sales-cust-main strong { font-size: 15px; color: var(--ink); }
.sales-cust-main span { font-size: 13px; color: var(--ink-soft); }
.sales-cust-deals { font-size: 12px !important; color: var(--muted) !important; }
.sales-cust-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.sales-cust-btn {
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 7px 14px; border-radius: 999px; border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  white-space: nowrap;
}
.sales-cust-btn:active { transform: scale(0.96); }
.sales-cust-btn.edit { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.sales-cust-btn.edit:hover { border-color: var(--brand); color: var(--brand); }
.sales-cust-btn.add { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.sales-cust-btn.add:hover { filter: brightness(1.05); }
.sales-cust-btn.del { background: transparent; border-color: #F0C9C1; color: var(--red); }
.sales-cust-btn.del:hover { background: #FBE5E1; border-color: #E39A8E; }
.sales-deal-info {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--bg-soft, #F6F5F1); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font-size: 13px; color: var(--ink-soft);
}
.sales-deal-info strong { color: var(--ink); font-weight: 600; }
.sales-deal-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sales-deal-appt { font-size: 12px; color: var(--ink-soft); }
.sales-deal-resched {
  font-size: 11px; font-weight: 600; color: var(--red);
  background: #FBE5E1; border-radius: 999px; padding: 2px 8px;
}

/* forms inside modal */
.sales-modal { max-width: 560px; width: 100%; }
.sales-form { display: flex; flex-direction: column; gap: 12px; }
.sales-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.sales-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sales-money-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sales-money-row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.sales-consent { flex-direction: row !important; align-items: flex-start; gap: 8px !important; background: var(--gold-tint); padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.sales-consent input { margin-top: 2px; }
.sales-consent span { font-size: 12.5px; color: var(--r); line-height: 1.45; }
.sales-hint { font-size: 12.5px; color: var(--t); background: #E7F0EB; padding: 8px 12px; border-radius: 8px; }
.sales-gps { font-size: 13px; padding: 9px 12px; border-radius: 8px; }
.sales-gps-loading { background: var(--paper-2); color: var(--muted); }
.sales-gps-ok { background: #E7F0EB; color: var(--t); }
.sales-gps-denied { background: #FBE5E1; color: var(--red); }

/* deal detail */
.sales-detail { max-width: 600px; }
.sales-detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); margin-bottom: 12px; }
.sales-detail-stats { display: flex; flex-wrap: wrap; gap: 18px; padding: 12px 0; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); margin-bottom: 14px; }
.sales-detail-stats div { display: flex; flex-direction: column; gap: 2px; }
.sales-detail-stats span { font-size: 11px; color: var(--muted); }
.sales-detail-stats strong { font-size: 16px; color: var(--ink); }
.sales-move-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.sales-move-label { font-size: 13px; color: var(--muted); margin-right: 4px; }
.sales-move-btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit; color: var(--ink-soft); }
.sales-move-btn:hover { border-color: var(--brand); color: var(--brand); }
.sales-detail-actions { margin-bottom: 16px; }
.sales-sub-h { font-size: 13px; font-weight: 700; color: var(--ink); margin: 14px 0 8px; }
.sales-timeline { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.sales-timeline li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.sales-timeline li em { margin-left: auto; font-style: normal; font-size: 11px; color: var(--muted); }
.sales-tl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: 0 0 auto; }
.sales-visit-list { display: flex; flex-direction: column; gap: 10px; }
.sales-visit-item { display: flex; gap: 10px; background: var(--paper-2); border-radius: 10px; padding: 10px; }
.sales-visit-thumbs { display: flex; gap: 4px; flex-wrap: wrap; }
.sales-visit-thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.recruit-file-chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border: 1px solid var(--line, #e3e0d8); border-radius: 8px; background: #F6F5F1; font-size: 13px; color: var(--ink, #2a2a2a); text-decoration: none; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sales-visit-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sales-visit-body p { margin: 0; font-size: 13px; color: var(--ink); }
.sales-visit-body em { font-style: normal; font-size: 11px; color: var(--muted); }

/* ---- admin panel ---- */
.sales-admin-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.sales-admin-tabs { margin-bottom: 0; padding-bottom: 0; flex: 0 1 auto; }
.sales-period-tabs { margin-bottom: 0; padding-bottom: 0; margin-left: auto; }
.sales-period-range { font-size: 12px; color: var(--muted); margin: -8px 0 14px; }
.sales-agent-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--gold-tint); color: var(--r); border-radius: 999px; padding: 5px 6px 5px 14px; font-size: 13px; margin-bottom: 14px; }
.sales-agent-chip strong { color: var(--ink); }
.sales-agent-chip button { border: none; background: var(--card); color: var(--ink-soft); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; font-family: inherit; }
.sales-agent-chip button:hover { color: var(--red); }
.sales-funnel { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.sales-funnel-h { margin: 0 0 2px; font-size: 13px; font-weight: 700; color: var(--muted); }
.sales-funnel-row { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 12px; }
.sales-funnel-label { display: flex; }
.sales-funnel-bar { background: var(--paper-2); border-radius: 8px; height: 22px; overflow: hidden; }
.sales-funnel-fill { height: 100%; border-radius: 8px; min-width: 22px; transition: width .4s ease; display: flex; align-items: center; justify-content: flex-end; padding-right: 7px; }
/* เลขในแท่ง: ใช้สีเข้มทุกแท่ง — สีขาวไม่ผ่าน AA บนสี fill อ่อน (เช่น #B7C2D2 ได้แค่ ~1.8:1) */
.sales-funnel-fill b { font-size: 11.5px; color: var(--ink); font-weight: 700; }
.sales-funnel-fill.st-prospect, .sac-mini i.st-prospect { background: #B7C2D2; }
.sales-funnel-fill.st-appointment, .sac-mini i.st-appointment { background: #7FA0CA; }
.sales-funnel-fill.st-meeting, .sac-mini i.st-meeting { background: #5FA38E; }
.sales-funnel-fill.st-presentation, .sac-mini i.st-presentation { background: var(--gold-soft); }
.sales-funnel-fill.st-won, .sac-mini i.st-won { background: #43A36B; }
.sales-funnel-fill.st-lost, .sac-mini i.st-lost { background: #D98477; }
.sales-funnel-fill.st-contact { background: #7FA0CA; }
.sales-funnel-fill.st-bop { background: #5FA38E; }
.sales-funnel-fill.st-interview { background: var(--gold-soft); }
.sales-funnel-fill.st-exam { background: #9575CD; }
.sales-funnel-num { font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; }
.sales-row-click { cursor: pointer; }
.sales-row-click:hover { background: var(--paper-2); }

/* การ์ดรายตัวแทน (แท็บภาพรวม sales tracking) */
.sales-agent-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.sales-agent-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color .15s, transform .15s; }
.sales-agent-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.sac-head { display: flex; align-items: flex-start; gap: 8px; }
.sac-head .agent-avatar { background: var(--paper-2); color: var(--ink-soft); font-weight: 700; }
.sac-name { min-width: 0; }
.sac-name strong { display: block; font-size: 14px; color: var(--ink); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sac-name span { font-size: 11.5px; color: var(--muted); }
.sac-badge { margin-left: auto; flex: 0 0 auto; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.sac-active, .sac-recent { background: #E7F0EB; color: var(--green); }
.sac-quiet { background: #FBE5E1; color: var(--red); }
.sac-none { background: var(--paper-2); color: var(--muted); }
.sac-mini { display: flex; gap: 3px; height: 36px; align-items: flex-end; margin: 10px 0 8px; }
.sac-mini i { flex: 1 1 0; border-radius: 3px 3px 0 0; background: var(--paper-2); }
.sac-stats { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); }
.sac-stats b { color: var(--ink); font-size: 12.5px; }
.sales-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.sales-gallery-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); }
.sales-gallery-imgs { display: flex; gap: 2px; height: 150px; background: var(--paper-2); }
.sales-gallery-imgs a { flex: 1 1 0; min-width: 0; }
.sales-gallery-imgs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sales-gallery-noimg { width: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.sales-gallery-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; }
.sales-gallery-body strong { font-size: 14px; color: var(--ink); }
.sales-gallery-body p { margin: 0; font-size: 13px; color: var(--ink-soft); }
.sales-gallery-body em { font-style: normal; font-size: 11px; color: var(--muted); }
.btn-danger { border: 1.5px solid var(--red); background: none; color: var(--red); border-radius: 10px; padding: 9px 20px; font-family: inherit; font-weight: 600; font-size: 14px; cursor: pointer; }
.btn-danger:hover { background: var(--red); color: #fff; }

/* ปุ่มพื้นฐาน (ใช้ในฟีเจอร์ออนบอร์ด 90 วัน) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 9px 18px;
  font-family: inherit; font-weight: 600; font-size: 14px;
  color: var(--ink); background: var(--card);
  border: 1.5px solid var(--line); border-radius: 10px;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--paper-2); border-color: var(--brand); color: var(--brand); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:disabled:hover { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn-primary { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; filter: brightness(.94); }
.btn-primary:disabled:hover { filter: none; }

@media (max-width: 720px) {
  .sales-summary { grid-template-columns: repeat(2, 1fr); }
  .sales-form-grid { grid-template-columns: 1fr; }
  .sales-money-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .sales-funnel-row { grid-template-columns: 80px 1fr; }
  .sales-funnel-num { grid-column: 2; text-align: right; }
  .sales-agent-cards { grid-template-columns: 1fr 1fr; }
}

/* --- LMS drag-and-drop reordering --- */
.lms-grip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  color: var(--muted, #9ca3af);
  font-size: 16px;
  line-height: 1;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.lms-grip:active { cursor: grabbing; }
.lms-grip-cell { width: 32px; text-align: center; }
/* The dragged item lifts and follows the pointer (transform set inline). */
.lms-row-dragging > td { background: var(--card, #fff); }
.lms-row-dragging {
  box-shadow: 0 12px 28px rgba(15, 26, 46, .22);
  opacity: .96;
  cursor: grabbing;
}
.lms-module-block.lms-block-dragging {
  box-shadow: 0 18px 40px rgba(15, 26, 46, .24);
  opacity: .96;
  cursor: grabbing;
}
/* Drop-position indicator line (in the gap where the item will land). */
.lms-drop-before > td,
.lms-module-block.lms-drop-before {
  box-shadow: inset 0 3px 0 0 var(--brand, #2563eb);
}
.lms-drop-after > td,
.lms-module-block.lms-drop-after {
  box-shadow: inset 0 -3px 0 0 var(--brand, #2563eb);
}
.lms-module-header .lms-grip { margin-right: 4px; }

/* ---- สรุปผลทีม (Team Summary Dashboard) ---- */
/* KPI hero */
.ts-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 18px 0; }
.ts-kpi { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 18px 16px 20px; box-shadow: var(--shadow-sm); overflow: hidden; }
.ts-kpi::before { content: ""; position: absolute; top: 0; left: 0; bottom: 0; width: 4px; background: var(--tone, var(--gold)); }
.ts-kpi-label { display: block; font-size: 12px; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.ts-kpi-val { display: block; font-family: 'Prompt', sans-serif; font-weight: 700; font-size: clamp(22px, 2.4vw, 30px); line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; margin-top: 7px; white-space: nowrap; }
.ts-kpi-unit { font-size: 11px; color: var(--muted); }
.ts-kpi.lead { background: linear-gradient(180deg, var(--gold-tint), var(--card) 72%); border-color: var(--gold-soft); }
.ts-kpi.lead .ts-kpi-val { color: var(--gold); }

/* shared card */
.ts-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
/* เป้าหมาย APE ประจำเดือน + นับถอยหลัง */
.ts-target-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.ts-target-head h3 { margin: 0; font-family: 'Prompt', sans-serif; font-size: 16px; font-weight: 600; color: var(--ink); }
.ts-target-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ts-target-controls .overview-select { width: auto; min-width: 150px; }
.ts-target-head .overview-select { width: auto; min-width: 150px; }
.ts-target-input { display: flex; gap: 8px; flex-wrap: wrap; }
.ts-target-input .form-input { width: 180px; }
.ts-target-note { margin-top: 14px; color: var(--muted); font-size: 14px; }
.ts-target-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 14px; }
.ts-target-stats > div { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; background: var(--paper-2); border-radius: 12px; }
.ts-target-stats span { font-size: 12px; color: var(--muted); }
.ts-target-stats strong { font-family: 'Prompt', sans-serif; font-size: 24px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.ts-target-stats .remain strong { color: var(--red); }
.ts-target-stats .reached strong { color: var(--green, #2f9e5b); }
.ts-target-bar { height: 14px; background: var(--paper-2); border-radius: 999px; overflow: hidden; }
.ts-target-fill { height: 100%; background: var(--gold); border-radius: 999px; transition: width 400ms ease; }
.ts-target-fill.done { background: var(--green, #2f9e5b); }
.ts-target-foot { margin-top: 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.ts-target-msg { margin-top: 10px; font-size: 13px; color: var(--ink-soft); }
/* แอดมิน: ตั้งเป้าแยกราย unit */
.ts-target-list { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.ts-target-row { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2); }
.ts-target-row-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ts-target-team { font-family: 'Prompt', sans-serif; font-size: 15px; font-weight: 600; color: var(--ink); }
.ts-target-team-val { font-family: 'Prompt', sans-serif; font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.ts-target-team-val.remain { color: var(--danger, #d9534f); }
.ts-target-row .ts-target-input .form-input { width: 150px; }
.ts-target-row .ts-target-bar { margin-top: 12px; }
.ts-target-rowfoot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.ts-target-rowfoot .remain { color: var(--red); font-weight: 600; }
.ts-target-rowfoot .reached { color: var(--green, #2f9e5b); font-weight: 600; }
@media (max-width: 560px) { .ts-target-stats { grid-template-columns: 1fr; } }

/* ---- แข่งขัน ทีม vs ทีม (Team Competition) ---- */
.modal-box-wide { max-width: 760px; }

.tc-vs-card { background: var(--card); border: 1px solid var(--gold-soft); border-radius: 16px; padding: 22px; box-shadow: var(--shadow-sm); background-image: linear-gradient(180deg, var(--gold-tint), var(--card) 70%); }
.tc-vs-name { font-family: 'Prompt', sans-serif; font-weight: 700; font-size: 16px; color: var(--ink); }
.tc-vs-captain { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tc-vs-foot { text-align: center; margin-top: 10px; font-size: 12px; color: var(--muted); }
.tc-vs-banner { text-align: center; margin-top: 14px; font-family: 'Prompt', sans-serif; font-weight: 700; font-size: 15px; color: var(--brand-strong); }
.tc-vs-rules { margin-top: 14px; padding: 12px 14px; background: var(--paper-2); border-radius: 10px; font-size: 13px; color: var(--ink-soft); white-space: pre-wrap; }

.tc-vs-sides { display: flex; align-items: center; justify-content: center; gap: 0; }
.tc-vs-side { flex: 1; text-align: center; }
.tc-vs-side .avatar-circle { margin: 0 auto 8px; }
.tc-vs-mid { width: 70px; text-align: center; font-family: 'Prompt', sans-serif; font-weight: 800; color: var(--gold); font-size: 20px; }
.tc-vs-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--paper-2); margin-top: 16px; }
.tc-vs-bar-a, .tc-vs-bar-b { height: 100%; }
.tc-vs-values { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); margin-top: 6px; font-variant-numeric: tabular-nums; }

.tc-lb-list { display: flex; flex-direction: column; gap: 12px; }
.tc-lb-row { display: flex; align-items: center; gap: 12px; }
.tc-lb-rank { width: 24px; height: 24px; border-radius: 50%; background: var(--paper-2); color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.tc-lb-rank.top { background: var(--gold); color: var(--ink); }
.tc-lb-info { flex: 1; min-width: 0; }
.tc-lb-bar-track { height: 10px; border-radius: 6px; background: var(--paper-2); overflow: hidden; margin-top: 6px; }
.tc-lb-bar-fill { height: 100%; border-radius: 6px; transition: width 200ms ease; }
.tc-lb-value { font-size: 13px; font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; }

.tc-participants { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--line); }
.tc-p-col-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 8px; }
.tc-p-list { display: flex; flex-direction: column; gap: 6px; }
.tc-p-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px; background: var(--paper-2); font-size: 13px; }
.tc-p-row.top { background: var(--gold-tint); border: 1px solid var(--gold-soft); }
.tc-p-mini-avatar { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; }
.tc-p-mini-avatar.has-photo { background-size: cover; background-position: center; }
.tc-p-name { flex: 1; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-p-val { font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.tc-p-empty { font-size: 12px; color: var(--muted); padding: 8px 10px; }
@media (max-width: 520px) { .tc-participants { grid-template-columns: 1fr; } }

.tc-list { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.tc-list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; transition: border-color 160ms ease; }
.tc-list-row:hover { border-color: var(--brand-soft); }
.tc-list-row.active { border-color: var(--brand); background: var(--paper-2); }
.tc-list-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.tc-list-range { font-size: 12px; color: var(--muted); }

.tc-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.tc-pill { border: 1.5px solid var(--line); background: #fff; color: var(--muted); font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.tc-pill.on { border-color: var(--brand-strong); background: var(--brand-strong); color: #fff; }

.tc-logo-picker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tc-logo-preview { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); flex-shrink: 0; }
.tc-logo-placeholder { width: 56px; height: 56px; border-radius: 50%; border: 2px dashed var(--line); display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); flex-shrink: 0; }

.tc-agent-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--gold-tint); color: var(--r); border-radius: 999px; padding: 5px 6px 5px 14px; font-size: 13px; }
.tc-agent-chip strong { color: var(--ink); }
.tc-agent-chip button { border: none; background: var(--card); color: var(--ink-soft); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; font-family: inherit; }
.tc-agent-chip button:hover { color: var(--r); }
.tc-agent-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tc-agent-picker-list { max-height: 180px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.tc-agent-picker-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.tc-agent-picker-row:hover { background: var(--paper-2); }
.tc-agent-picker-row.picked { background: var(--gold-tint); }
.tc-agent-picker-row.disabled { opacity: 0.4; cursor: not-allowed; }

.tc-form-teams { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.tc-form-team { position: relative; border: 1.5px solid var(--brand-soft); border-radius: 12px; padding: 14px; }
.tc-form-team-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.tc-form-team-remove { position: absolute; top: 10px; right: 10px; }
.tc-form-add-team { margin-top: 12px; }
@media (max-width: 640px) { .tc-form-teams { grid-template-columns: 1fr; } }
.ts-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.ts-card-head h3 { margin: 0; font-family: 'Prompt', sans-serif; font-size: 16px; font-weight: 600; color: var(--ink); }

/* segmented control */
.ts-seg { display: inline-flex; gap: 3px; background: var(--paper-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 3px; }
.ts-seg-btn { border: 0; background: transparent; color: var(--ink-soft); border-radius: 999px; padding: 5px 14px; font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer; transition: color .15s ease, background .15s ease; }
.ts-seg-btn:hover { color: var(--ink); }
.ts-seg-btn.active { background: var(--card); color: var(--tone, var(--gold)); box-shadow: var(--shadow-sm); }

/* comparison bars */
.ts-bars { display: flex; flex-direction: column; gap: 11px; }
.ts-bar { display: grid; grid-template-columns: 132px 1fr 100px; align-items: center; gap: 12px; }
.ts-bar-name { font-size: 13px; color: var(--ink-soft); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-bar-track { background: var(--paper-2); border-radius: 999px; height: 12px; overflow: hidden; }
.ts-bar-fill { height: 100%; border-radius: 999px; min-width: 3px; background: var(--tone, var(--gold)); transition: width .45s cubic-bezier(.2,.7,.2,1); }
.ts-bar-val { font-family: 'Prompt', sans-serif; font-size: 13px; font-weight: 600; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
/* เส้นเป้าหมายบนแท่งกราฟ (เฉพาะ APE) */
.ts-bar-track { position: relative; }
.ts-bar-target { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--red); transform: translateX(-50%); z-index: 2; }
.ts-bar-fill.reached { background: var(--green, #2f9e5b); }
.ts-bar-tgt { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.ts-bar-tgt.reached { color: var(--green, #2f9e5b); }

/* ranked sortable table (CSS grid) */
.ts-table { padding: 6px; }
.ts-table-scroll { overflow-x: auto; }
.ts-row { display: grid; grid-template-columns: 46px minmax(150px, 1.7fr) repeat(4, minmax(66px, 1fr)) 34px; align-items: center; gap: 8px; }
.ts-head { padding: 8px 12px; border-bottom: 1px solid var(--line); min-width: 600px; }
.ts-head > .ts-c-rank, .ts-head > .ts-c-team { font-size: 12px; font-weight: 600; color: var(--muted); }
.ts-sort { font-family: inherit; background: transparent; border: 0; cursor: pointer; text-align: right; padding: 4px 2px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--muted); transition: color .15s ease; }
.ts-sort:hover { color: var(--ink); }
.ts-sort.active { color: var(--gold); }

.ts-trow { width: 100%; min-width: 600px; background: transparent; border: 0; border-bottom: 1px solid var(--line-2); padding: 12px; cursor: pointer; text-align: left; font-family: inherit; transition: background .15s ease; }
.ts-trow:hover { background: var(--paper); }
.ts-trow.open { background: var(--gold-tint); }
.ts-trow.open .ts-c-caret { color: var(--gold); }
.ts-c-rank { display: flex; justify-content: center; }
.ts-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 8px; font-family: 'Prompt', sans-serif; font-size: 13px; font-weight: 700; color: var(--ink); background: color-mix(in srgb, var(--tone, var(--line)) 20%, white); border: 1px solid color-mix(in srgb, var(--tone, var(--line)) 50%, white); }
.ts-c-team { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ts-c-team strong { font-size: 15px; color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-c-team em { font-size: 11.5px; color: var(--muted); font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-c-num { text-align: right; font-family: 'Prompt', sans-serif; font-size: 14px; font-weight: 500; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.ts-c-num.active { color: var(--ink); font-weight: 700; }
.ts-c-caret { text-align: center; color: var(--muted); font-size: 11px; }

/* expanded per-agent rows */
.ts-agents { background: var(--paper); border-bottom: 1px solid var(--line-2); padding: 4px 0; }
.ts-arow { padding: 9px 12px 9px 12px; }
.ts-arow .ts-c-team { padding-left: 14px; border-left: 2px solid var(--gold-soft); }
.ts-arow .ts-c-team strong { font-size: 13.5px; font-weight: 500; }
.ts-arow .ts-c-num { font-size: 13px; }
.ts-empty { text-align: center; padding: 22px; color: var(--muted); font-size: 13px; }

@media (max-width: 720px) {
  .ts-kpis { grid-template-columns: repeat(2, 1fr); }
  .ts-bar { grid-template-columns: 96px 1fr 76px; }
}
/* iPad portrait (768–960): 4-up KPI/summary rows are too tight; drop to 2-up */
@media (min-width: 721px) and (max-width: 960px) {
  .ts-kpis { grid-template-columns: repeat(2, 1fr); }
  .sales-summary { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Admin · กิจกรรม (Activities manage) ---- */
.act-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.act-toolbar .search-input { flex: 1; min-width: 200px; }
.act-add { margin-left: auto; border: 0; background: var(--brand-strong); color: #fff; font-family: inherit; font-weight: 600; font-size: 14px; padding: 10px 18px; border-radius: 12px; cursor: pointer; box-shadow: var(--shadow-sm); transition: filter .15s ease, transform .05s ease; white-space: nowrap; }
.act-add:hover { filter: brightness(1.06); }
.act-add:active { transform: translateY(1px); }
.act-add:disabled { opacity: .6; cursor: default; }

.act-group { margin-bottom: 26px; }
.act-group-head { display: flex; align-items: center; gap: 8px; font-family: 'Prompt', sans-serif; font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 14px; }
.act-group-head em { font-style: normal; font-weight: 600; font-size: 12px; color: var(--muted); background: var(--paper-2); border-radius: 999px; padding: 1px 9px; }
.act-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.act-dot.up { background: var(--gold); }
.act-dot.past { background: var(--muted); }

.act-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.acm-card { display: grid; grid-template-columns: 92px 1fr; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow-sm); transition: box-shadow .18s ease, opacity .18s ease; }
.acm-card:hover { box-shadow: var(--shadow-md); }
.acm-card.past { opacity: .64; }
.acm-card.past:hover { opacity: 1; }

.act-poster { width: 92px; height: 92px; border-radius: 12px; overflow: hidden; border: 0; padding: 0; cursor: pointer; background: var(--paper-2); display: block; }
.act-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.act-poster.empty { display: flex; align-items: center; justify-content: center; border: 1px dashed var(--line); color: var(--muted); font-size: 11px; cursor: default; text-align: center; padding: 4px; }

.act-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.act-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.act-countdown { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.act-countdown.soon { background: var(--gold); color: #fff; }
.act-countdown.up { background: var(--gold-tint); color: var(--gold); }
.act-countdown.past, .act-countdown.none { background: var(--paper-2); color: var(--muted); }
.act-loc { font-size: 11.5px; color: var(--ink-soft); background: var(--paper-2); border-radius: 999px; padding: 2px 9px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-vis { font-size: 11px; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.act-vis.mgr { color: var(--s); border-color: color-mix(in srgb, var(--s) 40%, white); background: color-mix(in srgb, var(--s) 8%, white); }
.act-title { margin: 2px 0 0; font-family: 'Prompt', sans-serif; font-size: 16px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.act-desc { margin: 0; font-size: 13px; color: var(--ink-soft); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.act-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 10px; flex-wrap: wrap; }
.acm-meta { display: flex; gap: 18px; }
.acm-meta > div { display: flex; flex-direction: column; gap: 1px; }
.acm-meta span { font-size: 10.5px; color: var(--muted); }
.acm-meta strong { font-size: 12.5px; color: var(--ink); font-weight: 600; }
.act-actions { display: flex; gap: 8px; }

.act-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 48px 24px; background: var(--card); border: 1px dashed var(--line); border-radius: 16px; }
.act-empty-icon { font-size: 34px; line-height: 1; margin-bottom: 4px; }
.act-empty strong { font-family: 'Prompt', sans-serif; font-size: 16px; color: var(--ink); }
.act-empty span { font-size: 13px; color: var(--muted); }
.act-empty .act-add { margin: 10px 0 0; }

@media (max-width: 560px) {
  .act-list { grid-template-columns: 1fr; }
  .act-add { margin-left: 0; }
  .act-toolbar .search-input { min-width: 0; }
}

/* ===== ออนบอร์ด 90 วัน (ported) ===== */
.ob-loading, .ob-empty { padding: 24px; color: var(--muted); text-align: center; }
.ob-locked { text-align: center; padding: 48px 16px; color: var(--muted); }
.ob-locked-icon { font-size: 40px; margin-bottom: 12px; }

.ob-header { margin-bottom: 20px; }
.ob-day { font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.ob-progress-bar { background: var(--paper-2); border-radius: 999px; height: 12px; overflow: hidden; border: 1px solid var(--line-2); }
.ob-progress-bar.sm { height: 8px; width: 90px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.ob-progress-bar > span { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width .3s; }
.ob-progress-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

.ob-phase { margin: 18px 0; }
.ob-phase-title { font-size: 15px; color: var(--brand); border-bottom: 1px solid var(--line); padding-bottom: 6px; }

.ob-milestone { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; background: var(--card); box-shadow: var(--shadow-sm); }
.ob-milestone.ob-approved { border-left-color: var(--green); }
.ob-milestone.ob-pending_approval { border-left-color: var(--gold); }
.ob-milestone.ob-overdue { border-left-color: var(--red); }

.ob-ms-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ob-ms-title { font-weight: 600; color: var(--ink); }
.ob-ms-badge { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--paper-2); color: var(--ink-soft); border: 1px solid var(--line-2); }
.ob-approved .ob-ms-badge { background: #e6f2ee; color: var(--green); }
.ob-pending_approval .ob-ms-badge { background: var(--gold-tint); color: var(--r); }
.ob-overdue .ob-ms-badge { background: #FBE5E1; color: var(--red); }

.ob-items { list-style: none; margin: 0; padding: 0; }
.ob-item { padding: 4px 0; color: var(--ink-soft); }
.ob-item label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.ob-item.done span { text-decoration: line-through; color: var(--muted); }
.ob-auto { font-size: 11px; color: var(--s); margin-left: 6px; font-style: normal; }

/* แผน 90 วัน (การ์ดตัวแทน) — hero + เส้นทางเดินแนวตั้ง */
.ob90 { max-width: 640px; margin-left: auto; margin-right: auto; }

/* scrim ดำ 40% ทับสีแบรนด์ของ tenant (var(--brand)) เพื่อให้ตัวหนังสือขาวผ่าน WCAG AA ไม่ว่าแบรนด์จะเป็นสีอะไร */
.ob90-hero { background-image: linear-gradient(rgba(0,0,0,.4), rgba(0,0,0,.4)); background-color: var(--brand); border-radius: 16px; padding: 20px 22px; color: #fff; margin-bottom: 22px; box-shadow: var(--shadow-md); }
.ob90-hero-eyebrow { font-size: 12px; opacity: .85; letter-spacing: .04em; }
.ob90-hero-day { font-size: 26px; font-weight: 700; margin: 4px 0 12px; }
.ob90-hero-bar { height: 10px; background: rgba(255,255,255,.28); border-radius: 999px; overflow: hidden; }
.ob90-hero-bar > span { display: block; height: 100%; background: #fff; border-radius: 999px; transition: width .3s; }
.ob90-hero-row { display: flex; justify-content: space-between; font-size: 13px; margin-top: 8px; opacity: .95; font-variant-numeric: tabular-nums; }

.ob90-phase-title { font-size: 13px; font-weight: 700; color: var(--brand); margin: 0 0 8px 2px; letter-spacing: .02em; text-transform: uppercase; }

.ob90-rail-wrap { display: flex; gap: 14px; }
.ob90-rail { width: 20px; display: flex; flex-direction: column; align-items: center; padding-top: 4px; flex-shrink: 0; }
.ob90-dot { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; box-sizing: border-box; }
.ob90-dot-done { background: var(--brand); border: 3px solid var(--gold-tint); }
.ob90-dot-current { background: #fff; border: 3px solid var(--brand); box-shadow: 0 0 0 3px rgba(0,0,0,.15); }
.ob90-dot-upcoming { background: var(--paper-2); border: 3px solid var(--line); }
.ob90-dot-overdue { border-color: var(--red); box-shadow: 0 0 0 3px rgba(217,84,63,.2); }
.ob90-seg { width: 2px; flex: 1; min-height: 24px; background: var(--line); margin: 2px 0; }
.ob90-seg-done { background: var(--brand); }
.ob90-seg-overdue { background: var(--red); }

.ob90-steps { flex: 1; min-width: 0; }
.ob90-step { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.ob90-step.ob90-overdue { border-left: 4px solid var(--red); }
.ob90-step-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.ob90-step-title { font-weight: 600; font-size: 14px; color: var(--ink); }
.ob90-badge { font-size: 11px; padding: 2px 10px; border-radius: 999px; font-weight: 600; background: var(--paper-2); color: var(--ink-soft); border: 1px solid var(--line-2); white-space: nowrap; }
.ob90-approved .ob90-badge { background: #e6f2ee; color: var(--green); border-color: transparent; }
.ob90-pending_approval .ob90-badge { background: var(--gold-tint); color: #9a7b1f; border-color: transparent; }
.ob90-overdue .ob90-badge { background: #FBE5E1; color: var(--red); border-color: transparent; }

.ob90-items { list-style: none; margin: 4px 0 0; padding: 0; }
.ob90-item { padding: 3px 0; color: var(--ink-soft); font-size: 13px; }
.ob90-item label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.ob90-item input { accent-color: var(--brand); width: 15px; height: 15px; }
.ob90-item.done span { text-decoration: line-through; color: var(--muted); }

@media (max-width: 720px) {
  .ob90-hero { padding: 16px 18px; }
  .ob90-hero-day { font-size: 22px; }
  .ob90-rail { width: 16px; }
  .ob90-dot { width: 13px; height: 13px; }
  .ob90-rail-wrap { gap: 10px; }
}

/* ---- ออนบอร์ด 90 วัน: หน้าติดตาม (roster redesign) ---- */
.ob-admin-hero {
  background: linear-gradient(135deg, var(--card) 0%, var(--paper-2) 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 24px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.ob-hero-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.ob-hero-eyebrow {
  font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--brand); font-weight: 700; margin-bottom: 4px;
}
.ob-hero-title { margin: 0; font-size: 24px; font-weight: 700; color: var(--ink); display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ob-hero-unit { font-size: 14px; font-weight: 600; color: var(--ink-soft); background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; }

.ob-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 20px; }
.ob-stat {
  background: var(--card); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 2px;
  border-top: 3px solid var(--line);
}
.ob-stat-num { font-size: 26px; font-weight: 700; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.ob-stat-lbl { font-size: 12px; color: var(--muted); }
.ob-stat-active { border-top-color: var(--green); }
.ob-stat-active .ob-stat-num { color: var(--green); }
.ob-stat-idle { border-top-color: var(--muted); }
.ob-stat-late { border-top-color: var(--line); }
.ob-stat-late.on { border-top-color: var(--red); background: #fdf5f3; }
.ob-stat-late.on .ob-stat-num { color: var(--red); }

.ob-roster { display: flex; flex-direction: column; gap: 10px; }
.ob-card {
  display: grid;
  grid-template-columns: 46px minmax(150px, 1.4fr) minmax(160px, 1.6fr) auto auto;
  align-items: center; gap: 16px;
  background: var(--card); border: 1px solid var(--line-2); border-radius: 14px;
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s, transform .18s, border-color .18s;
}
.ob-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--line); }
.ob-card-idle { background: var(--paper); border-style: dashed; }

.ob-ava {
  width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff; user-select: none; overflow: hidden; flex-shrink: 0;
}
.ob-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ob-ava-active { background: linear-gradient(135deg, var(--green), #3f8674); }
.ob-ava-done   { background: linear-gradient(135deg, var(--brand), var(--gold-soft)); }
.ob-ava-late   { background: linear-gradient(135deg, var(--red), #d16a58); }
.ob-ava-idle   { background: var(--paper-2); color: var(--muted); border: 1px solid var(--line); }

.ob-card-id { min-width: 0; }
.ob-card-name { font-size: 16px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ob-card-sub { display: flex; align-items: center; gap: 8px; margin-top: 3px; flex-wrap: wrap; }
.ob-day-chip { font-size: 12px; font-weight: 600; color: var(--brand); background: var(--gold-tint); border-radius: 6px; padding: 1px 8px; font-variant-numeric: tabular-nums; }
.ob-ms-current { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ob-not-started { font-size: 13px; color: var(--muted); font-style: italic; }

.ob-card-prog { min-width: 0; }
.ob-prog-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.ob-prog-pct { font-size: 15px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.ob-prog-frac { font-size: 12px; color: var(--muted); }
.ob-prog-empty { color: var(--line); font-size: 20px; text-align: center; }
.ob-progress-bar.lg { height: 10px; width: 100%; display: block; }
.ob-bar-late > span { background: var(--red); }
.ob-bar-done > span { background: var(--brand); }

.ob-card-flags { display: flex; justify-content: flex-end; }
.ob-flag-late { font-size: 12px; font-weight: 700; color: var(--red); background: #FBE5E1; border: 1px solid #f0c9c1; border-radius: 999px; padding: 3px 11px; white-space: nowrap; }

.ob-card-action { justify-self: end; }
.ob-card-action .btn { white-space: nowrap; }

@media (max-width: 720px) {
  .ob-stats { grid-template-columns: repeat(2, 1fr); }
  .ob-card { grid-template-columns: 40px 1fr auto; grid-template-areas: "ava id action" "prog prog prog" "flags flags flags"; row-gap: 12px; }
  .ob-ava { grid-area: ava; width: 40px; height: 40px; font-size: 18px; }
  .ob-card-id { grid-area: id; }
  .ob-card-prog { grid-area: prog; }
  .ob-card-flags { grid-area: flags; justify-content: flex-start; }
  .ob-card-action { grid-area: action; }
}

.ob-overdue-count { color: var(--red); font-weight: 700; }
.ob-admin-detail h2 { margin: 12px 0; }
.ob-tmpl-ms { margin: 14px 0; }
.ob-tmpl-ms h3 { font-size: 14px; color: var(--ink-2); }
.ob-tmpl-ms ul { list-style: none; margin: 6px 0; padding: 0; }
.ob-tmpl-ms li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 7px 0; color: var(--ink-soft); border-bottom: 1px solid var(--line-2); }
.ob-tmpl-ms li > span:first-child { flex: 1; min-width: 120px; }

/* ปุ่มเล็กในตัวแก้แม่แบบ */
.btn-xs {
  min-height: 30px; padding: 4px 12px;
  font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--ink-soft); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.btn-xs:hover { background: var(--paper-2); border-color: var(--brand); color: var(--brand); }

/* ============================================================
   System-wide additions (frontend/UI review fixes)
   ============================================================ */

/* Global reduced-motion safety net. The scattered per-component blocks only
   covered ~4 of 18 animations (bell/badge/pending/shimmer pulses kept looping).
   This neutralises all animation/transition for users who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Toast / snackbar (shared, defined in components.jsx <ToastHost/>) ---- */
.ui-toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}
.ui-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--ink);
  color: #F4F5F7;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  line-height: 1.4;
  border: 1px solid rgba(255,255,255,0.08);
  animation: ui-toast-in 0.22s ease-out;
}
@keyframes ui-toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ui-toast.ok    { background: #1F5E45; }
.ui-toast.error { background: #8A2F23; }
.ui-toast-icon { flex: none; margin-top: 1px; font-weight: 700; }
.ui-toast-msg { flex: 1; }
.ui-toast-close {
  flex: none; background: transparent; border: 0; color: inherit;
  opacity: 0.7; cursor: pointer; font-size: 16px; line-height: 1;
  padding: 2px 4px; border-radius: 6px; min-width: 24px; min-height: 24px;
}
.ui-toast-close:hover { opacity: 1; }

/* ---- Styled confirm dialog (reuses modal shell) ---- */
.ui-confirm-msg { font-size: 15px; line-height: 1.55; color: var(--ink); margin: 4px 0 4px; }
.ui-confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.ui-confirm-danger {
  background: var(--red); border: 1px solid var(--red); color: #fff;
  padding: 9px 16px; border-radius: 9px; cursor: pointer; font-weight: 600;
}
.ui-confirm-danger:hover { filter: brightness(.94); }
.ui-confirm-danger:disabled { opacity: .6; cursor: default; filter: none; }

/* ============================================================================
   Mobile horizontal top-nav refinements (ครอบทุกกรณีที่ sidebar เป็นแถบบน)
   - แยกกลุ่ม utility (ออกจากระบบ / หน้าหลัก) ออกจากแท็บเนื้อหา ไม่ให้ดูเป็นปุ่มหลัก
   - ไม่เฟดขอบ nav ของ public app (ไม่ได้เลื่อน)
   - โชว์ปุ่ม ▲▼ จัดลำดับ Module (แทน drag) บนมือถือ
   ============================================================================ */
@media (max-width: 760px),
       (max-height: 500px) and (orientation: landscape),
       (min-width: 761px) and (max-width: 1100px) and (orientation: portrait) {
  /* utility cluster: โปร่ง + สีจาง ไม่แย่งความเด่นจากแท็บเนื้อหา */
  .sidebar .logout-btn,
  .sidebar .home-link {
    width: 60px;
    background: transparent;
    border-color: transparent;
    color: rgba(255, 255, 255, 0.62);
  }
  .sidebar .logout-btn { color: #ffab99; }        /* โทน danger อ่อน */
  .sidebar .logout-btn:hover,
  .sidebar .home-link:hover { background: rgba(255, 255, 255, 0.06); }
  /* เส้นคั่นก่อนกลุ่ม utility (logout เป็นชิ้นแรกของ sidebar-foot) */
  .sidebar .logout-btn {
    position: relative;
    margin-left: 10px;
  }
  .sidebar .logout-btn::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 14px;
    bottom: 14px;
    width: 1px;
    background: rgba(255, 255, 255, 0.16);
  }
  /* public app nav เต็มความกว้าง ไม่ได้เลื่อน — ไม่ต้องเฟดขอบ */
  .public-app .sidebar {
    -webkit-mask-image: none;
    mask-image: none;
  }
  /* Module reorder: ปุ่ม ▲▼ สำหรับสัมผัส (desktop ใช้ drag) */
  .lms-module-move { display: flex; }
}

/* ===== Willing & Ability Matrix (admin) ===== */
.wa-std-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 14px 18px;
  margin-bottom: 14px;
  display: grid;
  gap: 10px;
}
.wa-std-row {
  display: grid;
  grid-template-columns: 220px 1fr 140px;
  align-items: center;
  gap: 12px;
}
.wa-std-row label { font-size: 13px; color: var(--ink-soft); }
.wa-std-row input[type="range"] { width: 100%; accent-color: var(--brand-strong); }
.wa-std-row strong { font-size: 14px; color: var(--ink); text-align: right; }
.wa-std-save { display: flex; align-items: center; gap: 12px; }
.wa-std-msg { font-size: 13px; color: var(--brand-strong); }
.wa-chart-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 12px;
  margin-bottom: 14px;
}
.wa-chart { width: 100%; height: auto; display: block; }
.wa-q-label { font-size: 12px; text-anchor: middle; font-weight: 600; }
.wa-dot { cursor: pointer; }
.wa-dot:focus { outline: none; }
.wa-dot:focus circle { stroke: var(--ink); stroke-width: 2; }
.wa-dot-name {
  font-size: 11px;
  fill: var(--ink-2);
  text-anchor: middle;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3px;
  stroke-linejoin: round;
}
.wa-axis { font-size: 11px; fill: var(--muted); }
.wa-axis-title { font-size: 12px; fill: var(--ink-soft); }
.wa-hint {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 10px 4px;
}
.wa-quad-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.wa-quad-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--tone);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 10px 14px;
  display: grid;
  gap: 2px;
}
.wa-quad-card .wa-quad-name { font-size: 12px; font-weight: 600; }
.wa-quad-card strong { font-size: 20px; color: var(--ink); }
.wa-quad-card em { font-size: 11px; color: var(--muted); font-style: normal; }
.wa-detail-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 14px 18px;
  margin-bottom: 14px;
}
.wa-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.wa-detail-head strong { font-size: 16px; color: var(--ink); }
.wa-detail-head > span { font-size: 13px; color: var(--muted); }
.wa-detail-quad { font-weight: 600; }
.wa-detail-body { display: grid; gap: 6px; }
.wa-detail-label {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
  margin-right: 8px;
}
.wa-detail-stage {
  display: inline-block;
  background: var(--paper-2);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--ink-2);
  margin: 2px 4px 2px 0;
}
.wa-detail-ability span:last-child { font-size: 13px; color: var(--ink-2); }
@media (max-width: 760px) {
  .wa-std-row { grid-template-columns: 1fr; gap: 4px; }
  .wa-std-row strong { text-align: left; }
  .wa-quad-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ===== Willing & Ability — view toggle + Trend chart ===== */
.wa-view-toggle {
  display: inline-flex;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.wa-view-toggle button {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.wa-view-toggle button.active {
  background: var(--s);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.wa-view-toggle button:not(.active):hover { color: var(--ink); }
.wa-trend-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 12px;
}
.wa-trend-head strong { font-size: 16px; color: var(--ink); margin-right: 8px; }
.wa-trend-head > div > span { font-size: 13px; color: var(--muted); }
.wa-trend-legend { display: flex; gap: 14px; }
.wa-lg {
  font-size: 12px;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.wa-lg::before {
  content: "";
  width: 14px;
  height: 3px;
  border-radius: 2px;
}
.wa-lg-w::before { background: var(--gold-strong); }
.wa-lg-a::before { background: var(--s); }
.wa-trend-chart { width: 100%; height: auto; display: block; }
.wa-tip-t { font-size: 11px; fill: #fff; font-weight: 600; }
.wa-tip-s { font-size: 10px; fill: var(--muted-on-dark); }
.wa-trend-note { font-size: 12px; color: var(--muted); padding: 8px 6px 2px; }
.wa-trend-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 44px 20px;
  text-align: center;
}
.wa-trend-empty p { font-size: 14px; color: var(--ink-soft); max-width: 420px; }
.wa-trend-link {
  border: none;
  background: transparent;
  color: var(--s);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}
.wa-trend-link:hover { text-decoration: underline; }

/* ===== Point rules admin modal (จัดการกติกาการรับคะแนน) ===== */
.prm-box { max-width: 720px; width: 100%; }
.prm-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; max-height: 60vh; overflow-y: auto; }
.prm-row { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; flex-wrap: wrap; }
.prm-order { display: flex; flex-direction: column; gap: 2px; }
.prm-order button { width: 22px; height: 18px; font-size: 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); cursor: pointer; }
.prm-order button:disabled { opacity: .35; cursor: default; }
.prm-label { flex: 2 1 160px; min-width: 120px; }
.prm-note { flex: 1 1 100px; min-width: 90px; }
.prm-points { flex: 0 0 90px; width: 90px; }
.prm-active { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
