: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;
  --brand-tint: #FBF0EC;
  --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: ลิงก์ออกไปหน้าแรก (public) — โทนจางกว่าแท็บ panel
   + ลูกศร ↗ บอกว่าเป็นทางออก ไม่ใช่หน้าใน panel (ไม่มี state .active) */
.nav-item-home {
  color: var(--muted-on-dark);
  text-decoration: none;
}
.nav-item-home .nav-ext {
  margin-left: auto;
  display: inline-flex;
  opacity: 0.55;
}
.nav-item-home .nav-ext svg { width: 13px; height: 13px; }
.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 {
    width: 46px;
    height: 46px;
    padding: 0;
    margin: 0;
    justify-content: center;
  }
  .app-shell.sidebar-collapsed .nav-item-home .nav-ext { display: none; }
}
.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;
  }
}

/* ===== ระยะขอบของ "หนึ่งหน้า" — จุดเดียวของทั้งระบบ =====
   ระบบมีเปลือกแผงอยู่ 3 แบบตามประวัติการเขียน: section.scene (~30 หน้า),
   .admin-panel (การเงิน / เอกสารฝั่งแอดมิน / โปรไฟล์ / ช่วยเหลือ / หน้าเมนูปิด)
   และ .oc-wrap (ผังองค์กร) — ทั้งสามต้องได้ระยะขอบชุดเดียวกัน ไม่งั้นสลับเมนูแล้ว
   เนื้อหาขยับซ้าย-ขวาให้เห็น จึงมัดไว้ในกฎเดียวกันทั้ง 3 ช่วงจอ (ที่นี่ / ≤1100 / ≤760)
   ⚠️ เปลือกเป็นคนถือระยะขอบ ห้ามให้ลูกถือเอง — ลูกที่ใส่ padding ซ้าย-ขวาเองจะบวก
   ซ้อนกันเป็น 80px และคนที่เพิ่มลูกใหม่แล้วลืมใส่ก็จะได้กล่องที่ชนขอบ sidebar */
section.scene,
.admin-panel,
.oc-wrap { padding: 48px 48px 32px; }

section.scene {
  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(--green); /* ทองเดิมจางบนพื้นครีม */
}
.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;
  }
}

/* Team Posters — brand-controlled editorial studio */
/* Quota meter: state reads from color before the numbers are parsed, so the semantic
   green/amber/red scale stays separate from --brand (which owns the primary action). */
@media(prefers-reduced-motion:reduce){.poster-quota-bar span{transition:none}}
@media(max-width:900px){.poster-layout{grid-template-columns:1fr}.poster-preview{order:-1}.poster-preview img{max-height:58vh}}@media(max-width:520px){.poster-layout{padding:0 16px}.poster-quota{margin-left:16px;width:auto;min-width:0;max-width:calc(100% - 32px);border-radius:12px}.poster-templates,.poster-background-mode,.poster-layout-presets{grid-template-columns:1fr}.poster-logo-options{grid-template-columns:1fr}.poster-palette{grid-template-columns:1fr 1fr}}

/* 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;
}
/* ชื่อผู้สอนอยู่ใต้รูป ไม่ใช่ข้างๆ — แถวนี้มีได้ถึง 4 คน วางแนวนอนแล้วล้นการ์ด */
.club-schedule-owners .avatar {
  flex-direction: column;
  gap: 5px;
  max-width: 68px;
}
.club-schedule-owners .avatar-circle {
  width: 36px;
  height: 36px;
  font-size: 13px;
}
.club-schedule-owners .avatar-name {
  font-size: 10px;
  line-height: 1.25;
  text-align: center;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}
.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; }
}

/* ------- 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;
}
/* รูปโปรไฟล์จริงของผู้สอน — z-index 0 เพราะวงแหวน (::before) กับแสงเงา (::after) ต้องทับอยู่ข้างบน */
.avatar-circle > img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  border-radius: 50%;
}
.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;
  /* ข้อความสีทองบนพื้นสว่างต้องใช้ --gold-strong ตามกติกาหัวไฟล์
     (--gold #E7C878 บนพื้นครีมได้ contrast ~1.6:1 อ่านแทบไม่ออก) */
  color: var(--gold-strong);
  margin-bottom: 10px;
  letter-spacing: 0.04em;
}
.bank-info-empty {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
}
.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-strong);
  background: transparent;
  color: var(--gold-strong);   /* ข้อความสีทองบนพื้นสว่าง — ห้ามใช้ --gold ที่สว่างกว่า */
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.bank-info-copy:hover {
  background: var(--gold-strong);
  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;
}

/* ---- โหมดสาธิต: กล่องเลือกว่าจะเข้าใช้งานเป็นใคร ----
   ขึ้นเฉพาะร้านที่ติดธง config.isDemo และมี config.demoLogins มากับ bootstrap
   (ดู DemoUserPicker ใน login-app.jsx) — ร้านลูกค้าไม่มี DOM ส่วนนี้เลย */
.demo-box {
  border: 1px dashed #D8CDB4;
  background: linear-gradient(180deg, #FDFAF3, #FBF7EE);
  border-radius: 14px;
  padding: 14px 13px 13px;
  margin-bottom: 20px;
}
.demo-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 11px;
}
.demo-pip {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(63,122,84,0.16);
}
.demo-head-title {
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: #6E4E12;
}
.demo-head-hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-left: auto;
}
.demo-who {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 11px;
  padding: 9px 11px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}
.demo-who + .demo-who { margin-top: 7px; }
.demo-who:hover, .demo-who:focus-visible {
  border-color: var(--gold);
  box-shadow: 0 4px 14px rgba(44,44,46,0.10);
  transform: translateY(-1px);
  outline: none;
}
.demo-who:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
  box-shadow: none;
}
.demo-av {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 15px;
}
.demo-av.admin   { background: linear-gradient(145deg, #3C3833, #1F1D19); }
.demo-av.manager { background: linear-gradient(145deg, var(--brand-strong), var(--brand)); }
.demo-av.member  { background: linear-gradient(145deg, var(--gold-strong), var(--gold)); color: #3A2C08; }
.demo-txt {
  min-width: 0;
  flex: 1;
}
.demo-nm {
  display: block;
  font-family: 'Prompt', sans-serif;
  font-weight: 500;
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.demo-meta {
  display: block;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.demo-tag {
  flex: none;
  font-family: 'Prompt', sans-serif;
  font-weight: 600;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
}
.demo-tag.admin   { background: #EDEAE3; color: #3B372F; }
.demo-tag.manager { background: var(--brand-tint); color: var(--brand-strong); }
.demo-tag.member  { background: var(--gold-tint); color: #6E4E12; }
.demo-foot {
  text-align: center;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.5;
}
.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;
}
/* responsive */
@media (max-width: 1100px) {
  .app { display: block; }
  /* Sidebar becomes an off-canvas drawer. Keeps the desktop labeled layout
     (brand + profile + group labels + nav-text + foot) from the base rules —
     only positioning changes here. */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: calc(var(--z-overlay) + 1);
    width: min(300px, 84vw);
    height: auto;
    gap: 20px;
    padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
    padding-left: calc(16px + env(safe-area-inset-left));
    border-right: 1px solid var(--sidebar-strong);
    transform: translateX(-105%);
    transition: transform 220ms ease, box-shadow 220ms ease;
    box-shadow: none;
    overflow-x: hidden;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.4);
  }
  .sidebar .brand-logo { max-width: 132px; border-radius: 10px; }
  .mobile-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    background: rgba(26, 24, 21, 0.45);
  }
  .menu-btn { display: block; flex-shrink: 0; }
  /* สามเปลือกของ "หนึ่งหน้า" ต้องขยับพร้อมกัน — ดูหมายเหตุเหนือกฎ 48px ต้นไฟล์ */
  section.scene,
  .admin-panel,
  .oc-wrap { 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;
    /* ยอมให้ตกบรรทัด — พอมีชื่อใต้รูปแล้ว ผู้สอน 4 คนขึ้นไปจะดันการ์ดจนล้นจอถ้าบังคับแถวเดียว */
    flex-wrap: wrap;
    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;
    max-width: clamp(44px, 13vw, 62px);
  }
  .club-schedule-owners .avatar-circle {
    width: clamp(28px, 7vw, 34px);
    height: clamp(28px, 7vw, 34px);
    font-size: clamp(11px, 2.8vw, 13px);
  }
  .club-schedule-owners .avatar-name {
    font-size: clamp(8px, 2.1vw, 10px);
  }
  .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); }
  .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; }
}

@media (max-width: 1100px) and (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* 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;
  /* ไม่ใช้ backdrop-filter: blur — เบลอเต็มจอทำให้ Safari/iPad กระตุกหนัก */
  background: rgba(15,26,46,0.62);
  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; }

/* ---- ตัวเลือกผู้สอนในฟอร์มตารางเรียน (ClassOwnerPicker) ---- */
.owner-picker { position: relative; }
.owner-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 7px 10px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  cursor: text;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.owner-field:hover { border-color: rgba(15,26,46,0.18); }
.owner-field.open {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--gold-tint);
  background: var(--card);
}
.owner-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
}
/* เส้นประ = วิทยากรรับเชิญที่ไม่มีบัญชี จึงไม่มีรูปให้ดึง */
.owner-chip.guest { border-style: dashed; }
.owner-chip .avatar-circle { width: 24px; height: 24px; font-size: 11px; }
.owner-chip .avatar-name { font-size: 13px; }
.owner-chip-x {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  border-radius: 50%;
}
.owner-chip-x:hover { color: var(--red); }
.owner-search {
  flex: 1;
  min-width: 150px;
  border: 0;
  outline: none;
  background: none;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  padding: 4px 2px;
}
.owner-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 14px 34px rgba(15,26,46,0.14);
}
.owner-menu-group {
  padding: 9px 14px 5px;
  background: var(--bg-2);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.owner-menu-empty { padding: 14px; font-size: 14px; color: var(--muted); }
.owner-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 14px;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.owner-opt:hover { background: var(--bg-2); }
.owner-opt.on { background: var(--gold-tint); }
.owner-opt .avatar-circle { width: 30px; height: 30px; font-size: 12px; }
.owner-opt .avatar-name { font-size: 14px; }
.owner-opt-role { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 500; }
.owner-opt-tick { color: var(--brand); font-weight: 700; }
.owner-opt-add {
  border-top: 1px solid var(--line);
  color: var(--brand);
  font-weight: 600;
  font-size: 14px;
}

/* 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;
}
.att-course-row { cursor: pointer; }
.att-course-row:hover,
.att-course-row:focus-visible { background: var(--paper); outline: none; }
.att-course-row:hover strong,
.att-course-row:focus-visible strong { color: var(--brand); }
.att-course-cell { display: flex; align-items: center; gap: 8px; }
.att-chev {
  width: 14px; height: 14px; flex: none; color: var(--muted);
  opacity: .5; transition: opacity .12s ease, transform .12s ease;
}
.att-course-row:hover .att-chev,
.att-course-row:focus-visible .att-chev { opacity: 1; transform: translateX(2px); color: var(--brand); }
.att-hidden-note {
  margin: 10px 2px 0; font-size: 12.5px; color: var(--muted); line-height: 1.6;
}
.att-modal-body { display: flex; flex-direction: column; gap: 14px; }
.att-modal-row { display: flex; gap: 12px; align-items: flex-start; }
.att-modal-icon {
  width: 32px; height: 32px; border-radius: 9px; background: var(--gold-tint);
  color: var(--gold-strong); display: flex; align-items: center; justify-content: center;
  flex: none; font-size: 15px;
}
.att-modal-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.att-modal-value { font-size: 14px; font-weight: 600; }
.att-modal-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 1px; }
/* หลักฐานเซลฟี่เช็คอินคลาส Onsite/Hybrid */
.att-selfie-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px; margin-top: 10px;
}
.att-selfie { display: block; text-decoration: none; color: inherit; min-width: 0; }
.att-selfie img {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); background: var(--gold-tint); display: block;
}
.att-selfie span {
  display: block; font-size: 11px; color: var(--muted); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.att-selfie:hover img { border-color: var(--brand); }

/* 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;
}
/* ระยะขอบของ .admin-panel อยู่รวมกับ section.scene / .oc-wrap ที่ต้นไฟล์ ไม่ใช่ตรงนี้ */

.finance-summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 0 0 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 0 16px; }
}
.finance-section {
  margin-bottom: 26px;
}
.finance-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 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 0 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) {
  .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 0 10px;
  }
  .finance-table-wrap {
    margin: 0 0 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;  }

/* หัวคอลัมน์คลิกเรียงได้ (จอคอม) */
.dash-table th.sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 140ms ease;
}
.dash-table th.sortable-th:hover { color: var(--brand); }
.dash-table th.sortable-th:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.dash-table th.sortable-th.sorted { color: var(--brand); }
.dash-table th.sortable-th .sort-caret {
  margin-left: 4px;
  font-size: 0.9em;
  color: var(--muted);
  opacity: 0.5;
}
.dash-table th.sortable-th:hover .sort-caret { color: var(--brand); opacity: 0.85; }
.dash-table th.sortable-th.sorted .sort-caret { color: var(--brand); opacity: 1; }

/* แถบชิปเรียงลำดับ — เฉพาะมือถือ (การ์ด) */
.member-sort-bar { 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-sort-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: -2px 0 12px;
  }
  .member-sort-label { font-size: 11px; color: var(--muted); margin-right: 2px; }
  .member-sort-chip {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--muted);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
  }
  .member-sort-chip.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
  }
  .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;
}

/* โปรไฟล์ของฉัน (แผง Manager) — การ์ดตัวตนซ้าย + ฟอร์ม/ข้อมูลอ่านอย่างเดียวขวา
   .profile-card ตั้ง max-width: 560px ไว้สำหรับหน้าตัวแทนคอลัมน์เดียว ต้องปลดในกริดนี้
   ไม่งั้นการ์ดขวาไม่ยอมกว้างเต็มช่อง */
.my-profile-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  padding: 0 0 32px;
}
.my-profile-grid .profile-card { max-width: none; }
.my-profile-id {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 22px;
  text-align: center;
}
/* .avatar-upload-wrap เป็นแถวนอน (รูป | ปุ่ม) แล้ว wrap เมื่อคอลัมน์แคบ —
   ในการ์ดนี้ต้องจัดกลางทั้งตอนอยู่แถวเดียวและตอน wrap ลงบรรทัดใหม่ */
.my-profile-id .avatar-upload-wrap { justify-content: center; width: 100%; }
.my-profile-name {
  font-family: 'Prompt', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}
.my-profile-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.my-profile-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--gold-strong);
  background: var(--gold-tint);
  border-radius: 999px;
  padding: 3px 10px;
}
.my-profile-mates { font-size: 12px; color: var(--muted); }
.my-profile-edit {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line-2);
}
.my-profile-edit .form-field { width: 100%; max-width: 360px; }
.my-profile-lock {
  display: block;
  font-family: 'IBM Plex Sans Thai', sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 2px;
}

@media (max-width: 760px) {
  .my-profile-grid { grid-template-columns: 1fr; padding: 0 0 24px; gap: 14px; }
}

/* 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; }

/* เช็คอินคลาส Onsite/Hybrid ด้วยเซลฟี่ */
.selfie-modal .modal-body { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.selfie-hint { margin: 0; font-size: 13px; color: var(--ink-soft); text-align: center; }
.selfie-shot {
  width: 100%; max-width: 240px; aspect-ratio: 3 / 4; padding: 0; overflow: hidden;
  border: 1.5px dashed var(--brand); border-radius: 14px; background: var(--gold-tint);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.selfie-shot:disabled { opacity: .6; cursor: not-allowed; }
.selfie-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.selfie-placeholder { font-size: 15px; line-height: 2; color: var(--brand); text-align: center; }
.selfie-modal .modal-actions { width: 100%; }
.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 .qual-arow,
  body.printing-page .print-target .qual-bar,
  body.printing-page .print-target .sales-funnel-row { break-inside: avoid; }
  /* แถบความคืบหน้าคุณวุฒิสื่อความหมายด้วยสี ถ้าเบราว์เซอร์ตัดพื้นหลังทิ้งจะเหลือแถบว่าง */
  body.printing-page .print-target .qual-bar-track,
  body.printing-page .print-target .qual-bar-fill,
  body.printing-page .print-target .qual-metric-chip {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  body.printing-page .print-target .qual-bar-track { border: 1px solid #999; }
  /* ตาราง/ก้อนที่เลื่อนแนวนอนบนจอ ต้องกางเต็มตอนพิมพ์ */
  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;
}

/* ===== 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,
  .admin-panel,
  .oc-wrap { 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; }

  /* เมนูมือถือใช้ drawer จาก block max-width:1100 — ไม่มีกฎ sidebar เฉพาะที่นี่ */

  /* 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(--green); } /* ทองเดิมจางไปบนการ์ดขาว */
.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;
}
/* สถานะว่างของตารางเป้า APE — ร้านที่ยังไม่ได้ตั้งแผนเป้าหมายใหญ่
   ใช้กรอบเส้นประชุดเดียวกับ .pub-challenge-empty เพื่อให้ "ยังไม่มีข้อมูล" หน้าตาเหมือนกันทั้งแอป */
.ape-goal-empty {
  padding: 40px 24px;
  text-align: center;
  background: var(--paper-2);
  border: 1px dashed var(--line);
  border-radius: 14px;
  display: grid;
  gap: 8px;
  justify-items: center;
}
.ape-goal-empty-icon { font-size: 34px; line-height: 1; }
.ape-goal-empty-head { font-size: 17px; font-weight: 700; color: var(--ink); }
.ape-goal-empty-sub {
  font-size: 14px;
  color: var(--muted);
  max-width: 44ch;
  line-height: 1.7;
}

.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 ใช้ hamburger drawer เหมือนมือถือ (ดู block max-width:1100)
   ========================================================================= */

/* 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;
  }
}

/* =========================================================================
   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;
}

/* B) Touch devices only — finger-sized targets */
@media (pointer: coarse) {
  /* standalone icon / close buttons */
  .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);
  /* ไม่ใช้ backdrop-filter: blur — เบลอเต็มจอทำให้ Safari/iPad กระตุกหนัก */
  background: rgba(0,0,0,0.82);
  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; }

/* ระยะเวลาเปิดดีล (จำนวนวัน เปิด→ปิด) */
.sales-dur { display: inline-flex; flex-direction: column; line-height: 1.15; }
.sales-dur-num { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.sales-dur-num .u { font-weight: 500; font-size: 12px; margin-left: 2px; }
.sales-dur-cap { font-size: 10.5px; font-weight: 500; margin-top: 1px; }
.sales-dur.won  .sales-dur-num { color: #2E7D57; } .sales-dur.won  .sales-dur-cap { color: #5AA07B; }
.sales-dur.open .sales-dur-num { color: var(--ink); } .sales-dur.open .sales-dur-cap { color: var(--muted); }
.sales-dur.lost .sales-dur-num { color: var(--muted); } .sales-dur.lost .sales-dur-cap { color: #9A9086; }
.sales-dur-dash { color: #C3BCAE; }

/* 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); }

/* ===== การอบรม (เช็คลิสต์หลักสูตร) =====
   ใช้ตัวแปรสีชุดเดียวกับ Prospecting เพื่อให้สองหน้าดูเป็นระบบเดียวกัน
   ปุ่มติ๊กเป็น <button> ไม่ใช่ <input type=checkbox> เพราะต้องแสดงสามสถานะ
   (ยังไม่ติ๊ก / รอยืนยัน / ยืนยันแล้ว) ซึ่ง checkbox มีแค่สอง */
.training-progress { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; }
.training-progress-top { display: flex; align-items: baseline; gap: 10px; }
.training-progress-top strong { font-size: 16px; color: var(--ink); }
.training-progress-pending { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.training-bar { height: 6px; border-radius: 999px; background: var(--paper-2); overflow: hidden; margin-top: 10px; min-width: 90px; }
.training-bar > span { display: block; height: 100%; background: var(--brand-strong); border-radius: 999px; }

.training-group { margin-bottom: 18px; }
.training-group-head { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; margin-bottom: 6px; }
.training-row {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px;
}
.training-row.is-passed { border-color: #CFE3D8; }
.training-row.is-off { opacity: .55; }
.training-check {
  flex: 0 0 auto; width: 22px; height: 22px; margin-top: 1px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--paper);
  cursor: pointer; font-family: inherit; font-size: 14px; line-height: 20px; color: transparent;
  transition: background .15s, border-color .15s, color .15s;
}
.training-check:hover { border-color: var(--brand); }
.training-check.is-pending { background: var(--gold-tint); border-color: #E0C588; color: var(--brand-strong); }
.training-check.is-passed  { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.training-check:disabled { cursor: wait; opacity: .6; }
.training-row-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 auto; }
.training-row-title { font-size: 14.5px; color: var(--ink); }
.training-row-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.training-row-sub a { color: var(--brand); text-decoration: none; }
.training-row-sub a:hover { text-decoration: underline; }
.training-row-detail { font-size: 12.5px; color: var(--ink-soft); }
.training-kind { background: var(--paper-2); border-radius: 999px; padding: 1px 9px; font-size: 11px; color: var(--ink-soft); }
.training-pill { flex: 0 0 auto; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 3px 10px; background: var(--paper-2); color: var(--muted); }
.training-pill.ok { background: #E7F0EB; color: var(--t, #2E6B4F); }
.training-pill.pend { background: var(--gold-tint); color: var(--brand-strong); }

/* ตารางไขว้ ตัวแทน x หลักสูตร — คอลัมน์แคบและกึ่งกลาง ชื่อเต็มอยู่ใน title
   ไม่ล็อกความกว้างตาราง ปล่อยให้ .table-wrap เลื่อนแนวนอนเมื่อหลักสูตรเยอะ */
.training-matrix th.tm-cat { text-align: center; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
/* หัวคอลัมน์เป็นตัวหนังสือแนวตั้ง อ่านจากบนลงล่าง — แนวนอนกินความกว้างคอลัมน์ละ
   ~110px พอมี 7 หลักสูตรก็ล้นจอต้องเลื่อน แนวตั้งเหลือ ~38px เห็นครบในจอเดียว
   vertical-rl + rotate(180deg) = อ่านบนลงล่าง (ถ้าไม่หมุนกลับจะอ่านล่างขึ้นบน) */
.training-matrix th.tm-col { padding: 8px 4px; vertical-align: bottom; width: 38px; }
.training-matrix .tm-vert {
  writing-mode: vertical-rl; transform: rotate(180deg);
  display: block; margin: 0 auto;
  font-size: 11.5px; font-weight: 500; color: var(--ink-soft); line-height: 1.2;
  white-space: nowrap;
}
/* ชื่อหน่วยของบางทีมยาวมาก ("วายุภักษ์ 83F10 : The Infinite Wealth") ถ้าปล่อยให้
   ตัดบรรทัดจะดันแถวสูง 4 บรรทัด กวาดตาเช็กทั้งทีมไม่ได้ — บีบเป็นบรรทัดเดียว
   แล้วเก็บชื่อเต็มไว้ใน title */
.training-matrix td.tm-name { min-width: 132px; max-width: 190px; }
.training-matrix td.tm-name .tm-sub {
  display: block; font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
/* เส้นแนวดิ่งคั่นทุกคอลัมน์ — ช่องเป็น ✓/– ตัวเล็ก ๆ เรียงกัน 7 คอลัมน์
   ถ้าไม่มีเส้นคั่น สายตาไล่ไม่ถูกว่าเครื่องหมายอยู่ใต้หลักสูตรไหน
   ไม่ใส่เส้นให้คอลัมน์ชื่อตัวแทน (คอลัมน์แรก) เพราะซ้อนกับขอบตารางพอดี */
.training-matrix th.tm-cat,
.training-matrix th.tm-col,
.training-matrix td.tm-cell,
.training-matrix th.tm-total,
.training-matrix td.tm-total { border-left: 1px solid var(--line); }

.training-matrix td.tm-cell { text-align: center; font-size: 13px; }
.training-matrix td.tm-passed  { color: var(--brand-strong); font-weight: 700; }
.training-matrix td.tm-pending { color: #9A7B2E; font-size: 11px; }
.training-matrix td.tm-none    { color: var(--line); }

/* ฝั่งแอดมิน — แถวเดียวกันแต่ไม่มีปุ่มติ๊ก (หัวหน้ายืนยัน/ถอนด้วยปุ่มขวาสุดแทน) */
.training-row.is-admin { align-items: center; }
.training-manage-cat { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; background: var(--paper); }
.training-manage-cat.is-off { opacity: .6; }
.training-manage-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.training-manage-head strong { font-size: 15px; color: var(--ink); }
.training-manage-head .sales-cust-actions { margin-left: auto; }

@media (max-width: 640px) {
  .training-row { flex-wrap: wrap; }
  .training-manage-head .sales-cust-actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
}

/* 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; }

/* view "ของฉัน" ใน SalesTrackingPanel/RecruitTrackingPanel เรนเดอร์ SalesTab/RecruitTab ตรงๆ ซึ่งมี
   section.scene เป็น root ของตัวเอง ซ้อนอยู่ใน section.scene.sales-admin อีกชั้น — ล้าง padding/border
   ของ .scene ชั้นในไม่ให้ทบซ้อนกับ padding ของ .sales-admin ชั้นนอก (รวมเคส :last-child ด้วย) */
.sales-admin > section.scene { padding: 0; border-bottom: none; }
.sales-admin > section.scene:last-child { padding: 0; border-bottom: none; }

/* 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); }
/* เดิมเป็น space-between เพราะมีลูกแค่ 2 ตัว (ป้ายสเตจ + ยอด APE) พอเพิ่มป้ายเกรด
   เข้ามาเป็นตัวที่ 3 space-between จะดันป้ายสเตจไปกลางการ์ด — จัดชิดซ้ายแล้วดัน
   ยอดไปขวาด้วย margin-left:auto แทน จำนวนลูกเพิ่มอีกกี่ตัวก็ไม่พัง */
.sales-deal-top { display: flex; align-items: center; gap: 6px; }
.sales-deal-top .sales-deal-ape { margin-left: auto; }
.sales-deal-top .sales-grade-badge { margin-right: 0; }
.sales-detail-meta .sales-grade-badge { margin-right: 0; }
.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; }

/* เกรดลูกค้า A/B/C/D — ตาราง 2x2 ตามสื่อการสอน "คัดเกรดลูกค้าในพอร์ต"
   คงเป็น 2 คอลัมน์ทุกความกว้าง เพราะรูปทรง 2x2 คือตัวสื่อว่ามี 2 แกน
   ถ้ายุบเป็นคอลัมน์เดียวบนมือถือจะกลายเป็นลิสต์ 4 ตัวเลือกธรรมดา */
.sales-grade-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 13px; color: var(--ink-soft); font-weight: 500;
}
.sales-grade-axis { font-size: 12px; color: var(--muted); font-weight: 400; }
.sales-grade-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: -4px; }
.sales-grade-cell {
  font-family: inherit; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; transition: border-color .15s, background .15s, transform .05s;
}
.sales-grade-cell:hover { border-color: var(--brand); }
.sales-grade-cell:active { transform: scale(0.98); }
.sales-grade-cell.is-on { border-color: var(--brand-strong); background: var(--gold-tint); }
.sales-grade-letter { font-size: 22px; font-weight: 700; line-height: 1.1; color: var(--muted); }
.sales-grade-cell.is-on .sales-grade-letter { color: var(--brand-strong); }
.sales-grade-what { font-size: 13px; color: var(--ink); }
.sales-grade-goal { font-size: 12px; color: var(--ink-soft); }

/* ป้ายเกรดในรายชื่อลูกค้า — กว้างคงที่เพื่อให้ชื่อทุกแถวเริ่มตรงกัน อ่านไล่ลงมาได้ */
.sales-grade-badge {
  display: inline-block; min-width: 24px; text-align: center; margin-right: 8px;
  font-size: 12px; font-weight: 700; line-height: 1.6; border-radius: 6px; padding: 0 6px;
  background: var(--paper-2); color: var(--ink-soft); vertical-align: 1px;
}
.sales-grade-badge.g-A { background: var(--brand-strong); color: #fff; }
.sales-grade-badge.g-B { background: var(--gold-tint); color: var(--brand-strong); }
.sales-grade-badge.is-none { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-weight: 500; }
.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; }
/* ตัวเลขดีล: กริด 2 คอลัมน์แทน flex-wrap
   เดิมใช้ flex-wrap + gap:18px → ดีลที่มีค่าเดียว (เช่น เป้า APE) กินเต็มแถวแล้วเหลือที่ว่างครึ่งจอ
   กริดทำให้ดีลที่ปิดแล้ว (FYP/APE/NBC/เหตุผล) เรียงลงตัวเป็น 2x2 พอดีด้วย */
.sales-detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line-2);
  border: 1px solid var(--line-2);
  border-radius: 11px;
  overflow: hidden;
  margin-bottom: 14px;
}
.sales-detail-stats div { display: flex; flex-direction: column; gap: 1px; background: var(--card); padding: 10px 12px; }
.sales-detail-stats span { font-size: 10.5px; color: var(--muted); }
.sales-detail-stats strong { font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* หัวเรื่องโมดัลดีล: ชื่อลูกค้า 1 บรรทัด + บรรทัดรอง (เบอร์ · สินค้า · ชื่อดีล) */
.deal-head { align-items: flex-start; }
.deal-head-tt { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.deal-head-tt strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-head-sub { font-size: 12.5px; font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* โซน "ขั้นถัดไป" — งานหลักของจอนี้ จึงเป็นปุ่มเต็มความกว้าง กดด้วยนิ้วโป้งได้ไม่ต้องเล็ง
   คลาสแยกจาก .sales-move-btn เพราะตัวนั้นใช้ร่วมกับหน้า Recruiting */
.deal-next { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.deal-next-label { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.deal-next-btn {
  border-radius: 11px; padding: 13px; font-size: 15px; font-weight: 700;
  cursor: pointer; font-family: inherit; min-height: 48px; width: 100%;
  transition: background .15s ease, border-color .15s ease;
}
.deal-next-btn.is-primary { border: none; background: var(--brand); color: #fff; }
.deal-next-btn.is-primary:hover { background: var(--brand-strong); }
.deal-next-btn.is-ghost { border: 1px solid var(--line); background: transparent; color: var(--ink-soft); font-size: 14px; font-weight: 600; }
.deal-next-btn.is-ghost:hover { border-color: var(--brand); color: var(--brand); }

/* โซนอันตราย — ล่างสุด เป็นปุ่มข้อความใต้เส้นคั่น
   ปุ่มทำลายข้อมูลไม่ควรเด่นที่สุดในจอ (เดิมเป็นปุ่มกรอบเต็มตัวอยู่กลางจอ เด่นกว่าปุ่มเลื่อนสเตจ) */
.deal-danger { margin-top: 20px; padding-top: 12px; border-top: 1px dashed var(--line); display: flex; justify-content: center; }
.deal-danger-btn {
  background: none; border: none; cursor: pointer; font-family: inherit;
  color: var(--brand); font-size: 13px; font-weight: 600;
  min-height: 44px; padding: 0 16px; border-radius: 8px;
}
.deal-danger-btn:hover { background: var(--paper-2); }
.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); }
/* บรรทัดสรุปดีลที่ปิดแล้ว ใต้ funnel "ค้างอยู่ตอนนี้" (ขั้นที่ปิดแล้วไม่นับเป็นงานค้าง) */
.sales-funnel-foot { font-size: 12.5px; color: var(--muted); padding-top: 4px; border-top: 1px dashed var(--line); margin-top: 4px; }
.sales-funnel-foot span { opacity: .75; }

/* ---- สรุปรายเดือน (นับจาก sales_stage_logs — ตัวเลขไม่ลดลงย้อนหลัง) ---- */
.sales-monthly { display: grid; gap: 10px; margin-top: 22px; }
.sales-monthly-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sales-monthly-range { display: flex; gap: 6px; }
.sales-monthly-range button {
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink);
  border-radius: 999px; padding: 4px 12px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.sales-monthly-range button:hover { border-color: var(--brand); }
.sales-monthly-range button.active { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }
.sales-monthly-note { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; max-width: 76ch; }
.sales-monthly-note strong { color: var(--ink); font-weight: 600; }
.sales-monthly-table td.num, .sales-monthly-table th.num { font-variant-numeric: tabular-nums; }
.sales-monthly-table .dim { color: var(--line); }
.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, color-mix(in srgb, var(--green) 12%, var(--card)), var(--card) 72%); border-color: color-mix(in srgb, var(--green) 35%, var(--card)); } /* ทองเดิมจางบนการ์ดขาว → โทนเขียว */
.ts-kpi.lead .ts-kpi-val { color: var(--green); }

/* 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 {
  --tc-blue: #3f88ff;
  --tc-blue-deep: #0a3473;
  --tc-orange: #ff7a2f;
  --tc-orange-deep: #6f2c12;
  --tc-gold: #d8b678;
  --tc-line: rgba(216, 182, 120, .34);
  position: relative;
  overflow: hidden;
  color: #f6f1e7;
  background-color: #060b10;
  background-image: url("photos/championship-night-bg.png");
  background-size: cover;
  background-position: center top;
  border: 1px solid rgba(216, 182, 120, .64);
  border-radius: 8px;
  padding: clamp(18px, 3vw, 38px);
  box-shadow: 0 22px 52px rgba(3, 8, 14, .28);
}
.tc-champ-title { margin: 0 0 clamp(18px, 2.6vw, 32px); text-align: center; }
.tc-champ-title strong {
  display: inline-block;
  color: #e1c48f;
  font-family: 'Prompt', sans-serif;
  font-size: clamp(18px, 2.2vw, 30px);
  font-weight: 700;
  letter-spacing: .18em;
  line-height: 1.15;
  text-shadow: 0 2px 18px rgba(216, 182, 120, .26);
}
.tc-vs-sides { display: grid; grid-template-columns: minmax(0, 1fr) 118px minmax(0, 1fr); align-items: stretch; }
.tc-vs-side {
  min-width: 0;
  padding: clamp(16px, 2.4vw, 28px);
  background: rgba(3, 10, 18, .76);
  border: 1px solid rgba(126, 151, 178, .42);
  text-align: center;
}
.tc-vs-side.left { border-left: 3px solid var(--tc-blue); }
.tc-vs-side.right { border-right: 3px solid var(--tc-orange); }
.tc-vs-side.leading { box-shadow: inset 0 2px 0 var(--tc-gold); }
.tc-vs-team-head { display: flex; align-items: center; gap: 16px; text-align: left; }
.tc-vs-side.right .tc-vs-team-head { flex-direction: row-reverse; text-align: right; }
.tc-vs-side .avatar-circle {
  flex: 0 0 auto;
  border: 2px solid rgba(225, 196, 143, .82);
  box-shadow: 0 5px 18px rgba(0, 0, 0, .42);
}
.tc-vs-name {
  font-family: 'Prompt', sans-serif;
  font-weight: 700;
  font-size: clamp(18px, 2vw, 27px);
  line-height: 1.2;
  color: #fff;
  letter-spacing: .025em;
  text-transform: uppercase;
}
.tc-vs-captain { font-size: 13px; color: #c8c6c1; margin-top: 4px; }
.tc-vs-score-label { margin-top: 22px; color: #c9c7c1; font-size: 13px; font-weight: 500; }
.tc-vs-score {
  display: block;
  margin-top: 2px;
  font-family: 'Prompt', sans-serif;
  font-size: clamp(66px, 8vw, 112px);
  font-weight: 600;
  line-height: .95;
  font-variant-numeric: tabular-nums;
  color: #eaf2ff;
  text-shadow: 0 0 26px rgba(63, 136, 255, .22);
}
.tc-vs-side.right .tc-vs-score { color: #f1cf8d; text-shadow: 0 0 26px rgba(255, 122, 47, .22); }
.tc-vs-secondary { display: flex; justify-content: center; gap: 0; margin-top: 16px; }
.tc-vs-secondary span { min-width: 92px; padding: 0 18px; border-right: 1px solid rgba(216, 182, 120, .28); }
.tc-vs-secondary span:last-child { border-right: 0; }
.tc-vs-secondary small { display: block; color: #aeb2b8; font-size: 11px; line-height: 1.2; }
.tc-vs-secondary b { display: block; margin-top: 3px; color: #f6f1e7; font-family: 'Prompt', sans-serif; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tc-vs-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  color: #e5d3b0;
  font-family: 'Prompt', sans-serif;
  text-align: center;
}
.tc-vs-mid span { font-size: clamp(42px, 5vw, 72px); font-weight: 700; letter-spacing: -.06em; line-height: 1; text-shadow: 0 4px 24px rgba(216, 182, 120, .32); }
.tc-vs-mid small { margin-top: 10px; color: #858b93; font-size: 10px; font-weight: 500; white-space: nowrap; }
.tc-vs-bar { position: relative; height: 8px; overflow: hidden; background: rgba(255, 255, 255, .08); margin: 16px 18px 0; }
.tc-vs-bar-sub, .tc-vs-bar-ap { position: absolute; top: 0; bottom: 0; transition: width 300ms ease; }
.tc-vs-bar-sub.left, .tc-vs-bar-ap.left { left: 0; }
.tc-vs-bar-sub.right, .tc-vs-bar-ap.right { right: 0; }
.tc-vs-bar-sub { opacity: .42; }
.tc-vs-bar .tc-vs-bar-sub.left, .tc-vs-bar .tc-vs-bar-ap.left { background: var(--tc-blue) !important; }
.tc-vs-bar .tc-vs-bar-sub.right, .tc-vs-bar .tc-vs-bar-ap.right { background: var(--tc-orange) !important; }
.tc-vs-bar-ap { box-shadow: 0 0 10px currentColor; }
.tc-vs-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: min(680px, calc(100% - 32px));
  min-height: 48px;
  margin: -1px auto 0;
  padding: 9px 20px;
  background: rgba(6, 9, 12, .94);
  border: 1px solid rgba(216, 182, 120, .56);
  color: #d4d2cd;
  font-size: 14px;
}
.tc-vs-foot strong { color: #f0dfbf; font-family: 'Prompt', sans-serif; font-size: 17px; font-weight: 600; }
.tc-live-badge { padding: 3px 10px; background: #b92820; color: #fff; font-family: 'Prompt', sans-serif; font-size: 11px; font-weight: 700; letter-spacing: .1em; }
.tc-live-badge.upcoming { background: #5a6069; }
.tc-vs-banner {
  width: min(680px, calc(100% - 32px));
  margin: -1px auto 0;
  padding: 11px 20px;
  background: rgba(6, 9, 12, .94);
  border: 1px solid var(--tc-gold);
  text-align: center;
  font-family: 'Prompt', sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: #f0dfbf;
}
.tc-vs-details { display: flex; align-items: center; justify-content: center; gap: 0; margin: 12px 0 0; color: #c3c0ba; font-size: 12px; text-align: center; }
.tc-vs-details span { padding: 0 18px; border-right: 1px solid rgba(216, 182, 120, .34); white-space: pre-wrap; }
.tc-vs-details span:last-child { border-right: 0; }

/* leaderboard bars — ใช้ตอนแข่ง 3-6 ทีม (2 ทีมพอดีใช้ .tc-vs-sides แบบ VS เดิม) */
.tc-lb-list { display: flex; flex-direction: column; gap: 12px; }
.tc-lb-row { display: flex; align-items: center; gap: 12px; }
.tc-lb-rank { width: 26px; height: 26px; background: rgba(255,255,255,.08); color: #aeb2b8; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.tc-lb-rank.top { background: var(--tc-gold); color: #14110d; }
.tc-lb-info { flex: 1; min-width: 0; }
.tc-lb-info .tc-vs-name { font-size: 15px; }
.tc-lb-info .tc-vs-captain { font-size: 11px; }
.tc-lb-bar-track { position: relative; height: 9px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 7px; }
.tc-lb-bar-sub { position: absolute; inset: 0 auto 0 0; height: 100%; opacity: .35; transition: width 200ms ease; }
.tc-lb-bar-fill { position: absolute; inset: 0 auto 0 0; height: 100%; transition: width 200ms ease; }
.tc-lb-value { font-size: 13px; font-weight: 700; color: #eee9df; font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; text-align: right; line-height: 1.3; }
.tc-lb-value small { display: block; font-size: 10.5px; font-weight: 500; }
.tc-lb-value small.wait { color: #e1c48f; }
.tc-lb-value small.same { color: #8e949c; }

/* รายชื่อผู้แข่งขันรายบุคคลใต้การ์ด */
.tc-participants { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-top: 18px; }
.tc-p-column { min-width: 0; background: rgba(4, 9, 14, .82); border: 1px solid rgba(126, 151, 178, .35); }
.tc-p-column.left { border-top: 2px solid var(--tc-blue); }
.tc-p-column.right { border-top: 2px solid var(--tc-orange); }
.tc-p-col-head, .tc-p-row { display: grid; grid-template-columns: 28px 34px minmax(0, 1fr) 58px 58px; align-items: center; column-gap: 8px; }
.tc-p-col-head { min-height: 42px; padding: 7px 12px; border-bottom: 1px solid var(--tc-line); color: #aeb2b8; font-size: 10px; font-weight: 600; }
.tc-p-head-name { grid-column: 1 / 4; color: #f6f1e7; font-family: 'Prompt', sans-serif; font-size: 14px; font-weight: 700; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-p-head-name small { margin-left: 8px; color: #9ba0a8; font-family: 'IBM Plex Sans Thai', sans-serif; font-size: 10px; font-weight: 500; text-transform: none; }
.tc-p-head-score { text-align: right; }
.tc-p-list { display: flex; flex-direction: column; }
.tc-p-row { min-height: 54px; padding: 7px 12px; border-bottom: 1px solid rgba(126, 151, 178, .19); font-size: 13px; }
.tc-p-row:last-child { border-bottom: 0; }
.tc-p-row.top { box-shadow: inset 3px 0 0 var(--tc-gold); background: rgba(216, 182, 120, .07); }
.tc-p-column.right .tc-p-row.top { box-shadow: inset -3px 0 0 var(--tc-gold); }
.tc-p-rank { color: #aaa7a1; font-family: 'Prompt', sans-serif; font-size: 15px; font-weight: 600; text-align: center; }
.tc-p-mini-avatar { width: 30px; height: 30px; 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 { color: #eeece7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-captain-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; margin-left: 6px; padding: 0 5px; background: #c47d24; color: #fff; font-family: 'Prompt', sans-serif; font-size: 9px; font-weight: 700; vertical-align: 1px; }
.tc-p-score { color: #b9bdc4; font-family: 'Prompt', sans-serif; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.tc-p-column.left .tc-p-score.approved { color: var(--tc-blue); }
.tc-p-column.right .tc-p-score.approved { color: var(--tc-orange); }
.tc-p-empty { font-size: 12px; color: #8e949c; padding: 16px 12px; }

@media (max-width: 760px) {
  .tc-vs-card { padding: 18px 12px; border-radius: 0; }
  .tc-champ-title strong { letter-spacing: .1em; }
  .tc-vs-sides { grid-template-columns: minmax(0, 1fr) 58px minmax(0, 1fr); }
  .tc-vs-side { padding: 14px 10px; }
  .tc-vs-team-head, .tc-vs-side.right .tc-vs-team-head { flex-direction: column; gap: 8px; text-align: center; }
  .tc-vs-side .avatar-circle { width: 52px !important; height: 52px !important; font-size: 18px !important; }
  .tc-vs-name { font-size: 15px; }
  .tc-vs-captain { font-size: 10px; }
  .tc-vs-score-label { margin-top: 14px; font-size: 10px; }
  .tc-vs-score { font-size: clamp(48px, 14vw, 74px); }
  .tc-vs-secondary span { min-width: 0; flex: 1; padding: 0 6px; }
  .tc-vs-secondary small { font-size: 9px; }
  .tc-vs-secondary b { font-size: 18px; }
  .tc-vs-mid span { font-size: 32px; }
  .tc-vs-mid small { display: none; }
  .tc-vs-bar { margin-inline: 6px; }
  .tc-vs-foot { gap: 8px; width: calc(100% - 12px); padding-inline: 10px; font-size: 11px; }
  .tc-vs-foot strong { font-size: 13px; }
  .tc-vs-details { flex-direction: column; gap: 5px; }
  .tc-vs-details span { padding: 0; border-right: 0; }
  .tc-participants { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .tc-vs-card { margin-inline: -12px; }
  .tc-vs-sides { grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr); }
  .tc-vs-side { padding-inline: 7px; }
  .tc-vs-name { font-size: 13px; }
  .tc-vs-captain { max-width: 120px; margin-inline: auto; }
  .tc-vs-secondary { margin-top: 12px; }
  .tc-vs-secondary small { min-height: 22px; }
  .tc-vs-foot { flex-wrap: wrap; min-height: 54px; }
  .tc-p-col-head, .tc-p-row { grid-template-columns: 22px 30px minmax(0, 1fr) 50px 50px; column-gap: 6px; padding-inline: 8px; }
  .tc-p-mini-avatar { width: 28px; height: 28px; }
  .tc-p-name { font-size: 12px; }
  .tc-p-score { font-size: 12px; }
}

/* ป้ายสถานะอนุมัติของดีล (นำส่ง vs อนุมัติ) — การ์ด/โมดัลตัวแทน + ตารางดีลแอดมิน */
.deal-ap-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.deal-ap-pill.ok { background: color-mix(in srgb, var(--green, #2f9e5b) 12%, white); color: var(--green, #2f9e5b); border: 1px solid color-mix(in srgb, var(--green, #2f9e5b) 35%, white); }
.deal-ap-pill.wait { background: var(--gold-tint); color: #a97f16; border: 1px solid var(--gold-soft); }

/* กล่องเช็คบ็อกซ์ "บริษัทอนุมัติแล้ว" ในโมดัลดีลฝั่งแอดมิน */
.deal-approve-box { display: flex; align-items: flex-start; gap: 11px; border: 1.5px solid var(--gold-soft); background: var(--gold-tint); border-radius: 12px; padding: 12px 14px; margin: 4px 0 14px; cursor: pointer; }
.deal-approve-box input { width: 19px; height: 19px; accent-color: var(--green, #2f9e5b); margin-top: 2px; flex-shrink: 0; cursor: pointer; }
.deal-approve-box b { font-size: 14px; color: var(--ink); }
.deal-approve-box small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.deal-approve-box.done { border-color: color-mix(in srgb, var(--green, #2f9e5b) 40%, white); background: color-mix(in srgb, var(--green, #2f9e5b) 8%, white); }
.deal-approve-box.done small { color: var(--green, #2f9e5b); }

/* แจ้งตัวแทนตอนคีย์งานปิดดีล: NBC ต้องผ่านการตรวจของผู้จัดการก่อนคะแนนถึงเข้า */
.nbc-review-note { display: block; background: var(--gold-tint); border: 1px solid var(--gold-soft); border-radius: 10px; padding: 10px 13px; font-size: 12.5px; line-height: 1.55; color: color-mix(in srgb, var(--brand) 55%, var(--ink)); }

/* ผู้จัดการแก้ยอด APE/NBC ของดีลปิดได้ */
.deal-amt-edit-toggle { align-self: flex-start; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--brand, #8a2b23); background: var(--card, #fff); border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 12px; margin: 0 0 12px; cursor: pointer; }
.deal-amt-edit-toggle:hover { border-color: var(--gold-soft); background: var(--gold-tint); }
.deal-amt-edit { border: 1.5px solid var(--gold-soft); background: var(--gold-tint); border-radius: 12px; padding: 12px 14px; margin: 4px 0 14px; }
.deal-amt-edit-fields { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.deal-amt-edit-fields label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 140px; min-width: 0; font-size: 11px; color: var(--muted); }
.deal-amt-edit-fields input { font: inherit; font-size: 15px; font-weight: 600; color: var(--ink); padding: 9px 12px; border: 1.5px solid var(--brand, #8a2b23); border-radius: 9px; background: var(--card, #fff); font-variant-numeric: tabular-nums; }
.deal-amt-edit-btns { display: flex; gap: 8px; }

/* ---- งวดชำระเบี้ย (ฟอร์มปิดดีล + ฟอร์มแก้ยอด 2 จุด) ---- */
.pay-freq { display: flex; flex-direction: column; gap: 6px; }
.pay-freq-label { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
/* .ts-seg เดิมเป็น inline-flex ขนาดตามเนื้อหา — ในโมดัลอยากให้เต็มความกว้าง
   และปุ่มกว้างเท่ากันทั้งสาม เพื่อให้แตะง่ายบนมือถือ */
.pay-freq-seg { display: flex; width: 100%; }
.pay-freq-seg .ts-seg-btn { flex: 1 1 0; padding: 8px 6px; white-space: nowrap; }
.pay-freq-seg .ts-seg-btn.active { color: var(--brand); }
.pay-freq-seg .ts-seg-btn:disabled { opacity: .55; cursor: default; }
/* ในกล่องแก้ยอด (พื้น gold-tint) แถบเลือกต้องไม่กลืนไปกับพื้น */
.deal-amt-edit .pay-freq { margin-bottom: 10px; }
.deal-amt-edit .pay-freq-seg { background: var(--card); }
.pay-freq-hint { font-size: 12.5px; color: var(--muted); background: var(--paper-2);
  border-radius: 9px; padding: 10px 12px; text-align: center; }
.pay-freq-note { font-size: 12px; color: var(--ink-soft); line-height: 1.5; }
.deal-amt-edit .pay-freq-note { margin-bottom: 10px; }
.pay-freq-pill { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 999px;
  padding: 2px 10px; background: var(--paper-2); color: var(--ink-soft); border: 1px solid var(--line-2); }

.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); }
/* กิจกรรมหลายวันที่กำลังจัดอยู่ — ต้องเด่นกว่า .soon (วันนี้/พรุ่งนี้) */
.act-countdown.live { background: var(--brand); color: #fff; }
.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; }

/* Module reorder: ปุ่ม ▲▼ สำหรับสัมผัส (desktop ใช้ drag) */
@media (max-width: 760px),
       (max-height: 500px) and (orientation: landscape),
       (min-width: 761px) and (max-width: 1100px) and (orientation: portrait) {
  .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-dot-name.anchor-start { text-anchor: start; }
.wa-dot-name.anchor-end { text-anchor: end; }
.wa-dot-name.anchor-middle { text-anchor: middle; }
.wa-dot-name.side { dominant-baseline: middle; }
.wa-dot-name.active { font-weight: 700; fill: var(--ink); }
.wa-leader { stroke: #B9BCC2; stroke-width: 1; }
.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; }

/* ---- ฟีเจอร์ใหม่ (ปุ่ม sidebar หน้าแรก + ป๊อปอัพ changelog) ---- */
.whatsnew-btn {
  position: relative;
  border: 1px solid color-mix(in srgb, var(--green) 55%, transparent);
  background: color-mix(in srgb, var(--green) 16%, transparent);
  color: #DCEBE0;
  font-weight: 600;
}
.whatsnew-btn:hover {
  background: color-mix(in srgb, var(--green) 26%, transparent);
  color: #fff;
}
.whatsnew-dot {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #E05B4B;
  box-shadow: 0 0 0 3px color-mix(in srgb, #E05B4B 25%, transparent);
}
.whatsnew-card {
  position: relative;
  width: min(92vw, 460px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 12px 56px rgba(0,0,0,0.55);
  animation: ad-popup-pop 0.24s cubic-bezier(.2,.9,.3,1.2);
}
.whatsnew-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}
.whatsnew-badge {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--green) 14%, #fff);
  color: var(--green);
}
.whatsnew-head h2 {
  margin: 0;
  font-family: 'Prompt', sans-serif;
  font-size: 17px;
  color: var(--ink);
}
.whatsnew-head p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.whatsnew-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.whatsnew-close:hover { color: var(--ink); }
.whatsnew-body {
  padding: 14px 22px 20px;
  overflow-y: auto;
  display: grid;
  gap: 14px;
}
.whatsnew-item {
  display: grid;
  gap: 3px;
  padding-left: 14px;
  border-left: 3px solid var(--upd, var(--green));
}
.whatsnew-when {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
}
.whatsnew-item h3 {
  margin: 0;
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  color: var(--ink);
}
.whatsnew-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1.5px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: 1px;
  background: color-mix(in srgb, var(--upd, var(--green)) 14%, #fff);
  color: color-mix(in srgb, var(--upd, var(--green)) 80%, var(--ink));
}
.whatsnew-item p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
}
.whatsnew-foot {
  padding: 12px 22px 18px;
  border-top: 1px solid var(--line);
}
.whatsnew-ok {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 11px;
  background: var(--ink);
  color: #fff;
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  cursor: pointer;
}
.whatsnew-ok:hover { background: var(--ink-2); }

/* changelog จัดกลุ่มตามวัน (ป๊อปอัพฟีเจอร์ใหม่) */
.whatsnew-day {
  font-size: 12px;
  font-weight: 700;
  font-family: 'Prompt', sans-serif;
  color: var(--ink-2);
  margin-top: 4px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--line);
}
.whatsnew-item h3 {
  font-weight: 500;
  font-size: 13px;
  line-height: 1.5;
}
.whatsnew-item h3 .whatsnew-tag { margin: 0 6px 0 0; vertical-align: 1px; }

/* ---- membership price badge (สมัคร/ต่ออายุ) ---- */
.price-badge {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff; border-radius: 12px; padding: 12px 15px; margin: 4px 0 12px;
}
.price-badge-amt { font-size: 22px; font-weight: 800; line-height: 1; }
.price-badge-amt small { font-size: 12px; font-weight: 600; opacity: .85; }
.price-badge-dur { font-size: 12px; text-align: right; opacity: .95; line-height: 1.35; }

/* ---- renewal form ---- */
.renew-form { display: block; }
.renew-form .login-field { margin-top: 12px; }

/* ---- membership card (ในแอป) ---- */
.membership-card {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--green);
  border-radius: 14px; padding: 14px 18px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.membership-card.is-warn { border-left-color: var(--gold-strong); }
.membership-card.is-expired { border-left-color: var(--red); }
.membership-card-lab { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.membership-card-date { font-size: 17px; font-weight: 700; color: var(--ink); }
.membership-card-foot { display: flex; align-items: center; gap: 10px; }
.btn-renew {
  border: none; border-radius: 9px; padding: 9px 15px; font-family: inherit;
  font-size: 13px; font-weight: 700; color: #fff; background: var(--brand-strong); cursor: pointer;
}
.btn-renew:hover { filter: brightness(1.05); }

/* ---- admin renewal queue ---- */
.renewal-queue .finance-section-head h3 { color: var(--brand-strong); }
.approve-renewal-btn {
  border: none; border-radius: 8px; padding: 8px 13px; font-family: inherit;
  font-size: 12.5px; font-weight: 700; color: #fff; background: var(--green); cursor: pointer; white-space: nowrap;
}
.approve-renewal-btn:hover { filter: brightness(1.05); }

/* ============ เป้าหมายใหญ่ (org_goals) — เมนูแอดมิน ============ */
.og-list { display: flex; flex-direction: column; gap: 10px; }
.og-item { display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; background: var(--paper); }
.og-item.active { border-color: var(--gold); background: var(--gold-tint); }
.og-item-main { flex: 1; min-width: 200px; }
.og-item-name { font-weight: 700; }
.og-item-range { font-size: 12.5px; color: var(--muted); }
.og-item-target { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; text-align: right; }
.og-item-target small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.og-item-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.og-chip { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; letter-spacing: .04em; white-space: nowrap; }
.og-chip.live { background: var(--green); color: #fff; }
.og-chip.draft { background: var(--paper-2); color: var(--muted); border: 1px solid var(--line); }
.og-chip.past { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.og-del { color: var(--red); }
.og-empty { color: var(--muted); font-size: 13.5px; padding: 14px 4px; }
.og-btn { width: auto; padding: 10px 20px; }

.og-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.og-field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.og-field.og-full { grid-column: 1 / -1; }
.og-month-selects { display: flex; gap: 8px; }
.og-month-selects .form-input { flex: 1; }
.og-months-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin: 4px 0 10px; }
.og-months-table td { vertical-align: middle; }
.og-num-input { width: 130px; text-align: right; padding: 6px 9px; }
.og-focus-input { width: 100%; min-width: 140px; padding: 6px 9px; }
.og-sum-ok { color: var(--green); font-weight: 700; }
.og-sum-off { color: var(--red); font-weight: 700; }
.og-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
@media (max-width: 560px) { .og-form { grid-template-columns: 1fr; } }

/* ---- ความจุระบบ (System Capacity) — admin ---- */
.cap-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: var(--shadow-md);
  margin-top: 16px;
  max-width: 720px;
}
.cap-meter { margin-bottom: 20px; }
.cap-meter:last-child { margin-bottom: 0; }
.cap-meter-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; flex-wrap: wrap;
}
.cap-meter-name { font-weight: 600; font-size: 0.95rem; }
.cap-meter-value { font-variant-numeric: tabular-nums; font-size: 0.9rem; color: var(--ink-soft); }
.cap-meter-value strong { color: var(--ink); font-size: 1.05rem; }
.cap-bar {
  height: 10px; border-radius: 6px; background: var(--line-2);
  margin: 8px 0 6px; overflow: hidden;
}
.cap-bar i { display: block; height: 100%; border-radius: 6px; }
.cap-fill-green { background: var(--green); }
.cap-fill-gold  { background: var(--gold); }
.cap-fill-red   { background: var(--red); }
.cap-meter-cap { font-size: 0.78rem; color: var(--muted); }
.cap-bucket-list {
  margin: 10px 0 0; padding: 0; list-style: none;
  border-top: 1px dashed var(--line);
}
.cap-bucket-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px; border-bottom: 1px dashed var(--line-2); font-size: 0.88rem;
}
.cap-bucket-list li:last-child { border-bottom: 0; }
.cap-bucket-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex: none; }
.cap-bucket-name { flex: 1; }
.cap-bucket-name small { color: var(--muted); display: block; font-size: 0.76rem; }
.cap-bucket-size { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.cap-bucket-files { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.78rem; width: 70px; text-align: right; }
.cap-orphan {
  background: var(--gold-tint); border-radius: 8px; margin-top: 10px;
  padding: 8px 12px; font-size: 0.84rem;
  display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
}
.cap-orphan b { color: var(--gold-strong); }
.cap-orphan span { color: var(--ink-soft); }
.cap-orphan.ok { background: #E8F0EA; }
.cap-orphan.ok b { color: var(--green); }
.cap-unavailable { margin: 0 0 6px; font-size: 0.92rem; color: var(--ink-soft); }
.cap-skeleton {
  height: 12px; border-radius: 6px; margin-bottom: 10px;
  background: linear-gradient(90deg, var(--line-2), #F2EFE7, var(--line-2));
  background-size: 200% 100%;
  animation: cap-shimmer 1.2s ease-in-out infinite;
}
@keyframes cap-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.cap-skeleton:last-child { margin-bottom: 0; }
@media (prefers-reduced-motion: reduce) { .cap-skeleton { animation: none; } }

/* ---- ล้างไฟล์กำพร้า (Orphan cleanup) modal ---- */
.cap-orphan-txt { flex: 1; min-width: 200px; }
.cap-clean-btn {
  background: var(--card); border: 1px solid var(--gold-strong); color: var(--gold-strong);
  font: inherit; font-size: 0.82rem; font-weight: 600; padding: 7px 14px; border-radius: 8px;
  cursor: pointer; white-space: nowrap;
}
.cap-clean-btn:hover { background: var(--gold-tint); }
.orphan-cleanup { display: flex; flex-direction: column; gap: 14px; }
.orphan-warn {
  background: #FBEDEA; border: 1px solid var(--brand-soft); border-left: 3px solid var(--red);
  border-radius: 8px; padding: 10px 12px; font-size: 0.8rem; color: var(--ink-soft);
}
.orphan-warn b { color: var(--red); }
.orphan-loading, .orphan-empty { font-size: 0.88rem; color: var(--muted); padding: 6px 0; }
.orphan-selecthead { display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; color: var(--muted); }
.orphan-selecthead a { color: var(--brand); cursor: pointer; text-decoration: underline; }
.orphan-list { border: 1px solid var(--line); border-radius: 10px; max-height: 260px; overflow-y: auto; }
.orphan-group {
  background: var(--paper-2); padding: 6px 12px; font-size: 0.74rem; letter-spacing: 0.03em;
  color: var(--muted); position: sticky; top: 0; z-index: 1;
}
.orphan-group small { color: var(--ink-soft); margin-left: 8px; text-transform: none; letter-spacing: 0; }
.orphan-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-bottom: 1px dashed var(--line-2); font-size: 0.82rem; cursor: pointer;
}
.orphan-row:last-child { border-bottom: 0; }
.orphan-row input { width: 15px; height: 15px; accent-color: var(--brand); flex: none; }
.orphan-fn {
  flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.74rem;
  color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.orphan-sz { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; white-space: nowrap; }
.orphan-summary { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.9rem; padding: 2px; }
.orphan-summary b { font-size: 1.05rem; }
.orphan-reclaim { color: var(--red); }
.orphan-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

/* ============ คุณวุฒิ (qualification) — ตัวแทน + แอดมิน ============ */
/* การ์ดประจำฟีเจอร์ (โปรเจกต์ไม่มี .card กลาง — แต่ละฟีเจอร์ประกาศเอง เช่น .cap-card) */
.qual-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; box-shadow: var(--shadow-sm); }
.qual-card + .qual-card { margin-top: 14px; }
.qual-card h3 { margin: 0 0 14px; font-size: 16px; font-weight: 700; color: var(--ink); }
.qual-card h4 { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink); }
.qual-empty { color: var(--muted); font-size: 13.5px; padding: 18px 4px; }

/* --- การ์ดเป้าหมายถัดไป --- */
.qual-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 22px; align-items: center; }
.qual-hero-cap { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.qual-hero-num { font-size: 40px; font-weight: 700; line-height: 1.05; letter-spacing: -.02em;
  color: var(--ink); font-variant-numeric: tabular-nums; }
.qual-hero-num span { font-size: .45em; color: var(--muted); font-weight: 600; margin-left: 4px; }
.qual-hero-sub { font-size: 13.5px; color: var(--ink-soft); margin-top: 8px; }
.qual-hero-sub.pace { color: var(--green); font-weight: 600; }
.qual-hero-sub.late { color: var(--brand-strong); font-weight: 600; }
.qual-gauge { flex: none; width: 148px; text-align: center; }
.qual-gauge svg { width: 100%; height: auto; display: block; }
.qual-gauge-cap { font-size: 12px; color: var(--muted); margin-top: -14px; }

/* --- แถบความคืบหน้ารายขั้น --- */
.qual-bars { display: flex; flex-direction: column; gap: 13px; }
.qual-bar { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; align-items: center; }
.qual-bar-label { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.qual-bar-label small { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted);
  font-variant-numeric: tabular-nums; }
.qual-bar-track { position: relative; height: 13px; border-radius: 999px;
  background: var(--paper-2); overflow: hidden; }
.qual-bar-fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 999px;
  background: var(--brand); transition: width .45s cubic-bezier(.2,.7,.2,1); }
.qual-bar-fill.reached { background: var(--green); }
.qual-bar-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 5px;
  font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.qual-bar-meta b { color: var(--ink); font-weight: 700; }
.qual-bar-meta .done { color: var(--green); font-weight: 700; }
.qual-note { font-size: 13px; color: var(--muted); margin: 16px 0 0; }
.qual-note b { color: var(--brand-strong); }

/* --- กระดานผู้ถึงคุณวุฒิ --- */
.qual-club { border-top: 1px solid var(--line-2); padding: 14px 0; }
.qual-club:first-child { border-top: 0; padding-top: 2px; }
.qual-club-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 9px; flex-wrap: wrap; }
.qual-club-name { font-size: 15px; font-weight: 700; color: var(--ink); }
.qual-club-req { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.qual-club-count { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.qual-people { display: flex; flex-wrap: wrap; gap: 8px; }
.qual-person { display: inline-flex; align-items: center; gap: 8px; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 13px 4px 5px;
  font-size: 13.5px; color: var(--ink); }
.qual-person.me { background: var(--gold-tint); border-color: var(--gold); font-weight: 600; }
.qual-person-av { width: 24px; height: 24px; border-radius: 50%; flex: none; background: var(--brand);
  color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.qual-person-amt { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.qual-club-empty { font-size: 13.5px; color: var(--muted); font-style: italic; }
.qual-roster { margin-top: 16px; padding-top: 15px; border-top: 1px solid var(--qual-border, var(--line-2)); }
.qual-roster-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.qual-roster-head h3 { margin: 0; }
.qual-roster-head > span { color: var(--muted); font-size: 12px; }
.qual-roster-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.qual-roster-filters button { padding: 5px 10px; border: 1px solid var(--qual-border, var(--line-2)); border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: 11px; cursor: pointer; }
.qual-roster-filters button:hover { border-color: var(--qual-accent, var(--gold-strong)); color: var(--qual-heading, var(--ink)); }
.qual-roster-filters button.active { border-color: var(--qual-accent, var(--gold-strong)); background: var(--qual-accent, var(--gold-strong)); color: #FFFFFF; }
.qual-roster-list { display: grid; gap: 7px; }
.qual-roster-row { display: grid; grid-template-columns: minmax(250px, 30%) minmax(0, 1fr); align-items: center; gap: 24px;
  min-width: 0; padding: 9px 10px; border: 1px solid var(--qual-border, var(--line-2));
  border-radius: 10px; background: var(--qual-panel-muted, var(--paper-2)); }
.qual-roster-row.me { border-color: var(--gold); background: var(--gold-tint); }
.qual-roster-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.qual-roster-logo { width: 48px; height: 48px; flex: none; object-fit: contain; border-radius: 50%; filter: drop-shadow(0 2px 4px rgba(15, 18, 61, .16)); }
.qual-roster-name { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.qual-roster-name small { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.qual-roster-rank { min-width: 24px; color: var(--qual-heading, var(--ink)); font-size: 12px; font-weight: 800; text-align: center; }
.qual-roster-rank.rank-1 { color: #B07B13; font-size: 14px; }
.qual-roster-rank.rank-2 { color: #718096; }
.qual-roster-rank.rank-3 { color: #9A5B37; }
.qual-roster-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qual-roster-status { display: flex; flex-direction: column; align-items: flex-end; gap: 1px;
  min-width: 0; text-align: right; color: var(--qual-heading, var(--ink)); }
.qual-roster-status > b, .qual-roster-status > small { display: none; }
.qual-roster-status.none b { color: var(--gold-strong); }
.qual-roster-progress { display: block; width: 100%; margin-top: 7px; }
.qual-roster-progress-track { display: block; height: 8px; overflow: hidden; border-radius: 999px; background: var(--qual-border, var(--line-2)); }
.qual-roster-progress-track > span { display: block; height: 100%; border-radius: inherit; background: var(--qual-accent, var(--gold-strong)); transition: width .25s ease; }
.qual-roster-progress-track.passed > span { background: #3F7A54; }
.qual-roster-progress-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 3px; }
.qual-roster-progress-meta small { color: var(--muted); font-size: 10px; white-space: nowrap; }
.qual-roster-progress-meta small b { color: var(--qual-heading, var(--ink)); font-size: 11px; }

@media (max-width: 560px) {
  .qual-roster-row { grid-template-columns: 1fr; align-items: flex-start; gap: 7px; }
  .qual-roster-status { align-items: flex-start; text-align: left; width: 100%; }
  .qual-roster-progress { width: 100%; }
  .qual-roster-filters { margin-top: 4px; }
}

/* --- ฟอร์มแอดมิน --- */
.qual-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.qual-field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.qual-field.qual-full { grid-column: 1 / -1; }
.qual-tier-input { width: 150px; text-align: right; padding: 6px 9px; }
.qual-tier-label-input { width: 100%; min-width: 130px; padding: 6px 9px; }
.qual-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.qual-btn { width: auto; padding: 10px 20px; }

@media (max-width: 760px) {
  .qual-hero { grid-template-columns: minmax(0, 1fr); }
  .qual-gauge { width: 132px; margin: 0 auto; }
}
@media (max-width: 560px) {
  .qual-form { grid-template-columns: 1fr; }
  .qual-bar { grid-template-columns: minmax(0, 1fr); gap: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .qual-bar-fill { transition: none; }
}

/* ---- คุณวุฒิ: เกณฑ์เลือกชนิดได้ (เบี้ย / ค่าคอมฯ) ---- */
/* ป้ายกำกับชนิดเกณฑ์ — จำเป็นเพราะเบี้ยกับค่าคอมฯ คนละสเกล ถ้าไม่ติดป้ายจะอ่านผิด */
.qual-metric-chip { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
  border-radius: 999px; padding: 1px 8px; white-space: nowrap; vertical-align: middle; }
.qual-metric-chip.ape { background: var(--gold-tint); color: var(--gold-strong); border: 1px solid var(--gold); }
.qual-metric-chip.fyc { background: var(--paper-2); color: var(--ink-soft); border: 1px solid var(--muted); }
/* FYP อยู่โทนทองเดียวกับเบี้ย APE แต่กลับเป็นพื้นทึบ เพราะเป็นเบี้ยเหมือนกันแค่ไม่ถัวเฉลี่ย
   ถ้าใช้ tint เหมือน .ape จะแยกไม่ออกตอนอยู่คนละขั้นในลิสต์เดียวกัน */
.qual-metric-chip.fyp { background: var(--gold-strong); color: var(--paper); border: 1px solid var(--gold-strong); }
/* คุณวุฒิพิเศษวัดด้วยจำนวนราย/จำนวนคนได้ ถ้าไม่มีสไตล์ ป้ายจะกลายเป็นข้อความเปล่า
   กลืนไปกับชื่อขั้น แล้วชนิดเกณฑ์จะหายไปจากสายตาทั้งที่ยังพิมพ์อยู่
   อยู่ในโทน ember/gold/ink เดิม ไม่เพิ่มสีใหม่ ตามระบบสีที่ประกาศไว้ที่ :root */
.qual-metric-chip.cases { background: rgba(184,80,58,.12); color: var(--brand-strong); border: 1px solid var(--brand-soft); }
.qual-metric-chip.recruit { background: var(--ink-2); color: var(--paper); border: 1px solid var(--ink-2); }
/* แท่งของขั้นที่วัดด้วยค่าคอมฯ ใช้โทนเข้มกว่าเพื่อแยกจากแท่งเบี้ยสีอิฐ */
.qual-bar-fill.fyc { background: var(--ink-soft); }
/* ราย/คนต้องมีสีของตัวเอง ไม่งั้นแท่งจะเหมือนเบี้ยเป๊ะ ๆ แล้วสีก็เลิกสื่อความหมาย
   ห้ามใช้โทนเขียว เพราะเขียวจองไว้ให้ .reached แล้ว จะอ่านเป็น "ผ่านแล้ว" ทันที */
.qual-bar-fill.cases { background: var(--gold-strong); }
.qual-bar-fill.recruit { background: var(--ink-2); }
/* แท่ง FYP = ember เข้มกว่าแท่งเบี้ยพื้นฐาน ไม่งั้นสองขั้นนี้จะเป็นสีเดียวกันเป๊ะ */
.qual-bar-fill.fyp { background: var(--brand-strong); }
/* ต้องประกาศ .reached ซ้ำตรงนี้ (มีอยู่แล้วด้านบน) เพราะ specificity เท่ากับ .fyc/.cases/.recruit
   ถ้าไม่วางไว้หลังทุกตัว ขั้นที่ผ่านแล้วจะไม่เป็นสีเขียว — อย่าลบทิ้งเพราะคิดว่าซ้ำ */
.qual-bar-fill.reached { background: var(--green); }
.qual-tier-metric { width: 100%; min-width: 132px; padding: 6px 9px; }
.qual-cell-pending { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }

/* ---- คุณวุฒิ: ตราโลโก้ MDRT (ไฟล์ต้นฉบับ photos/mdrt-crest.png — ห้ามย้อมสี/บิดสัดส่วน) ---- */
/* ตราประจำขั้น: ขั้นที่ยังไม่ถึงเป็นขาวดำจาง = "ล็อกอยู่" ขั้นที่ผ่านแล้วสว่างเต็มสี */
.qual-crest { flex: none; object-fit: contain; }
.qual-crest.locked { filter: grayscale(1); opacity: .38; }
.qual-bar-label { display: flex; align-items: center; gap: 8px; }
/* ป้ายชื่อขั้นกว้างขึ้นเพราะมีทั้งตรา ชื่อขั้น และป้ายชนิดเกณฑ์ */
.qual-bar { grid-template-columns: 150px minmax(0, 1fr); }
/* หัวกลุ่มในกระดานเดิมจัดแบบ baseline — พอมีรูปต้องเป็น center ไม่งั้นตราจะลอย */
.qual-club-head { align-items: center; }

/* ลายน้ำในการ์ดฮีโร่ — ขาวดำ opacity ต่ำ ไม่ให้แย่งตัวเลขพระเอก */
.qual-wm { position: relative; overflow: hidden; }
/* วางชิดขอบล่างขวาและปล่อยให้ขอบการ์ดตัด เพื่อไม่ให้ไปทับตัวเลข % ในเกจ */
.qual-wm::after {
  content: ""; position: absolute; right: -44px; bottom: -74px; width: 210px; height: 210px;
  background: url("photos/mdrt-crest.png") no-repeat center / contain;
  filter: grayscale(1); opacity: .055; pointer-events: none; z-index: 0;
}
.qual-wm .qual-hero { position: relative; z-index: 1; }

/* การ์ด "ผ่านครบทุกขั้น" — โลโก้วางบนแผ่นขาวเสมอ เพราะ wordmark สีดำจะจมหายบนพื้นหมึก */
.qual-crown {
  position: relative; overflow: hidden; border-radius: 14px; padding: 24px 26px;
  background: linear-gradient(140deg, var(--ink-2) 0%, var(--sidebar-strong) 62%);
  color: #F5F1E8; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px; align-items: center; box-shadow: var(--shadow-md);
}
.qual-crown-glow {
  position: absolute; right: -40px; bottom: -110px; width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(231, 200, 120, .20) 0%, rgba(231, 200, 120, 0) 68%);
  pointer-events: none;
}
.qual-crown-body { position: relative; }
.qual-crown-cap { font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--gold); font-weight: 700; }
.qual-crown-num { font-size: 34px; font-weight: 700; line-height: 1.1; margin-top: 6px;
  letter-spacing: -.015em; }
.qual-crown-sub { font-size: 13.5px; color: var(--muted-on-dark); margin-top: 8px;
  font-variant-numeric: tabular-nums; }
.qual-crown-plate {
  position: relative; display: grid; place-items: center; background: #FFFFFF;
  border-radius: 16px; padding: 14px 20px;
  box-shadow: 0 0 0 1px rgba(231, 200, 120, .55), 0 10px 30px rgba(0, 0, 0, .35);
}
.qual-crown-plate img { display: block; width: 92px; height: auto; }

@media (max-width: 760px) {
  .qual-wm::after { display: none; }
  .qual-crown { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  .qual-crown-num { font-size: 28px; }
}
@media (max-width: 560px) {
  .qual-bar { grid-template-columns: minmax(0, 1fr); }
}

/* ---- KTAXA PRIME Agent: โปรแกรมคู่ขนานกับ MDRT ---- */
.qual-switches { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap; min-width: 0; margin-bottom: 16px; }
/* ชื่อคุณวุฒิพิเศษอาจยาวหรือมีหลายรายการ — ให้เลื่อนเฉพาะแถบโปรแกรมแทนการดันหน้าล้น */
.qual-program-switch { max-width: 100%; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.qual-program-switch .ts-seg-btn { flex: 0 0 auto; white-space: nowrap; }

.qual-prime-levels { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px;
  margin-bottom: 14px; }
.qual-prime-level { position: relative; min-width: 0; width: 100%; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 10px 10px 36px; box-shadow: var(--shadow-sm);
  color: var(--ink); font: inherit; text-align: left; cursor: pointer; appearance: none; }
.qual-prime-level b { display: block; color: var(--ink); font-size: 13px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.qual-prime-level small { display: block; color: var(--muted); font-size: 10.5px; margin-top: 2px;
  white-space: nowrap; font-variant-numeric: tabular-nums; }
.qual-prime-level-dot { position: absolute; left: 10px; top: 12px; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; border: 1px solid var(--line); color: #fff; font-size: 10px; font-weight: 700; }
.qual-prime-level.passed { border-color: color-mix(in srgb, var(--green) 55%, var(--line)); }
.qual-prime-level.passed .qual-prime-level-dot { background: var(--green); border-color: var(--green); }
.qual-prime-level.current { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), var(--shadow-sm); }
.qual-prime-level.target { background: var(--gold-tint); border-color: var(--gold); }
.qual-prime-level.selected { box-shadow: 0 0 0 2px var(--gold), var(--shadow-sm); }

.qual-prime-hero-card { overflow: hidden; position: relative; border-color: color-mix(in srgb, var(--gold) 50%, var(--line)); }
.qual-prime-hero-card::after { content: ""; position: absolute; right: -12px; bottom: -78px;
  width: 230px; height: 230px; border-radius: 50%;
  background: url("photos/ktaxa-prime-logo.png") no-repeat center / contain;
  opacity: .035; pointer-events: none; }
.qual-prime-hero-card > * { position: relative; z-index: 1; }
.qual-prime-kicker { display: block; color: var(--gold-strong); font-size: 10.5px; font-weight: 700;
  letter-spacing: .11em; margin-bottom: 5px; }
.qual-prime-chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 10px;
  background: var(--ink-2); color: var(--gold); font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.qual-prime-medal { display: block; width: 30px; height: 30px; object-fit: contain; border-radius: 50%;
  flex: none; border: 1px solid color-mix(in srgb, var(--gold) 72%, transparent);
  box-shadow: 0 2px 8px rgba(21, 18, 61, .2); }

.qual-criteria { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.qual-criterion { background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.qual-criterion > span { display: block; color: var(--muted); font-size: 11.5px; margin-bottom: 3px; }
.qual-criterion b { display: block; color: var(--ink); font-size: 18px; font-variant-numeric: tabular-nums; }
.qual-criterion b small { color: var(--muted); font-size: 12px; font-weight: 600; }
.qual-criterion em { display: block; color: var(--brand-strong); font-size: 11.5px; font-style: normal; margin-top: 3px; }
.qual-criterion.done { border-color: color-mix(in srgb, var(--green) 48%, var(--line)); }
.qual-criterion.done em { color: var(--green); font-weight: 700; }
.qual-prime-note { margin: 12px 0 0; color: var(--muted); font-size: 11.5px; }

.qual-benefits-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 13px; }
.qual-benefits-head h3 { margin-bottom: 0; }
.qual-benefit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 14px; }
.qual-benefit-item { display: flex; gap: 8px; align-items: flex-start; color: var(--ink-soft); font-size: 13px;
  padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.qual-benefit-item > span { flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid;
  place-items: center; background: var(--gold-tint); color: var(--gold-strong); font-size: 10px; font-weight: 700; }

@media (max-width: 900px) {
  .qual-prime-levels { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .qual-switches, .qual-switches .ts-seg { width: 100%; }
  .qual-switches .ts-seg-btn { flex: 1 1 auto; }
  .qual-switches .qual-program-switch .ts-seg-btn { flex: 0 0 auto; }
  .qual-prime-levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qual-criteria, .qual-benefit-grid { grid-template-columns: minmax(0, 1fr); }
  .qual-benefits-head { align-items: flex-start; flex-direction: column; }
}

@media print {
  .qual-card, .qual-prime-level { box-shadow: none; break-inside: avoid; }
  .qual-prime-medal { box-shadow: none; }
  .qual-prime-hero-card::after { display: none; }
  .qual-benefit-item, .qual-criterion { break-inside: avoid; }
}

/* ---- คุณวุฒิ: แถบรายคนในหน้า admin/manager (แทนตารางตัวเลขเดิม) ---- */
/* คอลัมน์ซ้ายกว้างกว่าหน้าตัวแทน เพราะต้องใส่ชื่อคน ทีม และขั้นที่ถึงแล้ว */
.qual-arows { display: flex; flex-direction: column; }
.qual-arow {
  display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 14px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--line-2);
}
.qual-arow:first-child { border-top: 0; padding-top: 2px; }
.qual-arow-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* ช่องตรากว้างคงที่ ชื่อจึงตรงแนวกันทุกแถว แม้ขั้นที่ตั้งเองจะไม่มีตรา */
.qual-arow-crest { flex: none; width: 34px; display: flex; align-items: center; justify-content: center; }
.qual-arow-who { display: flex; flex-direction: column; min-width: 0; }
.qual-arow-who b { font-size: 13.5px; font-weight: 700; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qual-arow-who small { font-size: 11.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* คอลัมน์ที่สามมีเฉพาะแถวที่ผู้ใช้คนนี้ปรับยอดได้ — ไม่งั้นจะเหลือช่องว่างลอยทุกแถว */
.qual-arow.has-adjust { grid-template-columns: 210px minmax(0, 1fr) auto; }
.qual-adjust-btn { font-size: 11.5px; padding: 4px 10px; white-space: nowrap; }

/* ป้าย "ยกมา" — ฝั่งผู้จัดการ/แอดมินเท่านั้น (หน้าตัวแทนไม่มีป้ายนี้โดยตั้งใจ) */
.qual-carried-chip {
  align-self: flex-start; margin-top: 3px; font-size: 10.5px; font-weight: 600;
  padding: 1px 7px; border-radius: 999px; white-space: nowrap;
  color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent);
}

/* หน้าต่างปรับยอด */
.qual-adjust-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.qual-adjust-form .qual-full { grid-column: 1 / -1; }
.qual-adjust-preview {
  margin-top: 14px; padding: 12px; border-radius: 10px;
  background: var(--paper-2); font-size: 12.5px; color: var(--muted);
}
.qual-adjust-sum { margin-top: 6px; font-size: 14px; color: var(--ink); }
.qual-adjust-sum.warn { color: var(--danger, #c0392b); font-size: 12.5px; }
.qual-adjust-note { margin-top: 8px; font-size: 11.5px; line-height: 1.6; }

@media (max-width: 760px) {
  .qual-arow, .qual-arow.has-adjust { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .qual-adjust-form { grid-template-columns: minmax(0, 1fr); }

  /* มือถือ: ปุ่มปรับยอดย่อเป็นปุ่มจิ๋วลอยมุมขวาบน แนวเดียวกับชื่อ (ผู้ใช้เลือกเอง 3 ส.ค. 69)
     แถวเตี้ยลงหนึ่งบรรทัด แลกกับต้องกันที่ด้านขวาให้ชื่อ/ป้ายยกมา ไม่งั้นทับกัน
     top ต้องล้อกับ padding-top ของแถว (11px ปกติ / 2px แถวแรก) ให้ปุ่มตรงบรรทัดชื่อพอดี */
  .qual-arow.has-adjust { position: relative; }
  .qual-arow.has-adjust .qual-adjust-btn {
    position: absolute; top: 11px; right: 0;
    font-size: 11px; padding: 3px 10px; border-radius: 999px;
  }
  .qual-arow.has-adjust:first-child .qual-adjust-btn { top: 2px; }
  .qual-arow.has-adjust .qual-arow-id { padding-right: 76px; }
}

/* ปุ่ม "+ เพิ่มคุณวุฒิพิเศษ" — เส้นประบอกว่ายังไม่มีของ ต่างจากแท็บที่มีคุณวุฒิอยู่จริง
   ต้องประกาศ border ครบทั้ง width/style/color เพราะ .ts-seg-btn ตั้ง border: 0 ไว้
   ใส่แค่ border-style จะไม่เห็นอะไรเลย (ความกว้างยังเป็น 0)
   ลด padding ลง 1px ชดเชยเส้นขอบ ให้ปุ่มสูงเท่าแท็บอื่นในแถวเดียวกัน */
.qual-seg-add { border: 1px dashed var(--line-2); padding: 4px 13px; }

/* ============ คุณวุฒิ: Contextual Theme ตามโปรแกรม ============
   เปลี่ยนเฉพาะพื้นที่ .scene ของคุณวุฒิ ไม่แตะ Sidebar/Topbar/Theme หลักของระบบ
   KTAXA PRIME อ้าง palette จากเอกสารบริษัท: Navy #15123D, Prime Blue #2E3092,
   Silver Blue #B4BCD3, Champagne #D2C6A9, Gold #DAB776 */
@media screen {
.main.main-qualification {
  display: flex;
  flex-direction: column;
}
.main.main-qualification > .topbar {
  flex: 0 0 auto;
  width: 100%;
  background: #F6F5F1;
}
.main.main-qualification > section.scene.qual-theme {
  flex: 1 0 auto;
  width: 100%;
  min-width: 0;
}

.qual-theme {
  --qual-panel: var(--card);
  --qual-panel-muted: var(--paper-2);
  --qual-border: var(--line);
  --qual-heading: var(--ink);
  --qual-copy: var(--ink-soft);
  --qual-progress: var(--brand);
  --qual-achieved: var(--green);
  background-color: var(--paper);
  transition: background-color .18s ease;
}
.qual-theme .qual-card {
  background: var(--qual-panel);
  border-color: var(--qual-border);
  color: var(--qual-copy);
}
.qual-theme .qual-card h3,
.qual-theme .qual-card h4,
.qual-theme .qual-club-name,
.qual-theme .qual-arow-who b { color: var(--qual-heading); }
.qual-theme .qual-bar-track { background: var(--qual-panel-muted); }
/* :where ทำให้ default มี specificity ต่ำกว่า .fyc/.cases/.recruit ของ custom program */
:where(.qual-theme) .qual-bar-fill { background: var(--qual-progress); }
.qual-theme .qual-bar-fill.reached { background: var(--qual-achieved); }

/* --- Header แบบ Achievement: ใช้ร่วมกัน แต่แต่ละโปรแกรมคนละบุคลิก --- */
.qual-theme-prime > .section-head,
.qual-theme-mdrt > .section-head {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 24px 26px;
  border-radius: 18px;
  margin-bottom: 20px;
  box-shadow: 0 16px 34px rgba(21, 18, 61, .14);
}
.qual-theme-prime > .section-head::after,
.qual-theme-mdrt > .section-head::after {
  content: "";
  position: absolute;
  z-index: -1;
  right: -80px;
  bottom: -150px;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  pointer-events: none;
}
.qual-theme-prime > .section-head .section-title,
.qual-theme-mdrt > .section-head .section-title { color: #FFFFFF; }
.qual-theme-prime > .section-head .section-sub,
.qual-theme-mdrt > .section-head .section-sub { color: rgba(255, 255, 255, .76); }
.qual-theme-prime > .section-head .page-print-btn,
.qual-theme-mdrt > .section-head .page-print-btn {
  color: #FFFFFF;
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .28);
}
.qual-theme-prime > .section-head .page-print-btn:hover,
.qual-theme-mdrt > .section-head .page-print-btn:hover { background: rgba(255, 255, 255, .16); }

/* --- KTAXA PRIME: Premium Navy Achievement --- */
section.scene.qual-theme-prime {
  --qual-panel: #FFFFFF;
  --qual-panel-muted: #EEF0F6;
  --qual-border: #D7D8E1;
  --qual-heading: #15123D;
  --qual-copy: #4E4C62;
  --qual-progress: #2E3092;
  --qual-achieved: #DAB776;
  color: #EAE4D3;
  background:
    radial-gradient(circle at 94% 4%, rgba(46, 48, 146, .68), transparent 31%),
    radial-gradient(circle at 68% 22%, rgba(218, 183, 118, .14), transparent 24%),
    linear-gradient(145deg, #0F0D2C 0%, #15123D 58%, #181545 100%);
}
.qual-theme-prime > .section-head {
  align-items: center;
  padding: 0 0 20px;
  border: 0;
  border-bottom: 1px solid rgba(210, 198, 169, .32);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.qual-theme-prime > .section-head::after { display: none; }
.qual-theme-prime > .section-head .eyebrow { color: #DAB776; }
.qual-theme-prime > .section-head .section-title {
  font-family: 'DM Serif Display', 'IBM Plex Sans Thai', serif;
  letter-spacing: .005em;
}
.qual-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}
.qual-prime-logo {
  display: block;
  width: 106px;
  height: auto;
  aspect-ratio: 1;
  flex: none;
  object-fit: contain;
  border: 1px solid rgba(218, 183, 118, .72);
  border-radius: 50%;
  box-shadow: 0 12px 34px rgba(4, 3, 18, .34), 0 0 0 5px rgba(218, 183, 118, .07);
}
.qual-mdrt-logo {
  display: block;
  width: 106px;
  height: auto;
  aspect-ratio: 1;
  flex: none;
  object-fit: contain;
  padding: 8px;
  border: 1px solid rgba(231, 200, 120, .72);
  border-radius: 12px;
  background: #FFFFFF;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .24), 0 0 0 5px rgba(231, 200, 120, .07);
}

.qual-theme-prime .qual-switches .ts-seg {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(210, 198, 169, .28);
}
.qual-theme-prime .qual-switches .ts-seg-btn { color: #EAE4D3; }
.qual-theme-prime .qual-switches .ts-seg-btn:hover { color: #FFFFFF; }
.qual-theme-prime .qual-switches .qual-seg-add { border-color: rgba(210, 198, 169, .42); }
.qual-theme-prime .qual-switches .ts-seg-btn.active {
  background: #DAB776;
  color: #15123D;
  box-shadow: 0 4px 14px rgba(4, 3, 18, .28);
}
.qual-theme-prime .qual-card { box-shadow: 0 8px 24px rgba(21, 18, 61, .07); }

/* ระดับ Agent อยู่ในตระกูล Navy เดียวกัน; Gold ใช้เมื่อผ่าน, Prime Blue ใช้เป้าถัดไป */
.qual-theme-prime .qual-prime-level {
  background: #FFFFFF;
  border-color: #B4BCD3;
  box-shadow: 0 4px 14px rgba(21, 18, 61, .06);
}
.qual-theme-prime .qual-prime-level b { color: #15123D; }
.qual-theme-prime .qual-prime-level small { color: #656477; }
.qual-theme-prime .qual-prime-level-dot { border-color: #B4BCD3; }
.qual-theme-prime .qual-prime-level.passed {
  background: #EAE4D3;
  border-color: #DAB776;
}
.qual-theme-prime .qual-prime-level.passed .qual-prime-level-dot {
  background: #DAB776;
  border-color: #DAB776;
  color: #15123D;
}
.qual-theme-prime .qual-prime-level.current {
  border-color: #A8884E;
  box-shadow: 0 0 0 2px rgba(218, 183, 118, .32), 0 6px 18px rgba(21, 18, 61, .10);
}
.qual-theme-prime .qual-prime-level.target {
  background: #2E3092;
  border-color: #2E3092;
}
.qual-theme-prime .qual-prime-level.target b { color: #FFFFFF; }
.qual-theme-prime .qual-prime-level.target small { color: #EAE4D3; }
.qual-theme-prime .qual-prime-level.target .qual-prime-level-dot { border-color: #D2C6A9; }
.qual-theme-prime .qual-prime-level.selected {
  box-shadow: 0 0 0 2px #DAB776, 0 6px 18px rgba(21, 18, 61, .12);
}

/* Canvas เป็น Navy เต็มพื้นที่แล้ว Hero จึงใช้ Ivory เพื่อรักษาความชัดของ NBC/จำนวนราย */
.qual-theme-prime .qual-prime-hero-card {
  --qual-gauge-track: #E1E3EC;
  --qual-gauge-fill: #2E3092;
  --qual-gauge-ink: #15123D;
  background:
    radial-gradient(circle at 90% 18%, rgba(46, 48, 146, .08), transparent 24%),
    linear-gradient(145deg, #FFFFFF, #F7F5EF);
  border-color: rgba(218, 183, 118, .76);
  color: #15123D;
  box-shadow: 0 18px 42px rgba(4, 3, 18, .24);
}
.qual-theme-prime .qual-prime-hero-card::after {
  content: "";
  right: -28px;
  bottom: -56px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: url("photos/ktaxa-prime-logo.png") no-repeat center / contain;
  opacity: .055;
}
.qual-theme-prime .qual-prime-hero-card .qual-prime-kicker {
  color: #7A5D25;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 12px;
}
.qual-theme-prime .qual-prime-hero-card .qual-hero-cap,
.qual-theme-prime .qual-prime-hero-card .qual-gauge-cap { color: #656477; }
.qual-theme-prime .qual-prime-hero-card .qual-hero-num { color: #15123D; }
.qual-theme-prime .qual-prime-hero-card .qual-hero-num span { color: #656477; }
.qual-theme-prime .qual-prime-hero-card .qual-hero-sub { color: #4E4C62; }
.qual-theme-prime .qual-prime-hero-card .qual-criterion {
  background: #EEF0F6;
  border-color: #B4BCD3;
}
.qual-theme-prime .qual-prime-hero-card .qual-criterion > span,
.qual-theme-prime .qual-prime-hero-card .qual-criterion b small { color: #656477; }
.qual-theme-prime .qual-prime-hero-card .qual-criterion b { color: #15123D; }
.qual-theme-prime .qual-prime-hero-card .qual-criterion em { color: #2E3092; }
.qual-theme-prime .qual-prime-hero-card .qual-criterion.done { border-color: #DAB776; }
.qual-theme-prime .qual-prime-hero-card .qual-criterion.done em { color: #2E3092; }
.qual-theme-prime .qual-prime-hero-card .qual-prime-note { color: #656477; }

/* สิทธิประโยชน์: Navy เป็นหัวหมวด, พื้นรายการยังสว่าง */
.qual-theme-prime .qual-benefits { overflow: hidden; border-top: 3px solid #DAB776; }
.qual-theme-prime .qual-benefits-head {
  margin: -18px -18px 13px;
  padding: 17px 18px 15px;
  background: #15123D;
}
.qual-theme-prime .qual-benefits-head h3 { color: #FFFFFF; }
.qual-theme-prime .qual-benefits-head .qual-prime-kicker { color: #DAB776; }
.qual-theme-prime .qual-prime-chip { background: #DAB776; color: #15123D; }
.qual-theme-prime .qual-benefit-item { color: #4E4C62; border-color: #E3E0D8; }
.qual-theme-prime .qual-benefit-item > span { background: #E5E8F2; color: #2E3092; }

/* ตารางเกณฑ์และกระดาน: หัว Navy แต่แถวข้อมูลสว่าง */
.qual-theme-prime .dash-table thead th { background: #15123D; color: #EAE4D3; }
.qual-theme-prime .qual-club { border-color: #D7D8E1; }
.qual-theme-prime .qual-prime-medal {
  border-color: rgba(218, 183, 118, .78);
  box-shadow: 0 2px 10px rgba(21, 18, 61, .24), 0 0 0 2px rgba(218, 183, 118, .1);
}
.qual-theme-prime .qual-person { background: #F0F2F7; border-color: #D7D8E1; }
.qual-theme-prime .qual-person.me { background: #EAE4D3; border-color: #DAB776; }
.qual-theme-prime .qual-person-av { background: #2E3092; }
.qual-theme-prime .qual-metric-chip.fyc { background: #E5E8F2; color: #2E3092; border-color: #B4BCD3; }
.qual-theme-prime .qual-bar-fill.fyc { background: #2E3092; }
.qual-theme-prime .qual-bar-fill.fyc.reached { background: #DAB776; }
.qual-theme-prime .qual-bar-meta .done { color: #7A5D25; }

/* --- MDRT: Classic Ink & Gold --- */
section.scene.qual-theme-mdrt {
  --qual-panel: #FFFFFF;
  --qual-panel-muted: #EFEAE0;
  --qual-border: #DED6C5;
  --qual-heading: #242220;
  --qual-copy: #5C5750;
  --qual-progress: #A6791E;
  --qual-achieved: #3F7A54;
  color: #F7ECCF;
  background:
    radial-gradient(circle at 92% 5%, rgba(231, 200, 120, .22), transparent 30%),
    linear-gradient(145deg, #211E1A 0%, #302D28 100%);
}
.qual-theme-mdrt > .section-head {
  padding: 0 0 20px;
  border: 0;
  border-bottom: 1px solid rgba(231, 200, 120, .30);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.qual-theme-mdrt > .section-head::after { display: none; }
.qual-theme-mdrt > .section-head .eyebrow { color: #E7C878; }
.qual-theme-mdrt .qual-switches .ts-seg {
  background: rgba(255, 255, 255, .07);
  border-color: rgba(231, 200, 120, .28);
}
.qual-theme-mdrt .qual-switches .ts-seg-btn { color: #F2E7CE; }
.qual-theme-mdrt .qual-switches .qual-seg-add { border-color: rgba(231, 200, 120, .40); }
.qual-theme-mdrt .qual-switches .ts-seg-btn.active {
  background: #E7C878;
  color: #242220;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .24);
}
.qual-theme-mdrt .qual-wm {
  --qual-gauge-track: #E6DFD1;
  --qual-gauge-fill: #A6791E;
  --qual-gauge-ink: #242220;
  background: linear-gradient(135deg, #FFFFFF, #FBF7EC);
  border-color: #DED6C5;
}
.qual-theme-mdrt .qual-bar-fill.ape { background: #A6791E; }
.qual-theme-mdrt .qual-bar-fill.ape.reached { background: #3F7A54; }
.qual-theme-mdrt .dash-table thead th { background: #302D28; color: #F7ECCF; }
.qual-theme-mdrt .qual-person.me { background: #F7ECCF; border-color: #E7C878; }
.qual-theme-prime > .section-head :focus-visible,
.qual-theme-prime > .qual-switches :focus-visible { outline-color: #DAB776; }
.qual-theme-mdrt > .section-head :focus-visible,
.qual-theme-mdrt > .qual-switches :focus-visible { outline-color: #E7C878; }

.qual-theme-prime > .sales-empty,
.qual-theme-prime > .loading-msg { color: #D2D5E2; }
.qual-theme-mdrt > .sales-empty,
.qual-theme-mdrt > .loading-msg { color: #E7DDC8; }
.qual-theme-prime > .form-error,
.qual-theme-mdrt > .form-error {
  padding: 10px 12px;
  border: 1px solid #E9B9AE;
  border-radius: 8px;
  background: #FBEDEA;
  color: #8D3427;
}

/* การ์ดรายการย้อนหลังเป็นข้อมูลของ custom program หลายชุด จึงคงโทนกลางแม้กำลังเลือก PRIME/MDRT */
.qual-theme .qual-archive-card {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
}
.qual-theme .qual-archive-card h3 { color: var(--ink); }
}

@media screen and (max-width: 1100px) {
  .main.main-qualification {
    min-height: 100vh;
    min-height: 100dvh;
  }
}

@media screen and (max-width: 760px) {
  .qual-theme-prime > .section-head,
  .qual-theme-mdrt > .section-head { padding: 0 0 16px; border-radius: 0; }
  .qual-prime-logo { width: 76px; }
  .qual-mdrt-logo { width: 76px; }
  .qual-theme-prime .qual-prime-hero-card::after {
    right: -34px;
    bottom: -42px;
    width: 176px;
    height: 176px;
  }
}

@media screen and (max-width: 560px) {
  .qual-head-actions { width: 100%; justify-content: space-between; margin-left: 0; }
}

@media screen and (prefers-reduced-motion: reduce) {
  .qual-theme { transition: none; }
}

@media print {
  .qual-head-actions { display: block; width: 100%; }
  .qual-head-actions .print-head { width: 100%; }
  .qual-prime-logo,
  .qual-mdrt-logo { display: none !important; }
  section.scene.qual-theme-prime,
  section.scene.qual-theme-mdrt { background: #FFFFFF !important; }
  .qual-theme-prime > .section-head,
  .qual-theme-mdrt > .section-head,
  .qual-theme-prime .qual-prime-hero-card,
  .qual-theme-mdrt .qual-crown {
    background: #FFFFFF !important;
    color: #111111 !important;
    border-color: #BBBBBB !important;
    box-shadow: none !important;
  }
  .qual-theme-prime .qual-prime-hero-card .qual-hero-num,
  .qual-theme-prime .qual-prime-hero-card .qual-hero-sub,
  .qual-theme-prime .qual-prime-hero-card .qual-hero-cap,
  .qual-theme-prime .qual-prime-hero-card .qual-prime-kicker,
  .qual-theme-prime .qual-prime-hero-card .qual-gauge-cap,
  .qual-theme-mdrt .qual-crown-num,
  .qual-theme-mdrt .qual-crown-sub { color: #111111 !important; }
  .qual-theme-prime .qual-benefits-head { margin: 0 0 12px; padding: 0; background: #FFFFFF; }
  .qual-theme-prime .qual-benefits-head h3 { color: #111111; }
}

/* ---- แชร์ผลงานเข้า LINE ---- */
.deal-share-body { display: flex; flex-direction: column; gap: 12px; }
.deal-share-tabs { align-self: flex-start; }
.deal-share-hint { margin: 0; font-size: .82rem; opacity: .75; }
.deal-share-text {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 170px;
  font: inherit; font-size: .92rem; line-height: 1.7; padding: 12px 14px;
  border: 1px solid rgba(0, 0, 0, .15); border-radius: 10px; background: #fff; color: inherit;
}
.deal-share-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.deal-share-chip {
  border: 0; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .82rem;
  font-weight: 700; cursor: pointer; background: rgba(122, 31, 31, .1); color: #7a1f1f;
}
.deal-share-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.deal-share-line {
  background: #06c755; color: #fff; text-decoration: none; font-weight: 700;
  padding: 10px 18px; border-radius: 9px; display: inline-block;
}
.deal-share-line:hover { filter: brightness(.95); }

/* ---- เกียรติบัตรยอดขาย (แบบ A · คลาสสิกทอง) ---- */
.cert-modal { max-width: 760px; }
.cert-body { display: flex; flex-direction: column; gap: 14px; }
.cert-tabs { align-self: flex-start; }
/* canvas วาดกว้าง 2400 (สูงตามสัดส่วนพื้นหลังของทีม) แล้วย่อลงด้วย CSS
   — ไฟล์ที่ดาวน์โหลดยังคมเต็มขนาด */
.cert-canvas {
  width: 100%; height: auto; display: block; border-radius: 8px;
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.cert-hint { margin: 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.cert-empty {
  margin: 0; padding: 22px 20px; text-align: center; font-size: 14px; line-height: 1.75;
  color: var(--ink-soft); background: var(--gold-tint); border-radius: 10px;
}

/* ---- "คนเก่งของเรา" — เกียรติบัตรสุ่มสลับ หน้าแรกสาธารณะ ---- */
.cert-wall-stage { max-width: 640px; margin: 0 auto; }
.cert-wall-canvas {
  width: 100%; height: auto; display: block; border-radius: 8px;
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.cert-wall-dots { display: flex; gap: 7px; justify-content: center; margin-top: 16px; }
.cert-wall-dot {
  width: 7px; height: 7px; border-radius: 999px; border: 0; padding: 0;
  background: var(--line); cursor: pointer;
}
.cert-wall-dot.on { background: var(--brand); width: 22px; border-radius: 4px; }
.cert-wall-caption { text-align: center; font-size: 13px; color: var(--ink-soft); margin: 12px 2px 0; }


/* ---- มิเตอร์ที่นั่งตามแพ็กเกจ (หน้าจัดการสมาชิก) ---- */
.seat-meter {
  display: grid; gap: .18rem; min-width: 11rem; margin-left: auto;
  border: 1px solid var(--line, #E2DCD1); border-radius: 10px; padding: .35rem .6rem;
  background: var(--paper-2, #fff);
}
.seat-meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; font-size: .8rem; }
.seat-meter-top b { font-variant-numeric: tabular-nums; }
.seat-meter-bar { height: 6px; border-radius: 99px; background: rgba(0,0,0,.08); overflow: hidden; }
.seat-meter-bar i { display: block; height: 100%; border-radius: 99px; background: #2F6B4F; transition: width .3s; }
.seat-meter.warn .seat-meter-bar i { background: #9A6212; }
.seat-meter.full .seat-meter-bar i { background: #A82F1E; }
.seat-meter-hint { font-size: .72rem; color: var(--muted, #726C62); }
.seat-meter.full .seat-meter-hint { color: #A82F1E; font-weight: 600; }
/* บรรทัดแยกว่ายอดรวมนั้นเป็นตำแหน่งอะไรบ้าง — คาดเส้นแบ่งไว้ไม่ให้อ่านปนกับยอดรวม */
.seat-meter-split {
  display: flex; flex-wrap: wrap; gap: .1rem .7rem; font-size: .72rem;
  color: var(--muted, #726C62);
  border-top: 1px solid var(--line, #E2DCD1); margin-top: .3rem; padding-top: .3rem;
}
@media (max-width: 700px) { .seat-meter { margin-left: 0; width: 100%; } }


/* ---- โลโก้ทีม: อักษรย่อ (ใช้เมื่อร้านยังไม่อัปโหลดโลโก้) ---- */
.team-logo-mono {
  display: grid; place-items: center; flex: none;
  background: var(--brand); color: #fff;
  font-family: 'Prompt', sans-serif; font-weight: 700; line-height: 1;
  border-radius: 12px; width: 56px; height: 56px; font-size: 1.6rem;
}
.login-logo.team-logo-mono { width: 64px; height: 64px; font-size: 1.9rem; margin-inline: auto; }
.brand-logo.team-logo-mono { width: 44px; height: 44px; font-size: 1.35rem; border-radius: 10px; }
.app-shell.sidebar-collapsed .brand-logo.team-logo-mono { width: 40px; height: 40px; font-size: 1.2rem; }

/* ---- หน้าตั้งค่าทีม ---- */
.brand-settings { display: grid; gap: 1rem; max-width: 40rem; }
.brand-row {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 12px; padding: 1rem;
  background: var(--paper-2, #fff);
}
.brand-row .brand-preview { width: 72px; height: 72px; border-radius: 14px; object-fit: contain;
  background: var(--soft); flex: none; }
/* .brand-copy ยังใช้ในการ์ดพื้นหลังเกียรติบัตร (.cert-bg-file) นอก .brand-row ด้วย
   ขยาย selector ให้ครอบทั้งสองที่แทนเขียนกฎซ้ำ — หน้าตาการ์ดโลโก้เดิมไม่เปลี่ยน */
.brand-row .brand-copy, .cert-bg-file .brand-copy { flex: 1; min-width: 12rem; }
.brand-row .brand-copy b, .cert-bg-file .brand-copy b { display: block; font-size: .95rem; }
/* display:block — สองบรรทัดนี้เป็นคนละประโยค ถ้าเป็น inline จะไหลต่อกันเป็นบรรทัดเดียว */
.brand-row .brand-copy span, .cert-bg-file .brand-copy span { display: block; font-size: .8rem; color: var(--muted); }
.brand-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ---- ตั้งค่าทีม: การ์ดชื่อทีม / สำนักงาน ---- */
/* ใช้โครง .brand-row เดิม (กรอบ/พื้น/อักษรย่อ 72px) แล้วเติมเฉพาะของที่การ์ดนี้มีเพิ่ม
   ปุ่มกับตัวอย่างขึ้นบรรทัดของตัวเองด้วย flex-basis 100% — ไม่แตะ .brand-row เดิม
   เพราะการ์ดโลโก้กับพื้นหลังเกียรติบัตรใช้คลาสเดียวกันอยู่ */
.team-name-card { row-gap: .85rem; }
.team-name-fields { flex: 1; min-width: 16rem; display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
@media (max-width: 640px) { .team-name-fields { grid-template-columns: 1fr; } }
.team-name-field span { display: block; font-size: .72rem; font-weight: 700; color: var(--muted); margin-bottom: .2rem; }
.team-name-field span small { font-weight: 400; }
.team-name-field .form-input { width: 100%; }

.team-name-preview {
  flex-basis: 100%; display: grid; gap: .2rem;
  border: 1px dashed var(--line); border-radius: 10px; padding: .7rem .85rem; background: var(--paper);
}
.tnp-cap { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: .25rem; }
.tnp-eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brand); }
/* ตัวอย่างต้องอ่านออกแม้ชื่อยาว — ตัดคำได้ ไม่ดันการ์ดให้กว้างเกินคอลัมน์ */
.tnp-title { font-size: 1.05rem; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.tnp-title em { font-style: italic; font-weight: 600; color: var(--green, #2F6B4F); }

.team-name-actions { flex-basis: 100%; align-items: center; }
.team-name-note { font-size: .78rem; color: var(--muted); }

.theme-settings { border: 1px solid var(--line); border-radius: 16px; padding: 18px; background: var(--card); display: grid; gap: 18px; }
.theme-settings-head, .theme-save-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.theme-settings-head b { display: block; font-size: 16px; }.theme-settings-head span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.theme-live-pill { flex: none; color: var(--green) !important; background: color-mix(in srgb, var(--green) 12%, transparent); border-radius: 99px; padding: 4px 9px; font-weight: 700; }
.theme-preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.theme-preset { min-height: 68px; display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); cursor: pointer; color: var(--ink); font: inherit; transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.theme-preset:hover { transform: translateY(-1px); border-color: var(--brand-soft); }.theme-preset.selected { border: 2px solid var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); padding: 9px; }
.theme-preset > span:last-child { display: grid; gap: 1px; }.theme-preset b { font-size: 13px; }.theme-preset small { color: var(--muted); font-size: 11px; }
.theme-swatches { display: flex; width: 48px; height: 38px; overflow: hidden; border-radius: 9px; border: 1px solid rgba(0,0,0,.08); flex: none; }.theme-swatches i { flex: 1; }
.theme-customize { border-top: 1px solid var(--line); padding-top: 15px; }.theme-customize > b { font-size: 13px; }.theme-color-fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-top: 9px; }
.theme-color-field { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 6px; min-width: 0; }.theme-color-field > span { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }.theme-color-field input { width: 28px; height: 28px; border: 0; padding: 0; border-radius: 7px; background: transparent; cursor: pointer; }.theme-color-field code { min-width: 0; color: var(--ink-soft); font-size: 10px; overflow: hidden; text-overflow: ellipsis; }
.theme-preview { display: grid; grid-template-columns: 120px 1fr; min-height: 158px; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: var(--preview-paper); }.theme-preview aside { padding: 16px 12px; display: grid; align-content: start; gap: 10px; color: #fff; background: var(--preview-sidebar); font-size: 11px; }.theme-preview aside b { font-size: 12px; }.theme-preview aside i { font-style: normal; color: rgba(255,255,255,.72); }.theme-preview-mark { display: block; width: 20px; height: 20px; transform: rotate(45deg); border-radius: 4px; background: var(--preview-brand); }.theme-preview-main { position: relative; padding: 17px; color: var(--ink); background: var(--preview-paper); font-size: 12px; }.theme-preview-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 12px; }.theme-preview-kpis b { display: grid; gap: 3px; padding: 10px; border-radius: 10px; color: var(--preview-brand); background: var(--preview-card); box-shadow: var(--shadow-sm); font-size: 20px; }.theme-preview-kpis small { color: var(--muted); font-size: 10px; font-weight: 400; }.theme-preview-main button { position: absolute; right: 17px; bottom: 16px; border: 0; border-radius: 8px; padding: 8px 11px; background: var(--preview-brand); color: #fff; font: inherit; font-size: 11px; font-weight: 700; }
.theme-save-row { border-top: 1px solid var(--line); padding-top: 14px; }.theme-save-row span { color: var(--muted); font-size: 12px; }
@media (max-width: 640px) { .theme-preset-grid { grid-template-columns: 1fr; }.theme-color-fields { grid-template-columns: repeat(2, 1fr); }.theme-save-row { align-items: stretch; flex-direction: column; }.theme-save-row .login-btn { width: 100% !important; }.theme-preview { grid-template-columns: 96px 1fr; } }

/* ---- แถบลิงก์ห้องเรียนออนไลน์ (หน้าตารางเรียน) ----
   ทำเป็นแถบเตี้ยๆ ไม่ใช่การ์ดเต็มใบ เพราะวางอยู่เหนือปุ่ม "+ เพิ่มตารางเรียน"
   ซึ่งเป็นงานหลักของหน้า — ค่านี้ตั้งครั้งเดียวแล้วแทบไม่แตะอีก ไม่ควรกินพื้นที่
   ช่องกรอก 16px กัน iOS ซูมเด้ง · ปุ่ม/ช่องสูง 44px ตามเกณฑ์ tap target */
.zoom-strip {
  border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2);
  padding: 12px 14px; display: grid; gap: 8px; margin-bottom: 14px;
}
.zoom-strip-top { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.zoom-strip-top b { font-size: 14px; }
.zoom-strip-state {
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor;
}
/* สถานะบอกด้วยข้อความด้วย ไม่ใช่สีอย่างเดียว (คนตาบอดสีต้องอ่านออก) */
.zoom-strip-state.off { color: var(--muted); background: var(--card); }
.zoom-strip-state.on { color: var(--green); background: color-mix(in srgb, var(--green) 10%, transparent); }
.zoom-strip-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.zoom-strip-row input {
  flex: 1; min-width: 220px; min-height: 44px; padding: 10px 12px;
  font: inherit; font-size: 16px; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.zoom-strip-row input:disabled { opacity: .55; cursor: not-allowed; }
.zoom-strip-hint { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.zoom-strip-hint code { font-size: 11.5px; background: var(--card); border-radius: 4px; padding: 0 4px; }
@media (max-width: 560px) {
  .zoom-strip-row { align-items: stretch; }
  .zoom-strip-row input { min-width: 0; flex-basis: 100%; }
}

/* ---- การ์ดบัญชีรับเงินค่าสมาชิก (หน้าตั้งค่าทีม) ----
   เข้าชุดกับ .cert-bg-settings — กล่องเดียวกัน แค่เนื้อในเป็นฟอร์มข้อความ
   ช่องกรอกใช้ font-size 16px กัน iOS ซูมเด้งตอนแตะ และ min-height 44px ตามเกณฑ์ tap target */
.ops-card { border: 1px solid var(--line); border-radius: 16px; padding: 18px; background: var(--card); display: grid; gap: 16px; }
.ops-field { display: grid; gap: 6px; }
.ops-field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.ops-field input {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; font-size: 16px;
  color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
}
.ops-field input:disabled { opacity: .55; cursor: not-allowed; }
.ops-hint { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.ops-hint code { font-size: 11.5px; background: var(--paper-2); border-radius: 4px; padding: 0 4px; }
.ops-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .ops-grid2 { grid-template-columns: 1fr; } }

/* ---- การ์ดพื้นหลังเกียรติบัตร (หน้าตั้งค่าทีม) — เข้าชุดกับ .theme-settings ---- */
.cert-bg-settings { border: 1px solid var(--line); border-radius: 16px; padding: 18px; background: var(--card); display: grid; gap: 18px; }
.cert-bg-file { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
/* กล่องเตือนความกว้างรูป — โทนทองอ่อน ตัวหนังสือทองเข้ม อ่านออกแม้บนพื้น --card */
.cert-bg-warn {
  margin: 0; padding: 10px 14px; border-radius: 10px;
  background: var(--gold-tint); color: var(--gold-strong); font-size: 12.5px; line-height: 1.6;
}
.cert-bg-controls { display: grid; gap: 12px; }
/* สองคอลัมน์: ป้ายซ้าย (ยืด) + ตัวควบคุมขวา (ชิดขวา ความกว้างเท่าเนื้อหา) */
.cert-bg-ctrl { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; justify-items: end; }
.cert-bg-ctrl > span:first-child { justify-self: start; display: grid; gap: 2px; }
.cert-bg-ctrl > span:first-child b { display: block; font-size: 13px; }
.cert-bg-ctrl > span:first-child small { display: block; color: var(--muted); font-size: 11.5px; }
.cert-bg-slider { display: flex; align-items: center; gap: 10px; }
.cert-bg-slider input[type="range"] { width: 130px; accent-color: var(--brand-strong); }
/* min-width คงที่ + tabular-nums กันตัวเลขดันเลย์เอาต์ตอนค่าเปลี่ยนจาก 15% เป็น 100% */
.cert-bg-slider code {
  min-width: 3.4em; text-align: right; font-variant-numeric: tabular-nums;
  color: var(--ink-soft); font-size: 12.5px;
}
/* canvas วาดที่ขนาดจริง กว้าง 2400 สูงตามสัดส่วนรูปที่ทีมอัปโหลด (ไม่ตายตัว)
   — ย่อด้วย CSS เหมือน .cert-canvas/.cert-wall-canvas ไม่งั้นล้นจอ */
.cert-bg-preview {
  width: 100%; height: auto; display: block; border-radius: 8px;
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
@media (max-width: 640px) {
  /* พอยุบเหลือคอลัมน์เดียว ต้องล้าง justify-items: end ของกฎหลักด้วย
     ไม่งั้นตัวควบคุมจะไปชิดขวาขณะที่ป้ายอยู่ซ้าย = ดูเหมือนคนละแถว */
  .cert-bg-ctrl { grid-template-columns: 1fr; gap: 6px; justify-items: start; }
  .cert-bg-slider { justify-self: stretch; }
  .cert-bg-slider input[type="range"] { width: auto; flex: 1; }
}

/* ---- การ์ดแพ็กเกจ (บนสุดของหน้าตั้งค่าทีม) ---- */
.plan-card {
  display: grid; gap: .85rem;
  border: 1px solid var(--line); border-radius: 12px; padding: 1rem;
  background: var(--paper-2, #fff);
}
.plan-top { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.plan-name { font-size: 1.05rem; }
.plan-price { margin-left: auto; font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.plan-price small { font-size: .78rem; font-weight: 400; color: var(--muted); }
.plan-pill { font-size: .72rem; font-weight: 700; padding: .12rem .5rem; border-radius: 99px; white-space: nowrap; }
.plan-pill.ok   { background: #E6F0E9; color: #2F6B4F; }
.plan-pill.warn { background: #FBF0D8; color: #9A6212; }
.plan-pill.bad  { background: #FBE9E5; color: #A82F1E; }
/* การ์ดนี้ใช้ .seat-meter ตัวเดียวกับแถบในหน้าสมาชิก — ในการ์ดต้องเต็มความกว้าง ไม่ลอยขวา */
.plan-card .seat-meter { margin: 0; width: 100%; max-width: none; }
.plan-foot {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: .8rem;
}
.plan-when { flex: 1; min-width: 12rem; font-size: .78rem; color: var(--muted); }
.plan-foot .login-btn, .plan-foot .btn-edit { width: auto; text-decoration: none; text-align: center; }

/* ============================================================================
   โมดัลรายละเอียดดีล บนจอแคบ → bottom sheet
   วางท้ายไฟล์เพื่อให้ชนะกฎฐาน (.modal-box / .modal-body) อย่างชัดเจน ไม่ต้องพึ่ง !important
   ครอบเฉพาะ .sales-detail — โมดัลอื่นในระบบไม่ถูกแตะ
   ขนาด tap target ยังมาจาก @media (pointer: coarse) ที่มีอยู่แล้ว ไม่ทำซ้ำที่นี่
   ============================================================================ */
@media (max-width: 560px) {
  /* กันขอบซ้าย-ขวาออกให้เต็มความกว้าง (ได้พื้นที่คืนราว 40px) แต่คงระยะปลอดภัยด้านบน */
  .modal-backdrop:has(.sales-detail) {
    padding: max(20px, env(safe-area-inset-top)) 0 0 0;
    align-items: flex-end;
  }
  .sales-detail {
    max-width: none;
    width: 100%;
    border-radius: 18px 18px 0 0;
    max-height: 92dvh;
  }
  /* หัวเรื่องติดบนตอนเลื่อนเนื้อหา — ดีลที่ปิดแล้วมีเนื้อหายาว เลื่อนแล้วยังรู้ว่าดูดีลใคร */
  .sales-detail .modal-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--card);
    padding: 14px 16px 11px;
  }
  .sales-detail .modal-body {
    padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  }
  /* ขีดจับด้านบนแบบ sheet — บอกใบ้ว่าปัดปิดได้ (decorative) */
  .sales-detail .modal-head::before {
    content: "";
    position: absolute;
    top: 6px; left: 50%;
    transform: translateX(-50%);
    width: 36px; height: 4px;
    border-radius: 99px;
    background: var(--line);
  }
  .sales-detail .modal-head { padding-top: 18px; }
}

/* จอที่เตี้ยมาก (มือถือแนวนอน) — อย่าให้ sheet กินทั้งจอจนกดปิดไม่ได้ */
@media (max-width: 560px) and (max-height: 480px) {
  .sales-detail { max-height: 96dvh; }
  .sales-detail .modal-head::before { display: none; }
}

/* จอกว้าง: ปุ่ม "ขั้นถัดไป" เรียงข้างกันขนาดพอดีเนื้อหา
   ปุ่มเต็มความกว้างเป็นเรื่องของนิ้วโป้งบนมือถือ บนเดสก์ท็อปปุ่มกว้าง 550px ดูหนักเกินจำเป็น */
@media (min-width: 561px) {
  .deal-next { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .deal-next-label { width: 100%; }
  .deal-next-btn { width: auto; min-width: 148px; padding: 11px 22px; }
  .deal-next-btn.is-ghost { min-width: 0; }
}

/* ---- ปุ่มอัปเกรดใต้มิเตอร์ที่นั่ง + แผ่นยืนยัน ---- */
.seat-meter-cta {
  margin-top: .5rem;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: .85rem;
  padding: .45rem .9rem;
  cursor: pointer;
}
.seat-meter-cta:hover { filter: brightness(1.08); }

.plan-sheet-overlay {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  background: rgba(15,26,46,0.62); padding: 1.25rem;
}
.plan-sheet {
  background: var(--card); color: var(--ink);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 1.25rem;
  width: min(26rem, 100%);
  display: flex; flex-direction: column; gap: .7rem;
  max-height: 90vh; overflow-y: auto;
}
.plan-sheet h3 { margin: 0; font-size: 1.05rem; }
.plan-sheet-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  border: 1px solid var(--line); border-radius: 10px; padding: .65rem .8rem;
}
.plan-sheet-row div { display: flex; flex-direction: column; }
.plan-sheet-row span { font-size: .8rem; opacity: .7; }
.plan-sheet-row button {
  border: 0; border-radius: 8px; background: var(--brand); color: #fff;
  font: inherit; font-weight: 700; font-size: .82rem; padding: .4rem .85rem;
  cursor: pointer; white-space: nowrap;
}
.plan-sheet-row button:disabled { opacity: .55; cursor: default; }
.plan-sheet-note { margin: 0; font-size: .82rem; opacity: .72; line-height: 1.55; }
.plan-sheet-err { opacity: 1; color: var(--red); }
.plan-sheet-close {
  align-self: flex-end; border: 0; background: none; font: inherit;
  font-size: .85rem; opacity: .6; cursor: pointer; padding: .2rem .4rem;
}

/* ============================================================================
   ตัวช่วยตั้งค่าครั้งแรก (First-run setup) + เช็กลิสต์ตั้งค่าทีม
   ดีไซน์: docs/superpowers/specs/2026-08-10-first-run-setup-design.md
   ตัวช่วยกั้นเต็มหน้าแทนหลังบ้านทั้งหมด จึงต้องมีพื้นหลังของตัวเอง ไม่ได้อยู่ใน .app
   ใช้โทเคนเดิมทั้งหมด (--brand/--paper/--card/--line/--ink/--muted) ไม่ตั้งสีใหม่
   วางท้ายไฟล์และตั้งชื่อคลาสขึ้นต้น .frs- / .setup-check- เพื่อไม่ไปทับของเดิมสักตัว
   ============================================================================ */
.frs-screen {
  min-height: 100vh; min-height: 100dvh;
  background: var(--paper); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  padding: clamp(1rem, 4vw, 2.5rem);
}
.frs-card {
  width: min(30rem, 100%);
  background: var(--card);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: clamp(1.25rem, 4vw, 1.75rem);
}
.frs-eyebrow {
  margin: 0 0 1rem; font-size: .72rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}

/* จุดบอกขั้น 3 จุด — ผ่านแล้วเป็นเครื่องหมายถูกสีเขียว ขั้นที่อยู่คือสีแบรนด์ */
.frs-steps { display: flex; align-items: center; gap: .4rem; }
.frs-dot {
  width: 1.65rem; height: 1.65rem; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  border: 1.5px solid var(--line); background: var(--card);
  font-size: .78rem; font-weight: 700; color: var(--muted);
}
.frs-dot.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.frs-dot.ok { background: var(--green); border-color: var(--green); color: #fff; }
.frs-line { flex: 1; height: 2px; background: var(--line); }

.frs-title { margin: 1.1rem 0 0; font-size: 1.32rem; line-height: 1.35; }
.frs-sub   { margin: .35rem 0 0; font-size: .88rem; color: var(--muted); line-height: 1.6; }

.frs-fields { display: grid; gap: .5rem; margin-top: 1.1rem; }
.frs-have   { margin: 0 0 .1rem; font-size: .8rem; color: var(--muted); }
/* เส้นประคั่นเฉพาะคนที่สองเป็นต้นไป — คนเดียวไม่ต้องมีเส้นให้รก */
.frs-person { display: grid; gap: .4rem; }
.frs-person + .frs-person { border-top: 1px dashed var(--line); padding-top: .55rem; }
.frs-person-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.frs-person-row .form-input { flex: 1; min-width: 8rem; }
.frs-person-row .frs-code { flex: none; width: 7.5rem; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.frs-remove {
  flex: none; width: 2.2rem; border: 1px solid var(--line); border-radius: 8px;
  background: none; color: var(--muted); font: inherit; font-size: .8rem; cursor: pointer;
}
.frs-remove:hover { color: var(--red); border-color: var(--red); }
.frs-add {
  border: 1px dashed var(--brand); border-radius: 9px;
  background: none; color: var(--brand); font: inherit; font-size: .85rem; font-weight: 600;
  padding: .5rem .75rem; cursor: pointer; text-align: left;
}
.frs-add:hover { background: color-mix(in srgb, var(--brand) 7%, transparent); }

/* ปุ่มหลักอยู่ซ้ายล่าง มี "ขั้นที่ N จาก 3" ต่อข้างๆ ส่วน "ข้ามก่อน" ถูกดันไปขวาสุดให้เบาที่สุด */
.frs-foot { display: flex; align-items: center; gap: .75rem; margin-top: 1.15rem; }
.frs-next {
  border: 0; border-radius: 9px; background: var(--brand-strong); color: #fff;
  font: inherit; font-weight: 700; font-size: .9rem; padding: .6rem 1.4rem; cursor: pointer;
}
.frs-next:hover:not(:disabled) { filter: brightness(1.08); }
.frs-next:disabled { opacity: .6; cursor: default; }
.frs-hint { font-size: .8rem; color: var(--muted); }
.frs-skip {
  margin-left: auto; border: 0; background: none; color: var(--muted);
  font: inherit; font-size: .82rem; text-decoration: underline; cursor: pointer; padding: .2rem;
}
.frs-skip:hover:not(:disabled) { color: var(--ink); }
.frs-note {
  margin: 1rem 0 0; border-top: 1px solid var(--line); padding-top: .85rem;
  font-size: .8rem; color: var(--muted); line-height: 1.65;
}
.frs-card .form-error { margin-top: .8rem; }

@media (max-width: 480px) {
  .frs-person-row .frs-code { width: 100%; }
  .frs-foot { flex-wrap: wrap; }
  .frs-skip { margin-left: auto; }
}

/* ---- การ์ดเช็กลิสต์บนสุดของ "สรุปผลทีม" — ครบสี่ข้อแล้วคอมโพเนนต์ถอดตัวเองออก ---- */
.setup-check {
  display: grid; gap: .6rem;
  border: 1px solid var(--brand); border-radius: 12px;
  background: color-mix(in srgb, var(--brand) 7%, var(--card));
  padding: .9rem 1rem; margin-bottom: 1rem;
}
.setup-check-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.setup-check-head b    { font-size: .98rem; }
.setup-check-head span { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.setup-check-bar {
  height: 5px; border-radius: 3px; overflow: hidden;
  background: color-mix(in srgb, var(--muted) 24%, transparent);
}
.setup-check-bar i { display: block; height: 100%; background: var(--brand); transition: width .3s ease; }
.setup-check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.setup-check-list li { display: flex; align-items: center; gap: .5rem; font-size: .87rem; }
.setup-check-box {
  flex: none; width: .95rem; height: .95rem; border-radius: 4px;
  border: 1.5px solid var(--muted); display: grid; place-items: center;
  font-size: .6rem; line-height: 1; color: #fff;
}
.setup-check-list li.done .setup-check-box { background: var(--green); border-color: var(--green); }
.setup-check-list li.done .setup-check-label { color: var(--muted); text-decoration: line-through; }
.setup-check-where { margin-left: auto; font-size: .76rem; color: var(--muted); white-space: nowrap; }

@media (max-width: 480px) {
  .setup-check-where { display: none; }
}

/* ============================================================================
   สวิตช์เปิด/ปิดฟีเจอร์รายทีม (หน้า "ตั้งค่าทีม")
   ดีไซน์: docs/superpowers/specs/2026-08-10-feature-switches-design.md
   ไฟล์นี้ไม่เคยมีกฎสวิตช์มาก่อน (ไม่มี :checked สักข้อ) จึงเขียนคอนโทรลขึ้นใหม่ทั้งตัว
   ตัวสวิตช์เป็น <button role="switch"> จริง สถานะจึงอ่านจาก [aria-checked] ไม่ใช่ :checked
   ใช้โทเคนเดิมล้วน (--brand/--paper-2/--line/--card/--muted) ไม่ตั้งสีใหม่
   ============================================================================ */
.feat-settings {
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--card); overflow: hidden;
}
.feat-head { padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.feat-head b    { display: block; font-size: 16px; }
.feat-head span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; line-height: 1.6; }

.feat-group {
  padding: 12px 18px 6px; background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
}

.feat-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; align-items: center;
  padding: 13px 18px; border-bottom: 1px solid var(--line);
}
.feat-text b    { display: block; font-size: 15px; font-weight: 600; }
.feat-text span { display: block; font-size: 13px; color: var(--muted); line-height: 1.55; }
/* แถวที่ถูกฟีเจอร์แม่ลากปิด — จางลงเพื่อบอกว่ากดไม่ได้ตอนนี้ ไม่ใช่ตัวเลือกที่แอดมินตั้งเอง */
.feat-row.forced .feat-text b, .feat-row.forced .feat-text span { opacity: .5; }

.feat-note {
  grid-column: 1 / -1; font-size: 12.5px; line-height: 1.6;
  border-radius: 7px; padding: 7px 10px;
}
.feat-note.warn { background: var(--gold-tint); color: var(--ink); }
.feat-note.stop { background: color-mix(in srgb, var(--brand) 12%, var(--card)); color: var(--brand-strong); }

.feat-lock {
  font-size: 11.5px; font-weight: 700; color: var(--muted);
  background: var(--paper-2); border-radius: 999px; padding: 4px 11px; white-space: nowrap;
}

/* ---- ตัวสวิตช์: ราง 42×24 ลูกบิด 18 เลื่อน 18 ---- */
.feat-toggle {
  position: relative; flex: none; width: 42px; height: 24px; padding: 0;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper-2); cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}
.feat-toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(36, 34, 32, .28);
  transition: transform .16s ease;
}
.feat-toggle[aria-checked="true"] { background: var(--brand); border-color: var(--brand); }
.feat-toggle[aria-checked="true"]::after { transform: translateX(18px); }
.feat-toggle:disabled { cursor: not-allowed; opacity: .45; }
.feat-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* แถวบันทึกใช้ .theme-save-row ร่วมกับส่วนธีม — คืนเส้นคั่นบน/ระยะห่างให้เท่ากันในกล่องนี้ */
.feat-settings .theme-save-row { padding: 14px 18px; border-top: 0; background: var(--paper-2); }

@media (prefers-reduced-motion: reduce) {
  .feat-toggle, .feat-toggle::after { transition: none; }
}

/* ==== "ขอความช่วยเหลือ" — การ์ดช่องทางติดต่อ (components.jsx → HelpContactCard) ====
   ใช้ร่วมกันทั้งหน้า Admin (HelpPanel) และหน้าตัวแทน (HelpTab)
   เดิมการ์ดนี้เขียน inline อ้าง var(--panel)/var(--border) ซึ่งไม่มีประกาศไว้ที่ไหนเลย
   เลยตกไปใช้ค่าสำรอง #fff/#e5e7eb ตลอด = ไม่เปลี่ยนตามธีมของทีม ตอนนี้ผูกกับ token จริงแล้ว */
.help-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  text-align: center;
}
.help-card-intro { margin: 0 0 20px; font-size: 15px; line-height: 1.6; }
.help-card-label { margin: 0 0 10px; font-size: 14px; color: var(--muted); }

/* เส้นคั่น "ช่องทางอื่น" — ขีดสองข้างยืดกินพื้นที่ที่เหลือเอง ไม่ต้องกำหนดความกว้าง */
.help-chan-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 0 14px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em;
  color: var(--muted);
}
.help-chan-divider::before, .help-chan-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line-2);
}

/* แถวช่องทาง — ชิดซ้ายสวนกับ text-align:center ของการ์ด เพราะเป็นรายการ ไม่ใช่ข้อความ */
.help-chan-list { display: flex; flex-direction: column; gap: 8px; text-align: left; }

.help-chan {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: inherit; text-decoration: none;
  transition: border-color .15s ease, background .15s ease;
}
.help-chan:hover { border-color: var(--brand); background: var(--paper-2); }
.help-chan:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.help-chan-icon {
  flex: none; width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; background: var(--paper-2);
}
.help-chan-text { display: flex; flex-direction: column; min-width: 0; }
.help-chan-text b { font-size: 14px; font-weight: 600; }
/* URL ยาวกว่าการ์ดบนจอแคบ — ตัดด้วย … แทนที่จะดันแถวจนล้น (min-width:0 ข้างบนคือตัวปลดล็อกให้ตัดได้) */
.help-chan-text span {
  font-size: 12.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.help-chan-arrow { margin-left: auto; flex: none; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .help-chan { transition: none; }
}

/* ==== นามบัตรออนไลน์ (card.html) ==== */
/* หน้านี้เปิดบนมือถือของลูกค้าเป็นหลัก จึงคุมความกว้างไว้ที่ขนาดบัตรใบเดียว
   แทนที่จะใช้ layout ของแอปซึ่งมีแถบข้าง */
.card-page { min-height: 100dvh; background: var(--paper); padding: 18px 14px 40px;
  display: flex; justify-content: center; align-items: flex-start; }
.card-page-plain { align-items: center; color: var(--muted); }
.card-sheet { width: 100%; max-width: 420px; background: var(--card);
  border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-lg); }

.card-hero { background: var(--sidebar); color: #F5F1E8; padding: 20px 18px 17px;
  position: relative; }
.card-hero::after { content: ""; position: absolute; inset: auto 0 0 0; height: 2px;
  background: linear-gradient(90deg, var(--card-brand, var(--brand)), var(--gold)); }
.card-team { position: absolute; top: 14px; right: 15px; font-size: 11px;
  letter-spacing: .08em; color: var(--gold);
  border: 1px solid rgba(231,200,120,.4); border-radius: 999px; padding: 1px 9px; }
.card-who { display: flex; gap: 13px; align-items: center; }
.card-photo { width: 62px; height: 62px; border-radius: 50%; flex: none;
  object-fit: cover; border: 2px solid rgba(231,200,120,.55); }
.card-photo-blank { display: grid; place-items: center; font-size: 21px; font-weight: 700;
  background: var(--card-brand, var(--brand)); color: #FFF3E6; }
.card-name { font-size: 19px; font-weight: 700; line-height: 1.3; }
.card-title { font-size: 13px; color: var(--muted-on-dark); }
.card-unit { font-size: 12px; color: var(--muted-on-dark); opacity: .8; }

.card-body { padding: 15px 15px 18px; display: grid; gap: 12px; }
.card-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.card-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--gold-tint); color: var(--gold-strong); border: 1px solid var(--gold-soft); }
.card-badge.green { background: #E7F0E9; color: var(--green); border-color: #C6DCCC; }
.card-bio { margin: 0; font-size: 13.5px; color: var(--ink-soft); line-height: 1.6; }

.card-quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.card-quick-item { text-align: center; font-size: 12px; font-weight: 600; padding: 9px 0 8px;
  border-radius: 10px; background: var(--card); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; }
.card-quick-glyph { display: block; font-size: 15px; color: var(--card-brand, var(--brand)); }

.card-btn { display: block; width: 100%; text-align: center; padding: 11px;
  border-radius: 10px; font-weight: 700; font-size: 14px; border: 0; cursor: pointer;
  font-family: inherit; text-decoration: none; }
.card-btn-solid { background: var(--card-brand, var(--brand)); color: #FFF6F0; }
.card-btn-dark { background: var(--sidebar); color: #F5F1E8; }
.card-btn-ghost { background: var(--card); border: 1.5px solid var(--line); color: var(--ink); }
.card-btn:disabled { opacity: .6; cursor: default; }

.card-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.card-tab { font-size: 13px; font-weight: 700; padding: 9px 4px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--muted);
  cursor: pointer; font-family: inherit; }
.card-tab.on { border-color: var(--card-brand, var(--brand));
  color: var(--card-brand, var(--brand)); background: var(--brand-tint, #FBF0EC); }

.card-form { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px; display: grid; gap: 9px; }
.card-form-done { text-align: center; display: grid; gap: 3px; color: var(--green); }
.card-form-title { font-size: 13.5px; font-weight: 700; }
.card-input { width: 100%; padding: 9px 11px; border-radius: 8px; font-size: 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-family: inherit; }
.card-textarea { resize: vertical; }
/* ช่องล่อบอต — ต้องอยู่ใน DOM แต่คนต้องไม่เห็นและ tab ไม่ถึง
   ใช้ display:none ไม่ใช่ดันออกนอกจอ: ตัวกรอกฟอร์มอัตโนมัติของเบราว์เซอร์และ
   password manager ยังกรอกช่องที่อยู่นอกจอให้ ลูกค้าจริงจึงถูกกลืนเงียบๆ ได้
   ยอมให้บอตที่ข้ามช่อง display:none หลุดเข้ามาบ้าง เพราะด่านจริงคือเพดานต่อ IP */
.card-hp { display: none; }
.card-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 11.5px;
  color: var(--muted); line-height: 1.5; }
.card-error { font-size: 12.5px; color: var(--red); }
.card-foot { display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 11px; color: var(--muted); padding-top: 4px; }
.card-foot-logo { height: 16px; width: auto; opacity: .8; }
.card-missing { text-align: center; display: grid; gap: 14px; }

/* ธีมบัตรสามแบบ — จำกัดไว้สามชุดเพื่อให้บัตรทุกใบยังดูเป็นทีมเดียวกัน */
.card-theme-dark .card-sheet { background: var(--sidebar); color: #F0EBE0; }
.card-theme-dark .card-body { background: var(--sidebar); }
.card-theme-dark .card-quick-item,
.card-theme-dark .card-input,
.card-theme-dark .card-form { background: var(--sidebar-strong); border-color: #3A362F;
  color: #F0EBE0; }
.card-theme-dark .card-bio { color: var(--muted-on-dark); }
.card-theme-light .card-hero { background: var(--paper-2); color: var(--ink); }
.card-theme-light .card-title,
.card-theme-light .card-unit { color: var(--muted); }

/* ==== หน้าแก้ไขนามบัตร + กล่องคำขอ (login.html) ==== */
.card-editor { display: grid; gap: 13px; max-width: 560px; }
.card-switch { display: flex; align-items: center; gap: 12px; padding: 13px 15px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.card-switch-title { font-weight: 700; font-size: 14px; }
.card-switch-state { font-size: 12px; color: var(--muted); }
.card-switch-state.on { color: var(--green); }
.card-switch-knob { margin-left: auto; }
.card-linkrow { display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; }
.card-linkrow code { font-size: 12px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.card-qr-box { display: flex; align-items: center; gap: 14px; padding: 13px 15px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.card-qr-img { width: 96px; height: 96px; flex: none; image-rendering: pixelated; }
.card-qr-side { display: grid; gap: 8px; font-size: 12.5px; color: var(--muted); }
.card-fields { display: grid; gap: 11px; }
.card-fields label { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); }
.card-count { font-size: 11px; color: var(--muted); justify-self: end; }
.card-fields-label { font-size: 12.5px; color: var(--muted); }
.card-theme-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px;
  margin-top: 5px; }
.card-theme-btn { padding: 8px; border-radius: 9px; font-size: 13px; font-family: inherit;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  cursor: pointer; }
.card-theme-btn.on { border-color: var(--brand); color: var(--brand); }

/* ตัวแก้ไขป้าย — โผล่เฉพาะบัตรที่เจ้าของพิมพ์ป้ายเอง (ผู้จัดการ) */
.card-badge-edit { display: grid; gap: 8px; }
.card-badge-edit em { font-style: normal; font-variant-numeric: tabular-nums; }
.card-badge-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.card-badge-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px;
  font-weight: 700; padding: 4px 5px 4px 11px; border-radius: 999px;
  background: var(--gold-tint); color: var(--gold-strong); border: 1px solid var(--gold-soft); }
.card-badge-chip.green { background: #E7F0E9; color: var(--green); border-color: #C6DCCC; }
.card-badge-x { border: 0; background: none; font-size: 15px; line-height: 1; cursor: pointer;
  color: inherit; opacity: .65; padding: 0 4px; font-family: inherit; }
.card-badge-x:hover { opacity: 1; }
.card-badge-add { display: flex; align-items: center; gap: 7px; }
.card-badge-add .card-input { flex: 1; min-width: 0; }
.card-badge-tones { display: flex; gap: 5px; flex: none; }
.card-badge-tone { width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px var(--line); }
.card-badge-tone.gold { background: var(--gold); }
.card-badge-tone.green { background: #E7F0E9; }
.card-badge-tone.on { border-color: var(--ink); }
.card-badge-hint { font-size: 11.5px; color: var(--muted); }

.lead-inbox { display: grid; gap: 11px; max-width: 560px; margin-top: 26px; }
.lead-inbox-head { display: flex; align-items: center; gap: 9px; font-size: 15px; }
.lead-pill { font-size: 11.5px; font-weight: 700; background: var(--brand); color: #FFF6F0;
  border-radius: 999px; padding: 2px 9px; }
.lead-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; display: grid; gap: 8px; }
.lead-card.is-new { border-color: var(--brand); }
.lead-card.is-done { opacity: .65; }
.lead-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.lead-name { font-weight: 700; font-size: 14px; }
.lead-kind { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.lead-kind.customer { background: var(--brand-tint, #FBF0EC); color: var(--brand-strong); }
.lead-kind.recruit { background: #E7F0E9; color: var(--green); }
.lead-when { margin-left: auto; font-size: 11px; color: var(--muted); }
.lead-line { font-size: 13px; color: var(--ink-soft); }
.lead-note { font-size: 12.5px; color: var(--muted); }
.lead-acts { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.lead-blocked, .lead-done-note { font-size: 12px; color: var(--muted); }
.lead-done-group summary { font-size: 13px; color: var(--muted); cursor: pointer;
  padding: 6px 0; }
.card-state { font-size: 12px; color: var(--muted); }
.card-state.on { color: var(--green); font-weight: 600; }

/* ==== แท็บนามบัตรฝั่งแอดมิน (admin.html) ==== */
.card-admin { display: grid; gap: 13px; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td { text-align: left; padding: 9px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table th { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ==== คลังเอกสาร "โหลดเอกสาร" (frontend/shared/documents.jsx) ==== */
.doc-head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.doc-search {
  flex: 1 1 240px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}
.doc-newfolder, .doc-upload {
  flex: none;
  border: 1px solid var(--brand);
  border-radius: 9px;
  padding: 9px 14px;
  background: var(--brand-strong);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.doc-newfolder:hover, .doc-upload:hover { opacity: 0.9; }
.doc-newfolder:disabled, .doc-upload:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- กริดโฟลเดอร์ ---- */
.doc-folders {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.doc-folder {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}
.doc-folder-open {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 15px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.doc-folder-open:hover { background: var(--paper-2); }
.doc-folder-open span {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.doc-folder-tools {
  display: flex;
  gap: 14px;
  padding: 8px 15px 12px;
  border-top: 1px solid var(--line-2);
}
.doc-folder-tools .link-btn:disabled { opacity: 0.5; cursor: not-allowed; text-decoration: none; }
.doc-folder-del { color: var(--red); }
/* ปุ่มในการ์ดที่ overflow: hidden (มุมโค้ง) ทำให้ outline โฟกัสปกติ (offset +2px)
   โดนตัดที่ขอบการ์ด — ดึง outline เข้ามาด้านในแทนเฉพาะปุ่มที่อยู่ในการ์ดนี้ */
.doc-folder-open:focus-visible,
.doc-folder-tools .link-btn:focus-visible {
  outline-offset: -2px;
}

/* ---- เปิดโฟลเดอร์ ---- */
.doc-crumb {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.doc-crumb-name { font-size: 16px; }
.doc-crumb .doc-upload { margin-left: auto; }

/* ---- แถวไฟล์ (ใช้ทั้งในโฟลเดอร์และผลค้นหา) ---- */
.doc-rows { display: flex; flex-direction: column; gap: 8px; }
.doc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--card);
}
.doc-ft {
  flex: none;
  min-width: 42px;
  padding: 4px 6px;
  border-radius: 5px;
  background: var(--paper-2);
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}
/* pdf/xls(x)/ppt(x) ได้สีเฉพาะตามโทนที่มีอยู่แล้วใน :root — ส่วน doc/docx (Word),
   jpg/jpeg/png (รูปภาพ — mockup ที่อนุมัติไว้ใช้ชิปฟ้าสำหรับรูป) และ zip เลยตกไปใช้
   ชิปสีกลางของ .doc-ft ด้านบนต่อไปทั้งหมด ไม่ใช่ตกหล่น: โทนของระบบนี้มีแค่
   ember/gold/green/red (ดู :root บรรทัด 1-60) ไม่มีโทนฟ้าให้ใช้เลยทั้งไฟล์ จะเติม
   ต้องเพิ่ม token ใหม่ซึ่งเกินขอบเขตงานนี้ */
.doc-ft-pdf { background: var(--brand-tint); color: var(--brand-strong); }
.doc-ft-xls, .doc-ft-xlsx { background: color-mix(in srgb, var(--green) 14%, var(--card)); color: var(--green); }
.doc-ft-ppt, .doc-ft-pptx { background: var(--gold-tint); color: var(--gold-strong); }
.doc-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.doc-in { margin-left: 6px; font-weight: 400; color: var(--muted); }
.doc-meta {
  flex: none;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.doc-dl {
  flex: none;
  border: 1px solid var(--brand);
  border-radius: 7px;
  padding: 5px 11px;
  background: var(--brand-tint);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.doc-dl:hover { opacity: 0.85; }
.doc-del {
  flex: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 10px;
  background: var(--card);
  color: var(--red);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.doc-del:hover { background: var(--paper-2); }
.doc-del:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- ว่าง / กำลังโหลด / ลองใหม่ ---- */
.doc-empty {
  padding: 32px 16px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
}
.doc-loading { font-style: italic; }
.doc-retry { margin-top: 12px; }

/* เมื่อก่อนตรงนี้เคยเติม padding ซ้าย-ขวาให้ลูกของ .admin-panel ทีละตัว (.doc-head,
   .doc-crumb, ...) เพราะเปลือกไม่มีระยะขอบของตัวเอง ตอนนี้ .admin-panel ถือระยะขอบเอง
   แล้ว (ดูกฎของมันด้านบนไฟล์นี้) จึงลบทิ้งได้ทั้งบล็อก — และห้ามเติมกลับมา ไม่งั้นซ้อนกัน
   เป็น 80px ส่วนฝั่งตัวแทนใช้ section.scene ซึ่งให้ระยะขอบเต็มอยู่แล้วเหมือนกัน */

@media (max-width: 560px) {
  .doc-folders { grid-template-columns: 1fr 1fr; }
  .doc-size, .doc-when { display: none; }
  .doc-meta { gap: 8px; }
}

/* ---- ผังองค์กร ---- */
/* ระยะขอบของ .oc-wrap อยู่รวมกับ section.scene / .admin-panel ที่ต้นไฟล์ ไม่ใช่ตรงนี้
   (แผงนี้เป็นลูกตรงของ .main ซึ่ง padding: 0 ทั้ง admin-app และ login-app) */

.oc-canvas { overflow-x: auto; padding: .5rem 0 1rem; }
.oc-canvas svg { display: block; height: auto; max-width: 100%; }
.oc-edge { fill: none; stroke: var(--line); stroke-width: 1.4; }
/* การ์ดสีทราย ไม่มีขอบ — ต่อยอดจาก --paper-2 ของระบบให้เข้มพอแยกตัวจากพื้น
   (ผสมกับ --brand เล็กน้อยแทนการตั้งค่า hex ใหม่ลอยๆ ทีมสีจะได้ขยับตามธีมร้าน) */
.oc-box { fill: color-mix(in srgb, var(--paper-2) 82%, var(--brand)); stroke: none; }
/* ผจก. = ยอดของหน่วย ต้องแยกออกจากลูกทีมได้ในพริบตา ผังชั้นเดียวมีหลายสายพร้อมกัน */
.oc-box--manager { stroke: var(--brand); stroke-width: 1.6; }
.oc-name { font-size: 12.5px; font-weight: 700; fill: var(--ink); }
.oc-meta { font-size: 9.5px; fill: var(--muted); letter-spacing: .03em; }
/* วงแหวนขาวคั่นรูปออกจากเส้นที่วิ่งมาจบข้างหลัง — ใช้ --card เพื่อให้เท่าพื้นการ์ดของแอป */
.oc-ring { fill: var(--card); }
.oc-face { fill: color-mix(in srgb, var(--brand) 42%, var(--paper-2)); }
.oc-initial { font-size: 17px; font-weight: 700; fill: var(--card); }
.oc-node.is-dim { opacity: .3; }
.oc-empty, .oc-tray-empty { color: var(--muted); font-size: .9rem; padding: 1rem 0; }
.oc-tray { border-top: 1px solid var(--line); padding-top: .9rem; margin-top: .5rem; }
.oc-tray-title { margin: 0 0 .5rem; font-size: .85rem; font-weight: 700; }
.oc-tray-list { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; margin: 0; padding: 0; }
.oc-chip {
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: .3rem .7rem; font-size: .82rem;
}
/* touch-action: none กันหน้าเลื่อนตามนิ้วตอนลาก — แต่ต้องมีเฉพาะตอนลากได้จริง
   ถ้าใส่ไว้ตลอด ฝั่งตัวแทน (canEdit=false) จะเลื่อนดูผังบนมือถือไม่ได้เลย
   ทั้งที่ลากอะไรไม่ได้อยู่แล้ว → ผูกกับคลาส is-editable ที่ใส่เฉพาะตอน canEdit */
.oc-wrap.is-editable .oc-node,
.oc-wrap.is-editable .oc-chip { touch-action: none; }
.oc-hit { cursor: grab; }
.oc-canvas.is-dragging .oc-hit { cursor: grabbing; }
.oc-hit.is-over .oc-box { stroke: var(--brand); stroke-width: 2.5; }
.oc-node.is-self .oc-box { stroke-dasharray: 5 4; }
.oc-tray.is-target { outline: 2px dashed var(--line); outline-offset: 4px; border-radius: 10px; }
@media (prefers-reduced-motion: no-preference) {
  .oc-node, .oc-edge { transition: opacity .12s ease; }
}

/* ---- ผังองค์กร: แยกตามหน่วย แบบเรียบ ---- */
.oc-unitblock { margin-bottom: 1.4rem; }
.oc-unitname {
  margin: 0 0 .3rem; font-size: .78rem; font-weight: 700; color: var(--muted);
}
.oc-pool { border-top: 1px solid var(--line); margin-top: .6rem; padding-top: .8rem; }
.oc-pool.is-target { outline: 2px dashed var(--line); outline-offset: 4px; border-radius: 10px; }
.oc-pool-title { margin: 0 0 .4rem; font-size: .76rem; font-weight: 700; color: var(--muted); }
.oc-chip.is-dim { opacity: .3; }
/* คนที่ตัวอยู่คนละหน่วยกับหัวหน้า — เส้นประบางๆ พอให้รู้ว่ากล่องนี้ไม่ได้สังกัดหน่วย
   ของบล็อกที่มันถูกวาดอยู่ ไม่มีป้าย ไม่มีปุ่ม เพราะเป็นข้อมูลเก่าที่ต่อขึ้นใหม่ไม่ได้แล้ว */
/* การ์ดไม่มีขอบแล้ว ธงจึงต้องวาดขอบของตัวเองขึ้นมา ไม่ใช่แค่เปลี่ยนเป็นเส้นประ */
.oc-box.is-flagged { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 5 3; }

/* ---- ชั้นลอยตอนลาก: กล่องเงา + เส้นยางยืด ----
   อยู่นอกผัง (position: fixed) เพราะปลายนิ้วไปได้ทุกที่บนหน้า ทั้งนอก viewBox ของผัง
   หน่วยนั้นและลงไปถึงถาดท้ายหน้า — วาดใน <svg> เมื่อไหร่ เงาโดนกรอบตัดหายทันที

   ⚠️ pointer-events: none ต้องมีทั้งชั้น ไม่งั้นเงาบังปลายนิ้วเอง แล้ว elementFromPoint
      จะเจอแต่เงา ไม่เจอกล่องข้างใต้ = ปล่อยลงที่ไหนไม่ได้เลยสักที่ */
.oc-drag-layer {
  position: fixed; inset: 0; z-index: var(--z-popup); pointer-events: none;
}
.oc-wire-layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.oc-wire {
  fill: none; stroke: var(--brand); stroke-width: 2;
  stroke-dasharray: 6 5; stroke-linecap: round;
}
.oc-wire-dot { fill: var(--brand); }
.oc-ghost {
  position: fixed; top: 0; left: 0; width: 152px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 46px; padding: .3rem .5rem; border-radius: 8px;
  background: var(--card); border: 2px solid var(--brand);
  box-shadow: 0 8px 18px rgb(0 0 0 / 22%);
  /* กันข้อความยาวดันกล่องจนเงาไม่เท่ากล่องจริง */
  overflow: hidden;
}
.oc-ghost-name {
  font-size: 13px; font-weight: 600; color: var(--ink);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.oc-ghost-meta { font-size: 10px; color: var(--muted); }

/* ตัวจริงจางลงและขอบเป็นเส้นประ = "ยกออกไปอยู่ที่ปลายนิ้วแล้ว" ไม่ใช่หายไปเฉยๆ */
.oc-node.is-self { opacity: .45; }

@media (prefers-reduced-motion: no-preference) {
  .oc-wire { animation: oc-wire-crawl .5s linear infinite; }
}
@keyframes oc-wire-crawl { to { stroke-dashoffset: -22; } }

/* ============================================================================
   คะแนน: สรุปแหล่งที่มา + ป้ายหมวด + ยอด NBC ที่รออนุมัติ
   ใช้ร่วมกันทั้งหน้าตัวแทน (login-app.jsx) และหน้าแอดมิน (admin-app.jsx)
   สีของแต่ละหมวดหยิบจาก token เดิมทั้งหมด — ไม่เพิ่มสีใหม่เข้าระบบ
   ============================================================================ */

/* --- ป้ายหมวดของแถวคะแนน --- */
.act-cat {
  --act-c: var(--muted);
  display: inline-block; font-size: 11px; font-weight: 500; line-height: 1.55;
  padding: 1px 8px; border-radius: 999px; white-space: nowrap;
  background: color-mix(in srgb, var(--act-c) 14%, white);
  color: color-mix(in srgb, var(--act-c) 80%, var(--ink));
}
.act-cat.is-nbc        { --act-c: var(--gold-strong); }
.act-cat.is-recruit    { --act-c: var(--brand); }
.act-cat.is-checkin    { --act-c: var(--green); }
.act-cat.is-lms        { --act-c: var(--ink-soft); }
.act-cat.is-deal       { --act-c: var(--t); }
.act-cat.is-money_need { --act-c: var(--s); }
.act-cat.is-challenge  { --act-c: var(--brand-strong); }
.act-cat.is-other      { --act-c: var(--muted); }
/* รออนุมัติ = ยังไม่ได้คะแนน จึงใช้ ember (สีเดียวกับ "ต้องทำอะไรต่อ") ไม่ใช่ทองแบบได้แล้ว */
.act-cat.is-pending {
  --act-c: var(--brand-strong);
  border: 1px dashed color-mix(in srgb, var(--brand) 45%, white);
  padding: 0 7px;
}

/* แถวที่ยังไม่ได้คะแนน — ตัวเลขในวงเล็บ + พื้นจางบอกว่ายังไม่นับรวม */
.dash-table tr.is-pending-row { background: color-mix(in srgb, var(--brand) 4%, transparent); }
.dash-table tr.is-pending-row td { color: var(--ink-soft); }
.dash-table tr.is-pending-row td.num strong { color: var(--brand-strong); font-weight: 500; }

/* --- ปุ่มกรองหมวด --- */
.act-filter { display: flex; flex-wrap: wrap; gap: 7px; margin: 18px 0 4px; }
.act-chip {
  font: inherit; font-size: 12.5px; line-height: 1.5;
  padding: 5px 13px; border-radius: 999px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}
.act-chip:hover { border-color: var(--gold-soft); color: var(--ink); }
.act-chip.on { background: var(--ink); border-color: var(--ink); color: #F4F5F7; }

/* --- การ์ดสรุปคะแนน 3 ใบ --- */
.kpi-row.pts-summary { margin-top: 22px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.pts-pending-kpi { border-color: var(--brand-soft); background: var(--brand-tint); }
.pts-pending-kpi .kpi-value { color: var(--brand-strong); }
.pts-pending-kpi .kpi-value em {
  font-family: 'DM Serif Display', serif; font-style: italic; font-weight: 400;
  font-size: 19px; color: var(--brand-strong); margin-left: 4px; letter-spacing: 0;
}
.pts-pending-kpi .kpi-bar { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.pts-pending-kpi .kpi-bar-fill { background: var(--brand-soft); }

/* --- แถบสัดส่วน "แต้มมาจากไหน" บนหน้าแรกของตัวแทน --- */
.pts-source { display: flex; flex-direction: column; gap: 12px; }
.pts-source-bar {
  display: flex; height: 11px; border-radius: 999px; overflow: hidden;
  border: 1px solid var(--line); background: var(--bg);
}
.pts-source-bar i { display: block; height: 100%; min-width: 3px; }
.pts-source-legend { list-style: none; display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; }
.pts-source-legend li {
  display: grid; grid-template-columns: 11px 1fr auto auto; gap: 10px; align-items: baseline;
  font-size: 13px; padding-bottom: 7px; border-bottom: 1px dotted var(--line);
}
.pts-source-legend li:last-child { border-bottom: 0; padding-bottom: 0; }
.pts-source-legend s { width: 10px; height: 10px; border-radius: 3px; text-decoration: none; align-self: center; }
.pts-source-legend span { color: var(--ink); }
.pts-source-legend b { font-family: 'Prompt', sans-serif; font-weight: 500; font-variant-numeric: tabular-nums; }
.pts-source-legend em { font-size: 11.5px; color: var(--muted); font-style: normal; min-width: 62px; text-align: right; }
.pts-source-pending {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--brand-tint); border: 1px solid var(--brand-soft); border-radius: 10px; padding: 10px 13px;
}
.pts-source-pending b { font-size: 14px; color: var(--brand-strong); font-family: 'Prompt', sans-serif; font-weight: 500; }
.pts-source-pending small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.5; }

/* สีในแถบสัดส่วน = สีเดียวกับป้ายหมวด ตัวสัญลักษณ์กับป้ายจึงอ่านคู่กันได้ */
.pts-src-nbc        { background: var(--gold-strong); }
.pts-src-recruit    { background: var(--brand); }
.pts-src-checkin    { background: var(--green); }
.pts-src-lms        { background: var(--ink-soft); }
.pts-src-deal       { background: var(--t); }
.pts-src-money_need { background: var(--s); }
.pts-src-challenge  { background: var(--brand-strong); }
.pts-src-other      { background: var(--muted); }

/* --- คะแนน NBC บนดีล (โมดัลรายละเอียด + การ์ดในบอร์ด) --- */
.deal-nbc-pts {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-radius: 12px; padding: 11px 14px; margin: 0 0 14px;
  border: 1.5px solid var(--gold-soft); background: var(--gold-tint);
}
.deal-nbc-pts b { font-size: 14px; color: var(--ink); }
.deal-nbc-pts small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.deal-nbc-pts strong {
  font-family: 'Prompt', sans-serif; font-size: 22px; font-weight: 600;
  color: var(--gold-strong); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.deal-nbc-pts.is-pending { border-color: var(--brand-soft); background: var(--brand-tint); }
.deal-nbc-pts.is-pending strong { color: var(--brand-strong); }
.deal-nbc-pts.is-pending small { color: color-mix(in srgb, var(--brand) 60%, var(--ink)); }

/* บรรทัดคะแนนในกล่องติ๊กอนุมัติ — ให้ผู้จัดการเห็นว่าติ๊กแล้วแจกไปเท่าไหร่ */
.deal-approve-pts { display: block; font-size: 12.5px; margin-top: 5px; color: var(--gold-strong); }

/* ชิปคะแนนบนการ์ดดีลในบอร์ด */
.sales-deal-pts {
  font-size: 11.5px; font-weight: 500; padding: 1px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--gold-tint); color: var(--gold-strong); border: 1px solid var(--gold-soft);
}
.sales-deal-pts.is-pending {
  background: var(--brand-tint); color: var(--brand-strong);
  border: 1px dashed color-mix(in srgb, var(--brand) 45%, white);
}

@media (max-width: 640px) {
  .deal-nbc-pts { flex-direction: column; align-items: flex-start; gap: 6px; }
  .pts-source-legend li { grid-template-columns: 11px 1fr auto; }
  .pts-source-legend em { display: none; }
}
