/* =====================================================================
   SamuraiPostVdoTikTok — TikTok design system (dark)
   สี: ดำ #000 / #121212, แดง TikTok #FE2C55, ฟ้า TikTok #25F4EE
   ฟอนต์: TikTok Sans (Google Fonts) + Noto Sans Thai
   ===================================================================== */
:root {
  --bg: #000000;                 /* พื้นหลังหลัก (sidebar / topbar) */
  --bg-2: #121212;               /* พื้นเนื้อหา */
  --card: #1a1a1a;               /* การ์ด */
  --card2: #242424;              /* พื้นยกระดับ / ปุ่มรอง */
  --line: rgba(255,255,255,.10);
  --line-2: rgba(255,255,255,.18);
  --border: var(--line);
  --text: #ffffff;
  --text-2: rgba(255,255,255,.75);
  --muted: #9a9ba3;
  --pink: #fe2c55;               /* TikTok red */
  --pink-2: #ef2950;
  --pink-soft: rgba(254,44,85,.14);
  --cyan: #25f4ee;               /* TikTok aqua */
  --cyan-soft: rgba(37,244,238,.12);
  --ok: #1ed760;
  --ok-soft: rgba(30,215,96,.12);
  --err: #ff4d5e;
  --err-soft: rgba(255,77,94,.14);
  --warn: #ffb020;
  --warn-soft: rgba(255,176,32,.14);
  --sidebar-w: 248px;
  --r-sm: 6px; --r: 8px; --r-lg: 12px; --r-xl: 16px;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --font: "TikTok Sans", "Noto Sans Thai", "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; border: none; border-radius: var(--r); color: inherit; }
input, textarea, select { font-family: inherit; }
a { color: inherit; }
::selection { background: rgba(254,44,85,.45); color: #fff; }

/* scrollbar บาง ๆ แบบมืด */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.28); }
*::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid rgba(254,44,85,.7); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; margin: 2px 6px 24px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: #000;
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
  border: 1px solid var(--line);
  overflow: hidden; flex-shrink: 0;
}
.brand-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text b {
  font-size: 15px; font-weight: 800; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  /* เอฟเฟกต์ glitch แบบโลโก้ TikTok */
  text-shadow: -1px -1px 0 rgba(37,244,238,.85), 1px 1px 0 rgba(254,44,85,.85);
}
.brand-text span { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 18px; flex: 1; overflow: auto; padding: 0 2px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 0 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r); color: var(--text-2);
  font-size: 14.5px; font-weight: 600; cursor: pointer; user-select: none; text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--text); }
.nav-item.active { background: rgba(254,44,85,.10); color: var(--pink); }
.nav-item.active .nav-ic { color: var(--pink); }
.nav-ic { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; flex: none; }

.sidebar-foot { display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--muted); padding-top: 12px; border-top: 1px solid var(--line); }
.foot-row { display: flex; align-items: center; gap: 8px; padding: 0 6px; }
.foot-ver {
  font-family: var(--mono); font-size: 11px;
  color: var(--muted); background: rgba(255,255,255,.05); border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 6px; width: fit-content; margin-left: 6px;
}
.dot-online { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(30,215,96,.18); }

/* แถบผู้ใช้ที่ล็อกอินอยู่ (ท้าย sidebar) */
.foot-user {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 10px 12px;
}
.foot-user .nav-ic { color: var(--cyan); flex: none; }
.foot-user-txt { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.foot-user-txt b { color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-user-txt span { font-size: 11px; color: var(--muted); }

/* ตารางสมาชิก */
.mem-note { color: var(--muted); font-size: 13px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem-exp { color: var(--warn); font-weight: 600; }
.mem-bind { color: var(--muted); font-size: 12px; margin-top: 2px; font-family: var(--mono); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-2); }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(18,18,18,.86);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); z-index: 20;
  min-height: 64px;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 800; letter-spacing: -.01em; }
.topbar-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.content { padding: 24px 26px 40px; }

/* ---------- buttons ---------- */
.primary {
  background: var(--pink);
  color: #fff; padding: 10px 16px; font-weight: 700; font-size: 14px;
  transition: background .15s, transform .1s;
}
.primary:hover { background: var(--pink-2); }
.primary:active { transform: scale(.985); }
.primary:disabled { opacity: .5; cursor: not-allowed; }
.ghost {
  background: transparent; color: var(--text); border: 1px solid var(--line-2);
  padding: 9px 14px; font-size: 14px; font-weight: 600;
  transition: background .15s, border-color .15s;
}
.ghost:hover { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.3); }
.ghost:disabled { opacity: .5; cursor: not-allowed; }
.danger { background: var(--err-soft); color: var(--err); border: 1px solid rgba(255,77,94,.3); padding: 8px 12px; font-size: 13px; font-weight: 600; }
.danger:hover { background: rgba(255,77,94,.24); }
.icon-btn { background: transparent; color: var(--text); padding: 8px 10px; font-size: 16px; border: 1px solid var(--line-2); }
.icon-btn:hover { background: rgba(255,255,255,.06); }
.only-mobile, .icon-btn.only-mobile { display: none; }

/* ---------- account cards ---------- */
.account-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
}
.account-card {
  background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-xl); padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.account-card:hover { border-color: var(--line-2); }
.ac-top { display: flex; align-items: flex-start; gap: 12px; }
.ac-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  background: var(--card2);
  display: grid; place-items: center; font-weight: 700; font-size: 18px; color: var(--text);
  border: 1px solid var(--line-2);
}
.account-card.is-on .ac-avatar { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(37,244,238,.18); }
.account-card.is-off .ac-avatar { color: var(--muted); }
.ac-avatar { position: relative; overflow: hidden; }
.ac-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.ac-icon.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ac-meta { flex: 1; min-width: 0; }
.ac-name { font-weight: 800; font-size: 16px; word-break: break-word; letter-spacing: -.01em; }
.ac-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ac-badge {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  font-size: 11px; font-weight: 700; padding: 5px 10px; border-radius: 999px;
  border: 1px solid transparent;
}
.ac-badge.on { background: var(--ok-soft); color: var(--ok); }
.ac-badge.off { background: rgba(255,255,255,.06); color: var(--muted); }
.ac-badge.warn { background: var(--warn-soft); color: var(--warn); }
.account-card.is-expired { border-color: rgba(255,176,32,.4); }
.ac-badge .d { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.ac-main { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: auto; }
.ac-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 12px; font-size: 14px; font-weight: 700; border-radius: var(--r);
  background: var(--card2); color: var(--text); border: 1px solid transparent;
  transition: transform .1s, background .15s, border-color .15s;
}
.ac-btn:hover { background: #2c2c2c; }
.ac-btn:active { transform: scale(.98); }
.ac-btn.primary { background: var(--pink); border-color: transparent; color: #fff; }
.ac-btn.primary:hover { background: var(--pink-2); }
.ac-btn.full { grid-column: 1 / -1; }
.ac-btn .ic { flex-shrink: 0; }

.ac-curl-box {
  margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: #0e0e0e; overflow: hidden;
}
.ac-curl-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; font-size: 11px; color: var(--muted); letter-spacing: .03em;
  border-bottom: 1px solid var(--line);
}
.ac-curl {
  margin: 0; padding: 8px 10px; max-height: 96px; overflow: auto;
  font: 11px/1.45 var(--mono);
  color: #c9d1d9; white-space: pre-wrap; word-break: break-all;
}
#loginCookieOldWrap { margin-bottom: 12px; }
#loginCookieOld { opacity: .9; }
#loginCookieCopy { margin: 6px 0 10px; }

.ac-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.ac-foot-right { display: flex; gap: 8px; }
.ac-foot-left { display: flex; gap: 8px; }
.ac-progress {
  font-size: 12px; color: var(--muted); margin-top: 10px;
  padding: 10px 12px; border-radius: var(--r-lg); background: rgba(255,255,255,.04); border: 1px solid var(--line);
}
.ac-progress.on { color: var(--cyan); border-color: rgba(37,244,238,.3); background: var(--cyan-soft); }
.ac-progress.warn { color: var(--err); }
.ac-authstop {
  display: flex; align-items: center; gap: 7px; font-weight: 700; color: var(--warn);
  animation: authstop-pulse 2s ease-in-out infinite;
}
@keyframes authstop-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.ac-prog-head { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.ac-prog-sub { font-size: 11px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-progress.on .ac-prog-sub { color: var(--cyan); opacity: .85; }
.ac-bar { height: 5px; border-radius: 999px; background: rgba(255,255,255,.10); overflow: hidden; margin-top: 8px; }
.ac-bar-in { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .3s ease; }
.ac-spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(37,244,238,.3); border-top-color: var(--cyan); animation: spin .8s linear infinite; flex: none; }

/* สรุปตัวเลขบนการ์ด */
.ac-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 4px; }
.ac-stat {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 4px; border-radius: var(--r); background: rgba(255,255,255,.04); border: 1px solid var(--line);
}
.ac-stat b { font-size: 17px; font-weight: 800; color: var(--text); line-height: 1.1; }
.ac-stat span { font-size: 10.5px; color: var(--muted); }
.ac-stat.hot b { color: var(--cyan); }
.ac-stat.bad b { color: var(--err); }

/* ===== การ์ดกำลังโพสต์: ขอบไล่สี TikTok ===== */
.account-card { position: relative; overflow: hidden; }
.account-card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5px;
  background: linear-gradient(135deg, var(--cyan), var(--pink), var(--cyan));
  background-size: 300% 300%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 1;
}
.account-card > * { position: relative; z-index: 2; }
.account-card.is-on:hover { border-color: rgba(37,244,238,.35); }
.account-card.is-posting { border-color: transparent; box-shadow: 0 0 0 1px rgba(37,244,238,.25), 0 12px 30px rgba(0,0,0,.4); }
.account-card.is-posting::before { opacity: 1; animation: neonSweep 3s linear infinite; }
@keyframes neonSweep { 0% { background-position: 0% 50%; } 100% { background-position: 300% 50%; } }

/* บรรทัดค่าตั้งบอทบนการ์ด */
.ac-cfg {
  display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted);
  padding: 7px 10px; border-radius: var(--r); background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
}
.ac-cfg-ic { display: inline-flex; color: var(--cyan); flex: none; }
.ac-cfg-tag { font-weight: 800; color: var(--cyan); flex: none; }
.ac-cfg-txt { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* บล็อกสินค้าที่กำลังโพสต์ */
.ac-nowpost {
  display: flex; gap: 12px; align-items: center; margin-bottom: 10px; padding: 10px;
  border-radius: var(--r-lg); background: rgba(255,255,255,.04);
  border: 1px solid rgba(37,244,238,.28); animation: nowpostIn .4s ease;
}
@keyframes nowpostIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ac-nowpost-img {
  position: relative; width: 62px; height: 62px; border-radius: var(--r); overflow: hidden; flex: none;
  background: #0e0e0e; border: 1px solid var(--line-2);
}
.ac-nowpost-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ac-nowpost-img.noimg { display: grid; }
.ac-nowpost-img.noimg img { display: none; }
.ac-nowpost-img.noimg::after { content: "🛒"; place-self: center; font-size: 24px; }
.ac-nowpost-scan {
  position: absolute; left: 0; right: 0; top: 0; height: 45%;
  background: linear-gradient(180deg, rgba(37,244,238,.35), transparent);
  animation: scan 1.8s ease-in-out infinite; pointer-events: none;
}
@keyframes scan { 0% { transform: translateY(-100%); } 100% { transform: translateY(240%); } }
.ac-nowpost-info { min-width: 0; flex: 1; }
.ac-nowpost-badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 800;
  color: var(--pink); letter-spacing: .04em; text-transform: uppercase;
}
.ac-live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--pink);
  animation: livePulse 1s ease-in-out infinite;
}
@keyframes livePulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.7); } }
.ac-nowpost-title {
  font-size: 12.5px; font-weight: 700; color: var(--text); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ac-nowpost-price { font-size: 12px; font-weight: 800; color: var(--cyan); margin-top: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.ac-ghost-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px;
  border-radius: var(--r); background: transparent; color: var(--text-2);
  border: 1px solid var(--line-2); font-size: 13px; font-weight: 600;
}
.ac-ghost-btn:hover { color: var(--text); background: rgba(255,255,255,.06); }
.ac-icon {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: var(--r); background: transparent; color: var(--text-2); border: 1px solid var(--line-2);
  transition: color .1s, background .1s, border-color .1s;
}
.ac-icon:hover { color: var(--text); background: rgba(255,255,255,.06); }
.ac-icon.danger { color: var(--err); }
.ac-icon.danger:hover { background: var(--err-soft); border-color: rgba(255,77,94,.35); }

/* icon + label buttons (topbar/empty) */
.btn-ic { display: inline-flex; align-items: center; gap: 8px; }
.btn-ic .ic, .nav-ic .ic, .empty-ic .ic { display: block; }
.icon-btn { display: inline-grid; place-items: center; }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-ic {
  display: grid; place-items: center; width: 84px; height: 84px; margin: 0 auto 14px;
  border-radius: 50%; background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--text-2);
}
.empty h3 { color: var(--text); margin: 10px 0 4px; font-size: 18px; font-weight: 800; }
.empty p { margin: 0 0 18px; }

/* ---------- generic card ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-xl); }
.card.pad { padding: 22px; }
.card h2 { margin: 0 0 8px; font-size: 20px; font-weight: 800; }
.card h3 { font-size: 15px; font-weight: 800; }
.muted { color: var(--muted); }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  animation: overlayIn .18s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r-xl);
  padding: 24px; width: 380px; max-width: 100%; position: relative;
  box-shadow: 0 30px 80px rgba(0,0,0,.6); max-height: 92vh; overflow: auto;
  animation: modalIn .22s cubic-bezier(.2,.9,.25,1.1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-lg { width: 640px; }
.modal-md { width: 720px; max-width: 92vw; }
.modal h3 { margin: 0 0 16px; font-size: 18px; font-weight: 800; letter-spacing: -.01em; padding-right: 36px; }
.modal h3 span { color: var(--cyan); }
.modal-close {
  position: absolute; top: 12px; right: 12px; background: transparent;
  color: var(--muted); font-size: 22px; line-height: 1; padding: 0;
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  transition: background .15s, color .15s;
}
.modal-close:hover { color: var(--text); background: rgba(255,255,255,.08); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.field .fl { display: block; min-height: 18px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field .fl .muted { font-size: 12px; font-weight: 500; }
.field input, .field textarea, .field select,
.search-input, .rng input, .dash-custom input[type=date], .ovr-input, .hms input,
.sched-row .sched-time, .sched-row .sched-count, .auth-box input, .pm-caption {
  background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--text); padding: 10px 12px; font-size: 14px; font-weight: 500; font-family: inherit; width: 100%;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.field input::placeholder, .field textarea::placeholder, .search-input::placeholder, .auth-box input::placeholder { color: rgba(255,255,255,.35); }
.field input:focus, .field textarea:focus, .field select:focus,
.search-input:focus, .rng input:focus, .dash-custom input[type=date]:focus, .ovr-input:focus, .hms input:focus,
.sched-row .sched-time:focus, .sched-row .sched-count:focus, .auth-box input:focus, .pm-caption:focus {
  outline: none; border-color: var(--pink); background: rgba(255,255,255,.08); box-shadow: 0 0 0 3px rgba(254,44,85,.18);
}
.field input:disabled, .ovr-input:disabled { opacity: .5; cursor: not-allowed; }
.field textarea { resize: vertical; min-height: 44px; line-height: 1.5; }
.field select, .search-input:is(select) {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a9ba3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px;
}
select option { background: #1f1f1f; color: #fff; }
input[type=checkbox] { accent-color: var(--pink); width: 16px; height: 16px; }
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(1) opacity(.6); cursor: pointer; }
input[type=file] { cursor: pointer; }
input[type=file]::file-selector-button {
  font-family: inherit; font-weight: 700; font-size: 12px; color: #fff; background: var(--pink);
  border: 0; border-radius: 6px; padding: 6px 10px; margin-right: 10px; cursor: pointer;
}
.grid { display: flex; flex-direction: column; gap: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.row { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ตั้งค่าบอท: แท็บโหมด */
.mode-tabs { display: flex; gap: 4px; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 4px; margin-bottom: 16px; }
.mode-tab {
  flex: 1; background: transparent; border: none; color: var(--muted); cursor: pointer;
  padding: 9px 12px; border-radius: var(--r); font-size: 13px; font-weight: 700; font-family: inherit; transition: .15s;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active { background: #fff; color: #000; }

/* ช่อง H M S */
.hms { display: flex; align-items: center; gap: 6px; }
.hms input { width: 56px; text-align: center; padding: 10px 6px; }
.hms span { font-size: 12px; color: var(--muted); margin-right: 4px; }

/* รายการรอบเวลา */
.sched-list { display: flex; flex-direction: column; gap: 8px; }
.sched-row {
  display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.04);
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 8px 10px;
}
.sched-ic { color: var(--pink); display: inline-flex; }
.sched-row .sched-time { width: 116px; padding: 8px 10px; }
.sched-row .sched-count { width: 64px; text-align: center; padding: 8px; }
.sched-x { font-size: 13px; color: var(--muted); }
.sched-del {
  margin-left: auto; background: transparent; border: none; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 6px; border-radius: var(--r);
}
.sched-del:hover { color: var(--err); }
.sched-gap { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line-2); }

.howto {
  background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 12px 14px; font-size: 13px; color: var(--muted); margin-bottom: 14px; line-height: 1.6;
}
.howto b { color: var(--text); }
.howto ol { margin: 8px 0 0; padding-left: 20px; }
.howto li { margin-bottom: 4px; }

.status { font-size: 13px; color: var(--muted); display: inline-block; margin-top: 8px; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.status.loading { color: var(--cyan); }

/* ---------- QR ---------- */
.qr-frame {
  position: relative; width: 220px; height: 220px; margin: 0 auto 14px;
  background: #fff; border-radius: var(--r-lg); display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.qr-frame img { width: 200px; height: 200px; image-rendering: pixelated; }
.spinner {
  position: absolute; width: 40px; height: 40px; border: 4px solid #ddd;
  border-top-color: var(--pink); border-radius: 50%; animation: spin .8s linear infinite;
}
.qr-hint { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 8px; text-align: center; }

.qr-success {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  background: var(--card); color: var(--ok);
}
.qr-success .ring {
  width: 84px; height: 84px; border-radius: 50%;
  border: 5px solid var(--ok); display: grid; place-items: center;
  font-size: 46px; line-height: 1; animation: pop .35s ease;
}
.qr-success .txt { color: var(--text); font-weight: 600; font-size: 15px; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* ---------- products ---------- */
.product-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px; margin-top: 12px; max-height: 260px; overflow: auto; padding: 4px;
}
.product-card {
  background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 8px; cursor: pointer; font-size: 12px; transition: border-color .1s;
}
.product-card:hover { border-color: var(--cyan); }
.product-card.selected { border-color: var(--pink); box-shadow: 0 0 0 1px var(--pink); }
.product-card img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; margin-bottom: 6px; background: #222; }
.p-title { color: var(--text); line-height: 1.3; max-height: 2.6em; overflow: hidden; }
.p-price { color: var(--pink); font-weight: 700; margin-top: 2px; }

.result {
  margin-top: 14px; background: #0e0e0e; border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 12px; font-family: var(--mono); font-size: 12px;
  white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; color: #c9d1d9;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #2a2a2a; border: 1px solid var(--line-2); color: var(--text);
  padding: 12px 18px; border-radius: 999px; z-index: 200; font-size: 14px; font-weight: 600;
  box-shadow: 0 12px 40px rgba(0,0,0,.55);
  animation: toastIn .25s cubic-bezier(.2,.9,.25,1.1);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast.ok { border-color: rgba(30,215,96,.5); }
.toast.err { border-color: rgba(255,77,94,.55); }

/* ---------- products table modal ---------- */
.modal-xl { width: 92vw; max-width: 1480px; }
.pm-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.pm-bulk { padding: 9px 14px; font-size: 13px; border: 1px dashed rgba(37,244,238,.6); color: var(--text); border-radius: var(--r); cursor: pointer; background: var(--cyan-soft); }
.pm-bulk:hover { background: rgba(37,244,238,.2); }
.pm-vis { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
.pm-vis select, .pm-vis input { width: auto; padding: 8px 10px; }
.pm-vis select { padding-right: 30px; }
.pm-showcase { white-space: nowrap; }
.pm-spacer { flex: 1; }
.pm-mapinfo { background: var(--cyan-soft); border: 1px solid rgba(37,244,238,.25); border-radius: var(--r-lg); padding: 10px 12px; font-size: 13px; color: var(--text); margin-bottom: 12px; }
.pm-table-wrap { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: auto; max-height: 62vh; background: var(--card); }
.pm-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.pm-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: #202020; color: var(--muted);
  text-align: left; font-weight: 700; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  padding: 12px 14px; border-bottom: 1px solid var(--line-2);
}
.pm-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.pm-table tbody tr { transition: background .12s ease; }
.pm-table tbody tr:last-child td { border-bottom: none; }
.pm-table tbody tr:hover { background: rgba(255,255,255,.035); }
.pm-table tr.mapped { background: rgba(37,244,238,.05); }
.pm-table tr.mapped:hover { background: rgba(37,244,238,.09); }
.pm-empty { text-align: center; color: var(--muted); padding: 30px !important; }
.pm-dash { color: var(--muted); }

/* ---------- ค้นหา + ลากจัดลำดับสินค้า ---------- */
.pm-search { min-width: 220px; flex: 0 1 280px; }
.pm-search-tip { font-size: 12px; color: var(--muted); white-space: nowrap; }
.pm-c-drag { width: 34px; padding-right: 0 !important; }
.pm-drag {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 26px;
  color: var(--muted); font-size: 15px; line-height: 1; cursor: grab; user-select: none; border-radius: 6px;
}
.pm-drag:hover { color: var(--cyan); background: var(--cyan-soft); }
.pm-table tbody tr.no-drag .pm-drag { opacity: .3; cursor: not-allowed; }
.pm-table tbody tr.dragging { opacity: .45; background: var(--cyan-soft); }
.pm-table tbody tr.dragging .pm-drag { cursor: grabbing; }
.pm-table tbody tr.drop-above td { box-shadow: inset 0 2px 0 var(--cyan); }
.pm-table tbody tr.drop-below td { box-shadow: inset 0 -2px 0 var(--cyan); }

.pm-c-thumb { width: 56px; }
.pm-thumb { width: 48px; height: 48px; border-radius: var(--r); object-fit: cover; background: #222; border: 1px solid var(--line); }

.pm-c-prod { min-width: 190px; }
.pm-title {
  color: var(--text); font-weight: 600; line-height: 1.4; max-width: 420px;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; text-overflow: ellipsis;
}
.pm-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.pm-price {
  color: var(--pink); font-weight: 800; font-size: 12.5px;
  background: var(--pink-soft); border: 1px solid rgba(254,44,85,.25);
  padding: 2px 8px; border-radius: 999px;
}
.pm-cat { color: var(--muted); font-size: 11px; background: rgba(255,255,255,.06); padding: 2px 8px; border-radius: 999px; }

.pm-c-id { white-space: nowrap; }
.pm-id { font-family: var(--mono); font-size: 12px; color: var(--cyan); background: rgba(255,255,255,.05); border: 1px solid var(--line); padding: 3px 8px; border-radius: 6px; word-break: break-all; }
.pm-copy { display: inline-grid; place-items: center; background: transparent; color: var(--muted); padding: 4px; margin-left: 4px; vertical-align: middle; border-radius: 6px; }
.pm-copy:hover { color: var(--cyan); background: var(--cyan-soft); }
.pm-noid { color: var(--muted); font-size: 12px; font-style: italic; }

.pm-comm { white-space: nowrap; }
.pm-comm-pill {
  display: inline-block; color: var(--ok); font-weight: 800; font-size: 13px;
  background: var(--ok-soft); border: 1px solid rgba(30,215,96,.3);
  padding: 3px 9px; border-radius: 999px;
}
.pm-comm-rate { display: inline-block; color: var(--muted); font-size: 11.5px; margin-left: 6px; }

.pm-c-cap { min-width: 150px; }
.pm-caption { padding: 9px 11px; font-size: 13px; }

.pm-video { white-space: nowrap; }
.pm-vrow { display: flex; gap: 6px; align-items: center; }
.pm-file { display: inline-flex; align-items: center; gap: 5px; padding: 8px 11px; font-size: 12px; cursor: pointer; border-radius: var(--r); font-weight: 600; }
.pm-up {
  display: inline-flex; align-items: center; gap: 5px; padding: 8px 11px; font-size: 12px; font-weight: 700;
  border-radius: var(--r); background: var(--cyan-soft); color: var(--cyan); border: 1px solid rgba(37,244,238,.3);
}
.pm-up:hover:not(:disabled) { background: rgba(37,244,238,.2); }
.pm-up:disabled { opacity: .4; cursor: not-allowed; }
.pm-del {
  display: inline-flex; align-items: center; justify-content: center; padding: 8px 10px;
  border-radius: var(--r); background: var(--pink-soft); color: var(--pink); border: 1px solid rgba(254,44,85,.3); cursor: pointer;
}
.pm-del:hover { background: rgba(254,44,85,.22); }
.pm-reset {
  display: inline-flex; align-items: center; justify-content: center; padding: 8px 10px;
  border-radius: var(--r); background: var(--warn-soft); color: var(--warn); border: 1px solid rgba(255,176,32,.32); cursor: pointer;
}
.pm-reset:hover { background: rgba(255,176,32,.22); }
.pm-fname { font-size: 11.5px; margin-top: 6px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.pm-fname.ok { color: var(--ok); }
.pm-fname.ok::before { content: "🎬 "; }
.pm-prog { margin-top: 7px; height: 5px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; max-width: 200px; }
.pm-prog-bar { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .15s ease; }

/* ===== หลายคลิปต่อสินค้า ===== */
.pm-clip-count { font-size: 11px; font-weight: 800; color: var(--cyan);
  background: var(--cyan-soft); border: 1px solid rgba(37,244,238,.3); border-radius: 999px; padding: 3px 9px; }
.pm-clips { margin-top: 7px; display: flex; flex-direction: column; gap: 4px; max-height: 190px; overflow-y: auto; }
.pm-clips:empty { display: none; }
.pm-clip { position: relative; display: flex; align-items: center; gap: 6px; padding: 5px 6px;
  border: 1px solid var(--line); border-radius: var(--r); background: rgba(255,255,255,.03); font-size: 11.5px; }
.pm-clip.ok { border-color: rgba(37,244,238,.35); background: rgba(37,244,238,.06); }
.pm-clip-idx { flex: none; width: 17px; height: 17px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: var(--muted); background: rgba(255,255,255,.08); }
.pm-clip-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-clip-st { flex: none; font-size: 10.5px; font-weight: 700; color: var(--muted); }
.pm-clip-st.ok { color: var(--ok); }
.pm-clip-st.err { color: var(--pink); }
.pm-clip-st.loading { color: var(--cyan); }
.pm-clip-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 0 0 8px 8px;
  background: rgba(255,255,255,.08); overflow: hidden; }
.pm-clip-prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .15s ease; }
.pm-clip-btn { flex: none; width: 20px; height: 20px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; }
.pm-clip-btn:hover { color: var(--text); }
.pm-clip-btn.x:hover { color: var(--pink); border-color: rgba(254,44,85,.4); background: var(--pink-soft); }

.pm-c-status { white-space: nowrap; }
.pm-status {
  display: inline-block; font-size: 11.5px; font-weight: 700; line-height: 1.4;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.06); color: var(--muted);
}
.pm-status.ok { background: var(--ok-soft); color: var(--ok); }
.pm-status.err { background: var(--err-soft); color: var(--err); }
.pm-status.loading { background: var(--cyan-soft); color: var(--cyan); }

/* ---------- confirm dialog ---------- */
.confirm-overlay { z-index: 150; }
.modal-sm { width: 400px; text-align: center; }
.confirm-box h3 { margin: 4px 0 8px; padding-right: 0; }
.confirm-box .muted { font-size: 14px; line-height: 1.55; }
.confirm-box .modal-actions { justify-content: center; margin-top: 22px; }
.confirm-box .modal-actions button { min-width: 110px; }
.confirm-ic {
  width: 56px; height: 56px; border-radius: 50%; margin: 4px auto 10px;
  display: grid; place-items: center;
  background: var(--cyan-soft); color: var(--cyan);
}
.confirm-ic.danger { background: var(--err-soft); color: var(--err); }
.danger-btn {
  background: var(--err) !important;
  color: #fff !important;
}
.danger-btn:hover { filter: brightness(1.08); }

/* posted row highlight */
.pm-table tr.done { background: rgba(30,215,96,.06); }
.pm-table tr.done:hover { background: rgba(30,215,96,.1); }
.pm-table tr.done td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.pm-table tr.done .pm-up { opacity: .4; }

/* ---------- clip library ---------- */
.clip-usage {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted);
  background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px;
}
.clip-usage svg { color: var(--cyan); }
.jb-badge {
  display: inline-flex; align-items: center; font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.07); color: var(--muted);
}
.jb-badge.ok { background: var(--ok-soft); color: var(--ok); }
.jb-badge.err { background: var(--err-soft); color: var(--err); }
.jb-badge.loading { background: var(--cyan-soft); color: var(--cyan); }
.clip-prod { font-size: 13px; }
.clip-prod-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip-onserver { font-size: 11px; color: var(--cyan); margin-top: 3px; }
.clip-err { font-size: 11px; color: var(--err); margin-top: 4px; }
.clip-actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.clip-retry { padding: 6px 9px; font-size: 12px; }

/* ---------- responsive ---------- */
.sidebar-scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 55;
}

/* ---------- auth gate ---------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(254,44,85,.16), transparent 60%),
    radial-gradient(600px 400px at 85% 90%, rgba(37,244,238,.12), transparent 60%),
    var(--bg);
}
.auth-box {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--card);
  border: 1px solid var(--line-2); border-radius: 20px;
  padding: 34px 28px 28px; box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.auth-logo { width: 64px; height: 64px; font-size: 22px; margin: 0 auto 18px; border-radius: 18px; }
.auth-box h2 { margin: 0 0 6px; font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.auth-box .muted { margin: 0 0 22px; font-size: 13px; }
.auth-box input { margin-bottom: 12px; padding: 12px 14px; font-size: 15px; }
.auth-box .primary { width: 100%; padding: 12px; font-size: 15px; border-radius: var(--r); }
.auth-box .status { display: block; margin-top: 12px; }

/* ===== หลังบ้าน: สถิติ / ตาราง Excel / การเงิน / ความปลอดภัย ===== */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-chip {
  border: 1px solid var(--line); background: var(--card);
  border-radius: var(--r-lg); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.stat-chip::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: rgba(255,255,255,.18); }
.stat-chip .stat-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-chip .stat-value { font-size: 24px; font-weight: 800; letter-spacing: -.01em; line-height: 1.1; }
.stat-chip.ok::before { background: var(--ok); }
.stat-chip.ok .stat-value { color: var(--ok); }
.stat-chip.warn::before { background: var(--warn); }
.stat-chip.warn .stat-value { color: var(--warn); }
.stat-chip.danger::before { background: var(--err); }
.stat-chip.danger .stat-value { color: var(--err); }
.stat-chip.money::before { background: var(--pink); }
.stat-chip.money .stat-value { color: var(--pink); }

.search-input { min-width: 240px; padding: 9px 13px; width: auto; }

/* ตาราง Excel: เส้นกริด + แถวสูงเท่ากัน + zebra */
.pm-table.excel { border-collapse: collapse; }
.pm-table.excel th, .pm-table.excel td { border: 1px solid var(--line); padding: 0 12px; height: 52px; vertical-align: middle; }
.pm-table.excel thead th { background: #202020; }
.pm-table.excel tbody tr:nth-child(even) td { background: rgba(255,255,255,.015); }
.pm-table.excel tbody tr:hover td { background: rgba(254,44,85,.06); }
.pm-table .num { text-align: right; }
.table-tip { color: var(--muted); font-size: 12px; margin: 8px 2px 0; }

.bulk-bar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  background: var(--pink-soft); border: 1px solid rgba(254,44,85,.4); border-radius: var(--r-lg); padding: 8px 14px; font-size: 13px;
}
.btn-small { min-height: 32px; padding: 6px 12px; font-size: 13px; border-radius: var(--r); }

.rng { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.rng input { width: auto; padding: 7px 10px; }
.quick-range { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }

/* ชิปตัวกรอง: เลือกแล้ว = ขาวบนดำ (แบบ TikTok) */
.chip-btn {
  border: 1px solid transparent; background: rgba(255,255,255,.08); color: var(--text-2);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 700; font-family: inherit;
  transition: background .15s, color .15s;
}
.chip-btn:hover { background: rgba(255,255,255,.14); color: var(--text); }
.chip-btn.active { background: #fff; color: #000; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.summary-card { border: 1px solid var(--line); background: var(--card); border-radius: var(--r-xl); padding: 16px 18px; }
.summary-card .sc-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.summary-card .sc-value { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -.01em; }
.summary-card .sc-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.summary-card.profit { border-color: rgba(30,215,96,.4); }
.summary-card.profit .sc-value { color: var(--ok); }
.summary-card.profit .sc-value.neg { color: var(--err); }
.summary-card.danger { border-color: rgba(255,77,94,.4); }
.summary-card.danger .sc-value { color: var(--err); }
.summary-card.hl { border-color: rgba(254,44,85,.45); }
.summary-card.hl .sc-value { color: var(--pink); }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid3 { grid-template-columns: 1fr; } }

.mode-toggle { display: flex; gap: 4px; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 4px; margin: 12px 0; }
.mode-btn { flex: 1; border: none; background: transparent; color: var(--muted); font-weight: 700; padding: 9px 12px; border-radius: var(--r); font-family: inherit; transition: .15s; }
.mode-btn:hover { color: var(--text); }
.mode-btn.active { background: #fff; color: #000; }

.amount-box { border: 1px solid rgba(254,44,85,.4); border-radius: var(--r-lg); padding: 14px 16px; margin: 14px 0; background: var(--pink-soft); }
.amount-row { display: flex; justify-content: space-between; align-items: baseline; }
.amount-value { font-size: 28px; font-weight: 900; color: var(--pink); letter-spacing: -.01em; }
.amount-detail { color: var(--muted); font-size: 12px; margin-top: 6px; }
.ovr-input { margin-left: 8px; width: 120px; padding: 6px 10px; }
.renew-current { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; font-size: 13px; color: var(--muted); margin-bottom: 8px; line-height: 1.7; }
.renew-current b { color: var(--text); }

.vps-res { font-family: var(--mono); font-size: 12px; line-height: 1.5; }
.vps-res .bar { display: inline-block; width: 46px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.12); vertical-align: middle; overflow: hidden; margin-left: 4px; }
.vps-res .bar > i { display: block; height: 100%; background: var(--ok); }
.vps-res .bar.warn > i { background: var(--warn); }
.vps-res .bar.hi > i { background: var(--err); }

/* ===== โพสต์ที่เผยแพร่แล้ว (posts modal) ===== */
.posts-summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.post-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: var(--text);
  background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; }
.post-chip .ic { opacity: .8; }
.posts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-top: 14px;
  max-height: 62vh; overflow-y: auto; padding: 2px; }
.posts-grid.sz-s { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.posts-grid.sz-l { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.post-card { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden; text-decoration: none; color: inherit; transition: transform .15s, border-color .15s, box-shadow .15s; }
.post-card:hover { transform: translateY(-3px); border-color: var(--line-2); box-shadow: var(--shadow); }
.post-cover { position: relative; aspect-ratio: 3/4; background: #0e0e0e; overflow: hidden; }
.post-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-cover.noimg { display: flex; align-items: center; justify-content: center; }
.post-cover.noimg img { display: none; }
.post-cover.noimg::after { content: "ไม่มีภาพปก"; color: var(--muted); font-size: 12px; }
.post-dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.7); color: #fff; font-size: 11px;
  font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.post-vis { position: absolute; left: 6px; top: 6px; font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 6px;
  background: rgba(0,0,0,.6); color: #fff; }
.post-vis.on { background: var(--cyan); color: #000; }
.post-vis.muted { background: rgba(0,0,0,.7); color: #cfd2da; }
.post-body { padding: 10px 11px 12px; display: flex; flex-direction: column; gap: 8px; }
.post-desc { font-size: 12.5px; line-height: 1.45; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; min-height: 36px; }
.post-stats { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.post-stats span { display: inline-flex; align-items: center; gap: 3px; }
.post-stats .ic { opacity: .75; }
.post-time { font-size: 11px; color: var(--muted); }
.posts-more { text-align: center; margin-top: 14px; }
@media (max-width: 560px) { .posts-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); } }

/* ===== เลือกเพลงประกอบ (music picker) ===== */
.music-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.music-title { font-weight: 800; font-size: 14px; }
.switch-line { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch-line input { width: 18px; height: 18px; }
.mode-toggle.disabled { opacity: .45; pointer-events: none; }

.music-pool { margin-top: 12px; }
.music-pool .pool-head { font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 6px; }
.music-pool .pool-items { display: flex; flex-wrap: wrap; gap: 6px; }
.pool-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 999px; padding: 5px 6px 5px 11px; max-width: 240px; }
.pool-chip b { color: var(--cyan); }
.pool-chip .pool-x { border: none; background: var(--err-soft); color: var(--err); width: 18px; height: 18px; border-radius: 50%;
  cursor: pointer; font-size: 14px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }

.music-picker { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px; background: rgba(255,255,255,.03); }
.music-picker-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.music-picker-bar .search-input { flex: 1; min-width: 0; }
.music-list { max-height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.music-item { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card); }
.music-item.sel { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan) inset; }
.music-item img { width: 40px; height: 40px; border-radius: var(--r); object-fit: cover; background: var(--bg); flex: none; }
.music-item .mi-info { min-width: 0; flex: 1; }
.music-item .mi-title { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-item .mi-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-item .mi-com { color: var(--ok); font-weight: 700; }
.music-item .mi-play { flex: none; width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid var(--line-2); background: transparent; cursor: pointer; color: var(--text); }
.music-item .mi-play:hover { background: var(--pink); border-color: var(--pink); }
.music-item .mi-pick { flex: none; padding: 6px 12px; font-size: 12px; }
.ac-cfg-music { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; color: var(--pink); background: var(--pink-soft); max-width: 160px; }
.ac-cfg-music span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-rotate-n input { width: 74px; }
.ac-cfg-order { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; color: var(--cyan); background: var(--cyan-soft); white-space: nowrap; }
#musicBtn.on { color: var(--pink); border-color: rgba(254,44,85,.45); background: var(--pink-soft); }

/* ---------- รายได้ / ค่าคอมมิชชั่น ---------- */

/* ชิปยอดรวมบนแถบบน — เห็นได้ทุกหน้า */
.earn-chip {
  display: inline-flex; align-items: center; gap: 10px; padding: 7px 14px 7px 12px;
  border-radius: var(--r); cursor: pointer; font-family: inherit; text-align: left;
  border: 1px solid rgba(30,215,96,.35); background: var(--ok-soft); color: var(--text);
  transition: border-color .15s, background .15s;
}
.earn-chip:hover { border-color: rgba(30,215,96,.7); background: rgba(30,215,96,.18); }
.earn-chip-ic { display: inline-flex; color: var(--ok); }
.earn-chip-txt { display: flex; flex-direction: column; line-height: 1.2; }
.earn-chip-txt b { font-size: 15px; font-weight: 800; color: var(--ok); }
.earn-chip-txt small { font-size: 10px; color: var(--muted); font-weight: 600; }
@media (max-width: 720px) { .earn-chip-txt small { display: none; } }

.com-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.com-card {
  border: 1px solid var(--line); border-radius: var(--r-xl); padding: 16px 18px;
  background: var(--card);
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.com-card:hover { border-color: var(--line-2); box-shadow: var(--shadow); transform: translateY(-2px); }
.com-card.is-off { opacity: .7; }
.com-card-head { display: flex; align-items: flex-start; gap: 12px; }
.com-card-name { min-width: 0; flex: 1; }
.com-card-name b { display: block; font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.com-card-name small { color: var(--muted); font-size: 12px; }
.com-card-main { text-align: right; flex: none; }
.com-card-main b { display: block; font-size: 22px; font-weight: 800; color: var(--ok); letter-spacing: -.01em; }
.com-card-main small { color: var(--muted); font-size: 11px; }
.com-bar { height: 5px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.com-bar i {
  display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--ok), var(--cyan));
  animation: fxFill .85s cubic-bezier(.22,.9,.2,1) forwards;
}
.com-card-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.com-card-stats > div { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 6px; text-align: center; }
.com-card-stats span { display: block; font-size: 10px; color: var(--muted); font-weight: 600; }
.com-card-stats b { display: block; font-size: 13px; margin-top: 3px; white-space: nowrap; }
.com-more { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.com-card-err { display: flex; align-items: center; gap: 8px; color: var(--warn); font-size: 13px; }

/* สรุปหลายช่วงในหน้าต่างรายละเอียด */
.com-sum-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 4px 0 16px; }
@media (max-width: 900px) { .com-sum-grid { grid-template-columns: repeat(2, 1fr); } }
.com-sum { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; background: rgba(255,255,255,.03); }
.com-sum.hl { border-color: rgba(30,215,96,.45); background: var(--ok-soft); }
.com-sum-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.com-sum-val { display: block; font-size: 20px; font-weight: 800; margin: 4px 0 2px; letter-spacing: -.01em; }
.com-sum.hl .com-sum-val { color: var(--ok); }
.com-sum-sub { font-size: 11px; color: var(--muted); }

.com-chart-card { border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--card); padding: 16px 18px; }
.com-chart-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.com-chart-head b { font-size: 15px; font-weight: 800; }
.com-chart-head .muted { font-size: 12px; }
.com-legend { margin-left: auto; display: flex; gap: 14px; font-size: 12px; color: var(--muted); font-weight: 600; }
.com-lg { display: inline-flex; align-items: center; gap: 6px; }
.com-lg::before { content: ""; width: 12px; height: 3px; border-radius: 2px; }
.com-lg-com::before { background: var(--ok); height: 10px; width: 8px; border-radius: 2px; }
.com-lg-gmv::before { background: var(--cyan); }
.com-chart { min-height: 200px; }
.com-svg { width: 100%; height: 260px; display: block; overflow: visible; }
.com-bar-r { opacity: .95; }
.com-bar-r:hover { opacity: 1; }
.com-guide { stroke: rgba(255,255,255,.07); stroke-width: 1; vector-effect: non-scaling-stroke; }
.com-line { fill: none; stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.com-area { opacity: 0; animation: fxFade .8s .35s ease forwards; }
.com-xl { fill: var(--muted); font-size: 11px; }
.com-chart-foot { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.com-chart-foot b { color: var(--text); }
.fx-bar {
  transform-box: fill-box; transform-origin: center bottom;
  animation: fxBarUp .75s cubic-bezier(.22,.9,.2,1) both;
}
.fx-dot {
  fill: #fff; stroke: var(--cyan); stroke-width: 2;
  transform-box: fill-box; transform-origin: center;
  animation: fxPop .45s cubic-bezier(.2,1.4,.3,1) both;
}
.fx-dot:hover { r: 5; }
@keyframes fxBarUp {
  from { transform: scaleY(0); opacity: 0; }
  to { transform: scaleY(1); opacity: 1; }
}
@keyframes fxFill { to { width: var(--w); } }
@keyframes fxFade { to { opacity: 1; } }
@keyframes fxPop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes fxSlide {
  from { transform: translateX(-16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.com-lists { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 14px; }
.com-list-card { border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--card); padding: 16px 18px; }
.com-list-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.com-list-head b { font-size: 15px; font-weight: 800; }
.com-list-head .muted { margin-left: auto; font-size: 12px; }
.com-list-wrap { max-height: 340px; }
.com-clip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.com-clip-img { width: 38px; height: 38px; border-radius: var(--r); object-fit: cover; flex: none; background: var(--bg); }
.com-clip-img.ph { display: inline-block; border: 1px solid var(--line); }
.com-clip-tx { min-width: 0; }
.com-clip-tx span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 460px; }
.com-clip-tx small { color: var(--muted); font-size: 11px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 460px; }

/* คลิปทำยอด: แผงและการ์ดแนวตั้ง 9:16 แบบ TikTok */
.vclip-panel {
  position: relative; overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(420px 160px at 0% 0%, rgba(254,44,85,.14), transparent 58%),
    radial-gradient(380px 140px at 100% 0%, rgba(37,244,238,.10), transparent 52%),
    var(--card);
  padding: 16px;
}
.vclip-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.vclip-head-ic {
  width: 40px; height: 40px; border-radius: var(--r-lg); flex: none;
  display: grid; place-items: center; color: #fff;
  background: var(--pink);
}
.vclip-head b { display: block; font-size: 16px; font-weight: 800; }
.vclip-head small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.vclip-count {
  margin-left: auto; font-size: 12px; font-weight: 700; color: #fff;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(255,255,255,.08); border: 1px solid var(--line);
}
.vclip-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 14px; padding: 2px 2px 8px;
}
.vclip {
  position: relative; aspect-ratio: 9 / 16; border-radius: var(--r-xl); overflow: hidden;
  border: 1px solid var(--line); background: #0a0a0a;
  animation: vclipIn .45s cubic-bezier(.2,.9,.3,1) both;
  animation-delay: calc(var(--i, 0) * 45ms);
  transition: transform .25s, box-shadow .25s, border-color .25s;
}
.vclip.is-podium { box-shadow: 0 14px 28px rgba(0,0,0,.28); }
.vclip:hover {
  transform: translateY(-5px);
  border-color: var(--line-2);
  box-shadow: 0 24px 42px rgba(0,0,0,.5);
  z-index: 2;
}
@keyframes vclipIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.vclip-media {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
  padding: 0; border: 0; border-radius: 0; background: #0a0a0a; cursor: pointer;
}
.vclip-media img, .vclip-ph { width: 100%; height: 100%; object-fit: cover; display: block; }
.vclip-media img { transition: transform .45s ease; }
.vclip:hover .vclip-media img { transform: scale(1.06); }
.vclip-ph { display: flex; align-items: center; justify-content: center; color: var(--muted); background: #141414; }
.vclip-shade {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.38) 0%, transparent 28%, transparent 48%, rgba(0,0,0,.92) 100%);
  pointer-events: none;
}
.vclip-play {
  position: absolute; left: 50%; top: 36%; width: 48px; height: 48px; margin: -24px 0 0 -24px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.5); color: #fff; font-style: normal;
  border: 2px solid rgba(255,255,255,.7); backdrop-filter: blur(6px);
  opacity: .92; transition: transform .2s, opacity .2s, background .2s;
}
.vclip:hover .vclip-play { transform: scale(1.08); opacity: 1; background: var(--pink); border-color: var(--pink); }
.vclip-dur, .vclip-rank {
  position: absolute; z-index: 2; font-style: normal; font-weight: 800;
  line-height: 1; border-radius: 999px; color: #fff;
}
.vclip-rank {
  top: 10px; left: 10px; min-width: 28px; height: 28px; padding: 0 8px;
  display: grid; place-items: center; font-size: 12px;
  background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.14);
}
.vclip-rank.is-gold { background: linear-gradient(145deg, #ffd56a, #e09a1a); color: #2a1a00; border-color: transparent; }
.vclip-rank.is-silver { background: linear-gradient(145deg, #e8eef5, #9aa6b5); color: #1b222b; border-color: transparent; }
.vclip-rank.is-bronze { background: linear-gradient(145deg, #e8a87c, #a85b2a); color: #2a1408; border-color: transparent; }
.vclip-dur {
  top: 12px; right: 10px; font-size: 11px; padding: 5px 8px;
  background: rgba(0,0,0,.58); backdrop-filter: blur(8px);
}
.vclip-body {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; flex-direction: column; gap: 7px;
  padding: 16px 12px 12px;
  pointer-events: none;
}
.vclip-cap {
  font-size: 13px; font-weight: 700; line-height: 1.35; color: #fff;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  text-shadow: 0 1px 8px rgba(0,0,0,.55);
}
.vclip-prods { display: flex; flex-direction: column; gap: 6px; }
.vclip-prod {
  display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%;
  padding: 5px 8px 5px 5px; border-radius: var(--r-lg);
  background: rgba(12,12,12,.62); border: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(10px);
}
.vclip-prod img, .vclip-prod-ph {
  width: 32px; height: 32px; border-radius: var(--r); object-fit: cover; flex: none;
  background: #1a1a1a;
}
.vclip-prod-ph {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--cyan); border: 1px dashed rgba(37,244,238,.35);
}
.vclip-prod span {
  min-width: 0; font-size: 12px; line-height: 1.3; color: #fff;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.vclip-prod-more {
  align-self: flex-start; font-style: normal; font-size: 11px; font-weight: 800;
  color: #fff; padding: 4px 8px; border-radius: 999px;
  background: rgba(37,244,238,.2); border: 1px solid rgba(37,244,238,.3);
}
.vclip-noprod { color: rgba(255,255,255,.62); font-size: 11px; }
.vclip-stats { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.vclip-gmv { font-size: 15px; font-weight: 800; color: var(--cyan); }
.vclip-meta { display: flex; gap: 8px; color: rgba(255,255,255,.78); font-size: 11px; font-weight: 700; }
.vclip-empty {
  grid-column: 1 / -1; min-height: 180px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; color: var(--muted); padding: 28px 12px;
}
.vclip-empty i {
  width: 52px; height: 52px; border-radius: var(--r-xl); display: grid; place-items: center;
  background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--cyan); margin-bottom: 4px;
}
.vclip-empty b { color: var(--text); font-size: 15px; }
.vclip-empty small { font-size: 12px; max-width: 280px; line-height: 1.45; }

.clip-preview-ov { z-index: 130; }
.clip-preview-modal { width: min(820px, 94vw); padding: 18px; background: var(--card); }
.clip-preview-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
.clip-preview-stage {
  position: relative; border-radius: var(--r-xl); overflow: hidden;
  background: #000; aspect-ratio: 9 / 16; max-height: 72vh;
  box-shadow: 0 18px 40px rgba(0,0,0,.45), 0 0 0 1px var(--line-2);
}
.clip-preview-stage video, .clip-preview-stage img {
  width: 100%; height: 100%; object-fit: contain; display: block; background: #000;
}
.clip-preview-side h3 {
  margin: 0 0 12px; font-size: 18px; line-height: 1.35; padding-right: 30px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.clip-preview-tt {
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px; padding: 10px 16px; border-radius: var(--r);
  text-decoration: none; color: #fff; font-weight: 800; font-size: 13px;
  background: var(--pink);
}
.clip-preview-tt:hover { background: var(--pink-2); }
.clip-preview-plabel { color: var(--muted); font-size: 12px; margin-bottom: 8px; font-weight: 700; }
.vclip-prods-preview { gap: 8px; }
.vclip-prods-preview .vclip-prod { background: rgba(255,255,255,.04); border-color: var(--line); backdrop-filter: none; }
.vclip-prods-preview .vclip-prod span { color: var(--text); font-size: 13px; }
.vclip-prods-preview .vclip-prod img, .vclip-prods-preview .vclip-prod-ph { width: 44px; height: 44px; border-radius: var(--r); }

@media (max-width: 720px) {
  .clip-preview-layout { grid-template-columns: 1fr; }
  .clip-preview-stage { max-height: 52vh; margin: 0 auto; width: min(280px, 100%); }
  .vclip-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
}

/* ---------- Dashboard hero + filters ---------- */
.dash-hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(280px, 400px) minmax(0, 1fr);
  gap: 28px; align-items: center;
  border: 1px solid var(--line-2);
  border-radius: 20px; padding: 24px 28px; margin-bottom: 16px;
  background:
    radial-gradient(560px 280px at 0% 0%, rgba(254,44,85,.24), transparent 60%),
    radial-gradient(560px 280px at 100% 100%, rgba(37,244,238,.14), transparent 60%),
    #000;
}
.dash-hero-glow {
  position: absolute; inset: -40% auto auto 30%; width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(37,244,238,.10), transparent 70%);
  pointer-events: none; animation: dashPulse 6s ease-in-out infinite;
}
@keyframes dashPulse { 50% { transform: scale(1.12); opacity: .7; } }
.dash-hero-main { min-width: 0; position: relative; display: flex; flex-direction: column; justify-content: center; }
.dash-kicker { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.dash-hero-val {
  display: block; font-size: 48px; line-height: 1.05; margin: 8px 0 8px; font-weight: 800; letter-spacing: -.02em;
  color: #fff;
  text-shadow: -2px -1px 0 rgba(37,244,238,.55), 2px 1px 0 rgba(254,44,85,.55);
}
.dash-hero-sub { color: var(--muted); font-size: 13px; }
.dash-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.dash-facts:empty { display: none; }
.dash-fact {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  background: rgba(255,255,255,.07); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px;
}
.dash-fact em { font-style: normal; color: #fff; font-weight: 800; }

.dash-hero-side {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; min-width: 0; position: relative;
}
.dash-mini {
  display: flex; gap: 10px; align-items: flex-start; min-width: 0;
  background: rgba(255,255,255,.05); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 12px 14px;
  transition: background .15s, border-color .15s;
}
.dash-mini:hover { background: rgba(255,255,255,.08); border-color: var(--line-2); }
.dash-mini.gmv { --accent: var(--cyan); }
.dash-mini.sold { --accent: var(--pink); }
.dash-mini.today { --accent: var(--ok); }
.dash-mini.month { --accent: var(--warn); }
.dash-mini.acc { --accent: #fff; }
.dash-mini-ic {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center; background: rgba(255,255,255,.06); color: var(--accent, var(--muted));
  border: 1px solid var(--line);
}
.dash-mini > div { min-width: 0; flex: 1; }
.dash-mini > div > span { display: block; font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-mini b { display: block; margin-top: 3px; font-size: 19px; font-weight: 800; letter-spacing: -.01em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-mini small { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-mini small.up { color: var(--ok); font-weight: 700; }
.dash-mini small.down { color: var(--err); font-weight: 700; }
.dash-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.dash-custom { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); font-weight: 600; }
.dash-custom input[type=date] { width: auto; padding: 6px 8px; }
.com-card-acts { display: flex; gap: 8px; }
.com-card-acts .com-more, .com-card-acts .com-day { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

.time-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px 7px 10px;
  border-radius: var(--r); border: 1px solid var(--line); background: rgba(255,255,255,.04);
  font-variant-numeric: tabular-nums;
}
.time-chip-ic { color: var(--cyan); display: inline-flex; }
.time-chip-txt { display: flex; flex-direction: column; line-height: 1.2; }
.time-chip-txt b { font-size: 13px; font-weight: 800; letter-spacing: .02em; }
.time-chip-txt small { font-size: 10px; color: var(--muted); font-weight: 600; }

/* disk chip */
.disk-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px 7px 10px;
  border-radius: var(--r); border: 1px solid var(--line); background: rgba(255,255,255,.04);
  position: relative; overflow: hidden;
}
.disk-chip-ic { color: var(--cyan); display: inline-flex; }
.disk-chip-txt { display: flex; flex-direction: column; line-height: 1.2; }
.disk-chip-txt b { font-size: 13px; }
.disk-chip-txt small { font-size: 10px; color: var(--muted); font-weight: 600; }
.disk-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.06); }
.disk-bar em { display: block; height: 100%; width: 0; background: var(--cyan); transition: width .4s; }
.disk-bar em.warm { background: var(--warn); }
.disk-bar em.hot { background: var(--err); }

/* clip library */
.lib-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.lib-card {
  border: 1px solid var(--line); border-radius: var(--r-xl); overflow: hidden;
  background: var(--card); display: flex; flex-direction: column;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.lib-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--line-2); }
.lib-vid { width: 100%; aspect-ratio: 9/16; max-height: 280px; object-fit: cover; background: #0a0a0a; display: block; }
.lib-vid.ph { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 12px; }
.lib-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.lib-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-acc { display: flex; align-items: center; gap: 6px; color: var(--cyan); font-size: 12px; font-weight: 600; }
.lib-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: var(--muted); }
.lib-st { padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.07); font-weight: 700; }
.lib-card.st-success .lib-st { color: var(--ok); background: var(--ok-soft); }
.lib-card.st-failed .lib-st { color: var(--err); background: var(--err-soft); }
.lib-card.st-running .lib-st { color: var(--cyan); background: var(--cyan-soft); }
.lib-card.st-queued .lib-st { color: var(--warn); background: var(--warn-soft); }
.lib-acts { margin-top: 4px; }

/* bot settings */
.bot-lead { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.bot-lead b { color: var(--text); }
.bot-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.bot-mode {
  text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,.03);
  border-radius: var(--r-lg); padding: 12px 14px; color: var(--muted); font-family: inherit;
  transition: border-color .15s, background .15s;
}
.bot-mode b { display: block; color: var(--text); margin-bottom: 4px; font-weight: 800; }
.bot-mode small { display: block; font-size: 11px; line-height: 1.4; }
.bot-mode:hover { border-color: var(--line-2); background: rgba(255,255,255,.05); }
.bot-mode.active {
  border-color: var(--pink);
  background: var(--pink-soft);
  color: var(--text-2);
  box-shadow: 0 0 0 1px var(--pink) inset;
}
.size-toggle { display: flex; gap: 4px; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: var(--r); padding: 3px; }
.size-toggle button {
  border: 0; background: transparent; color: var(--muted); font-family: inherit;
  font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 6px;
}
.size-toggle button.active { background: #fff; color: #000; }

@media (max-width: 900px) {
  .dash-hero { padding: 20px; gap: 18px; }
  .dash-hero-val { font-size: 38px; }
  .dash-hero-side { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .bot-modes { grid-template-columns: 1fr; }
}

/* ---------- วิเคราะห์ข้อมูล ---------- */
.an-head {
  display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  margin-bottom: 10px;
}
.an-head-copy { display: flex; flex-direction: column; min-width: 0; }
.an-head-copy b { font-size: 20px; font-weight: 800; letter-spacing: -.01em; margin: 2px 0 2px; line-height: 1.2; }
.an-head-copy .muted { font-size: 12.5px; }
.an-head-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.an-custom { margin-bottom: 10px; }
.an-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 0 0 10px; }
.an-meta:empty { display: none; }
.an-note { margin: 0; font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.an-note::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); flex: none; }
.an-errors { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.an-err-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--warn); }
.an-err {
  font-size: 11px; font-weight: 700; color: var(--warn); background: var(--warn-soft);
  border: 1px solid rgba(255,176,32,.3); border-radius: 999px; padding: 2px 9px;
}

/* ตัวเลขรวม — แถบเตี้ย ๆ */
.an-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.an-kpi {
  position: relative; overflow: hidden;
  display: flex; gap: 12px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card); padding: 12px 14px;
}
.an-kpi::after {
  content: ""; position: absolute; right: -36px; top: -36px; width: 110px; height: 110px;
  border-radius: 50%; pointer-events: none; opacity: .28;
  background: radial-gradient(circle, var(--glow), transparent 70%);
}
.an-kpi.gmv { --accent: var(--cyan); --glow: rgba(37,244,238,.7); }
.an-kpi.sold { --accent: var(--pink); --glow: rgba(254,44,85,.7); }
.an-kpi.com { --accent: var(--ok); --glow: rgba(30,215,96,.7); }
.an-kpi.sku { --accent: #fff; --glow: rgba(255,255,255,.4); }
.an-kpi-ic {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center; background: rgba(255,255,255,.06); color: var(--accent);
  border: 1px solid var(--line);
}
.an-kpi-body { min-width: 0; position: relative; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.an-kpi-label { display: block; flex: 1 1 100%; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.an-kpi b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; color: var(--text); }
.an-kpi small { display: block; font-size: 11.5px; color: var(--muted); }
.an-kpi small em { font-style: normal; color: var(--accent); font-weight: 800; }

/* สินค้าเด่น 3 ด้าน — รายการกะทัดรัดในคอลัมน์ข้าง */
.an-winners { display: flex; flex-direction: column; gap: 8px; }
.an-win {
  position: relative; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px 12px;
  background: rgba(255,255,255,.03);
  display: flex; gap: 12px; align-items: center;
  animation: fxSlide .45s cubic-bezier(.22,.9,.2,1) both;
}
.an-win:nth-child(2) { animation-delay: .06s; }
.an-win:nth-child(3) { animation-delay: .12s; }
.an-win.gmv { --accent: var(--cyan); border-color: rgba(37,244,238,.3); }
.an-win.sold { --accent: var(--pink); border-color: rgba(254,44,85,.3); }
.an-win.com { --accent: var(--ok); border-color: rgba(30,215,96,.3); }
.an-win.is-empty { opacity: .7; border-color: var(--line); }
.an-win img, .an-win .an-ph {
  width: 52px; height: 52px; border-radius: var(--r); object-fit: cover; flex: none; background: var(--bg);
  border: 1px solid var(--line);
}
.an-win .an-ph, .an-ph { display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.an-win-body { min-width: 0; flex: 1; position: relative; }
.an-win-tag { display: block; font-size: 10.5px; color: var(--accent, var(--muted)); font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.an-win-name { display: block; font-weight: 600; font-size: 12.5px; margin: 2px 0 2px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 44px; }
.an-win-val { display: inline-block; font-size: 17px; font-weight: 800; letter-spacing: -.01em; color: var(--accent, var(--text)); margin-right: 8px; }
.an-win-sub { display: inline; font-size: 11px; color: var(--muted); }
.an-win-bar { display: block; height: 3px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 6px; }
.an-win-bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); animation: fxFill .9s .2s cubic-bezier(.22,.9,.2,1) forwards; }
.an-win-share {
  position: absolute; top: 8px; right: 10px; font-size: 10.5px; font-weight: 800; color: var(--accent);
  background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px;
}

/* อันดับสินค้า + แผงข้าง */
.an-main { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .85fr); gap: 14px; margin-bottom: 14px; align-items: start; }
.an-col-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.an-board-card { min-width: 0; }
.an-board-head { align-items: center; }
.an-board-title { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.an-board-hint { font-size: 12px; }
.an-sort { margin-left: 0; }
.an-search { min-width: 160px; flex: 0 1 200px; }
.an-board { display: flex; flex-direction: column; gap: 2px; }
.an-row {
  display: grid; grid-template-columns: 28px 40px minmax(0, 1fr) 22px; gap: 10px; align-items: center;
  padding: 7px 10px; border-radius: var(--r-lg); border: 1px solid transparent; cursor: pointer;
  transition: background .15s, border-color .15s;
  animation: fxSlide .4s cubic-bezier(.22,.9,.2,1) both;
}
.an-row:hover { background: rgba(255,255,255,.04); }
.an-row.open { background: rgba(255,255,255,.05); border-color: var(--line); }
.an-rank {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; background: rgba(255,255,255,.07); color: var(--muted);
}
.an-rank.r1 { background: linear-gradient(145deg, #ffd56a, #e09a1a); color: #2a1a00; }
.an-rank.r2 { background: linear-gradient(145deg, #e8eef5, #9aa6b5); color: #1b222b; }
.an-rank.r3 { background: linear-gradient(145deg, #e8a87c, #a85b2a); color: #2a1408; }
.an-row-img, .an-row .an-ph { width: 40px; height: 40px; border-radius: var(--r); object-fit: cover; background: var(--bg); border: 1px solid var(--line); }
.an-row-body { min-width: 0; }
.an-row-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.an-row-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: 13px; }
.an-row-val { flex: none; font-weight: 800; font-size: 14px; color: var(--text); }
.an-row-track { height: 5px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; margin: 4px 0; }
.an-row-track i {
  display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--pink));
  animation: fxFill .8s cubic-bezier(.22,.9,.2,1) forwards;
}
.an-row-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 11px; color: var(--muted); }
.an-row-meta b { color: var(--text-2); font-weight: 700; }
.an-row-chev { color: var(--muted); display: grid; place-items: center; transition: transform .2s; }
.an-row.open .an-row-chev { transform: rotate(180deg); color: var(--text); }
.an-row-detail { grid-column: 1 / -1; display: none; padding: 4px 0 4px 42px; border-top: 1px dashed var(--line); margin-top: 2px; padding-top: 10px; }
.an-row.open .an-row-detail { display: flex; flex-direction: column; gap: 8px; cursor: default; }
.an-acc { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; font-size: 12px; }
.an-acc-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.an-acc-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-acc-av {
  width: 22px; height: 22px; border-radius: 50%; background: var(--card2); border: 1px solid var(--line-2);
  font-size: 9.5px; font-weight: 800; display: grid; place-items: center; flex: none; color: var(--text-2);
}
.an-acc-val { font-weight: 800; white-space: nowrap; }
.an-acc-val small { color: var(--muted); font-weight: 600; margin-left: 6px; }
.an-acc-track { grid-column: 1 / -1; height: 4px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; }
.an-acc-track i { display: block; height: 100%; background: var(--cyan); border-radius: 999px; }
.an-accounts .hbar-track i { background: linear-gradient(90deg, var(--ok), var(--cyan)); }
.an-col-side .hbar-box, .an-col-side .donut-box { min-height: 0; }
.an-col-side .com-chart-card { padding: 14px 16px; }
.an-col-side .com-chart-head { margin-bottom: 10px; }

/* ตารางละเอียด */
.an-table-card { margin-bottom: 10px; }
.an-table-hint { font-size: 12px; }
.an-csv { margin-left: auto; }
.an-table th.sortable { cursor: pointer; user-select: none; transition: color .15s; }
.an-table th.sortable:hover { color: var(--text); }
.an-table th.sortable.active { color: var(--pink); }
.an-table th.sortable.active::after { content: " ↓"; }
.an-prod { display: flex; align-items: center; gap: 10px; min-width: 0; }
.an-prod img, .an-prod .an-ph {
  width: 40px; height: 40px; border-radius: var(--r); object-fit: cover; flex: none; background: var(--bg);
}
.an-prod span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
.an-prod small { color: var(--muted); font-size: 11px; }
.an-accs { color: var(--muted); font-size: 12px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-empty-win { grid-column: 1 / -1; }

@media (max-width: 1200px) {
  .an-kpis { grid-template-columns: 1fr 1fr; }
  .an-main { grid-template-columns: 1fr; }
  .an-col-side { display: grid; grid-template-columns: 1fr 1fr; }
  .an-col-side > .com-chart-card:last-child { grid-column: 1 / -1; }
}
@media (max-width: 1400px) {
  .dash-hero { grid-template-columns: 1fr; gap: 20px; }
}
@media (max-width: 900px) {
  .an-head { flex-direction: column; align-items: stretch; }
  .an-col-side { grid-template-columns: 1fr; }
  .an-search { flex: 1 1 100%; }
}
@media (max-width: 520px) {
  .an-kpis { grid-template-columns: 1fr; }
  .an-kpi b { font-size: 22px; }
  .an-row { grid-template-columns: 26px 40px minmax(0, 1fr) 18px; gap: 8px; padding: 8px; }
  .an-row-detail { padding-left: 0; }
}

.hbar-box { display: flex; flex-direction: column; gap: 10px; min-height: 220px; }
.hbar {
  display: flex; align-items: center; gap: 10px;
  animation: fxSlide .5s cubic-bezier(.22,.9,.2,1) both;
}
.hbar-rank {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
  background: rgba(255,255,255,.08); color: var(--muted);
}
.hbar-img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; flex: none; background: var(--bg); }
.hbar-body { flex: 1; min-width: 0; }
.hbar-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; margin-bottom: 4px; }
.hbar-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.hbar-top b { flex: none; color: var(--text); }
.hbar-track { height: 8px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.hbar-track i {
  display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--c1, var(--cyan)), var(--c2, var(--pink)));
  animation: fxFill .9s cubic-bezier(.22,.9,.2,1) forwards;
}

.donut-box { display: flex; flex-direction: column; align-items: center; gap: 12px; min-height: 220px; }
.donut-svg { width: 168px; height: 168px; }
.donut-seg {
  transform: rotate(-90deg); transform-origin: 50% 50%;
  stroke-linecap: round;
  animation: fxDonut 1s cubic-bezier(.22,.9,.2,1) both;
}
@keyframes fxDonut { from { stroke-dasharray: 0 999; } }
.donut-center { fill: var(--text); font-size: 13px; font-weight: 800; }
.donut-sub { fill: var(--muted); font-size: 8px; }
.donut-leg { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.donut-leg div { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.donut-leg i { width: 8px; height: 8px; border-radius: 99px; flex: none; }
.donut-leg b { margin-left: auto; color: var(--text); }

/* ---------- จอมือถือ: ส่วนหัว Dashboard (วางท้ายไฟล์ให้ชนะกฎหลัก) ---------- */
@media (max-width: 520px) {
  .dash-hero-side { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dash-mini { padding: 10px 12px; }
  .dash-mini-ic { display: none; }
  .dash-mini b { font-size: 16px; white-space: normal; word-break: break-word; }
  .dash-mini small, .dash-mini > div > span { white-space: normal; }
}

/* ---------- สถานะบัญชี (PPS + คำเตือน/การละเมิด) ---------- */
.hl-note { margin: -4px 0 12px; }
.hl-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.hl-card {
  position: relative; border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--card);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.hl-card:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.hl-card.is-off { opacity: .75; }
.hl-card.good { --accent: var(--ok); }
.hl-card.mid { --accent: var(--warn); }
.hl-card.bad { --accent: var(--err); }
.hl-card.none { --accent: var(--muted); }
.hl-card::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent, transparent); }
.hl-card.has-viol { border-color: rgba(255,77,94,.35); }

.hl-head { display: flex; align-items: center; gap: 12px; }
.hl-av {
  width: 44px; height: 44px; border-radius: 50%; flex: none; overflow: hidden;
  background: var(--card2); border: 1px solid var(--line-2);
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
}
.hl-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hl-name { min-width: 0; flex: 1; }
.hl-name b { display: block; font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-name small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-card .hl-badge { display: none; }
.hl-badge {
  flex: none; font-size: 11.5px; font-weight: 800; padding: 5px 11px; border-radius: 999px;
  color: var(--accent, var(--muted)); background: rgba(255,255,255,.06); border: 1px solid var(--line);
}
.hl-badge.good { background: var(--ok-soft); border-color: rgba(30,215,96,.35); }
.hl-badge.mid { background: var(--warn-soft); border-color: rgba(255,176,32,.35); }
.hl-badge.bad { background: var(--err-soft); border-color: rgba(255,77,94,.35); }

.hl-body { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: 14px; align-items: center; }
.hl-score { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hl-score-lb { font-size: 10.5px; color: var(--muted); font-weight: 700; text-align: center; letter-spacing: .03em; }
.hl-gauge { width: 176px; height: 88px; display: block; overflow: visible; }
.hl-gauge-zone { fill: var(--muted); font-size: 7.5px; font-weight: 700; letter-spacing: .02em; }
.hl-gauge-dot { fill: rgba(255,255,255,.22); }
.hl-gauge-tick { stroke: #fff; stroke-width: 1.6; opacity: .9; }
.hl-gauge-tickv { fill: var(--text-2); font-size: 8px; font-weight: 800; }
.hl-gauge-needle { fill: #fff; opacity: .95; transform-box: fill-box; transform-origin: 50% 100%; animation: fxPop .6s cubic-bezier(.2,1.2,.3,1) both; }
.hl-gauge-needle.good { fill: var(--ok); }
.hl-gauge-needle.mid { fill: #ffd400; }
.hl-gauge-needle.bad { fill: var(--err); }
.hl-gauge-hub { fill: #1a1a1a; stroke: rgba(255,255,255,.35); stroke-width: 1.5; }
.hl-gauge-hub2 { fill: #fff; }
.hl-gauge-hub2.good { fill: var(--ok); }
.hl-gauge-hub2.mid { fill: #ffd400; }
.hl-gauge-hub2.bad { fill: var(--err); }
.hl-gauge-val { fill: #fff; font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.hl-gauge-max { fill: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: 0; }
.hl-gauge-level { display: block; font-size: 15px; font-weight: 800; margin-top: -2px; }
.hl-gauge-level.good { color: var(--ok); }
.hl-gauge-level.mid { color: #ffd400; }
.hl-gauge-level.bad { color: var(--err); }
.hl-gauge-level.none { color: var(--muted); }
.hl-mgauge { margin-left: 12px; display: flex; flex-direction: column; align-items: center; }
.hl-mgauge .hl-gauge { width: 150px; height: 75px; }
.hl-mgauge .hl-gauge-level { font-size: 13px; }
.hl-dims { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.hl-dim-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; font-weight: 600; }
.hl-dim-top b { font-weight: 800; }
.hl-dim-top b.good { color: var(--ok); }
.hl-dim-top b.mid { color: var(--warn); }
.hl-dim-top b.bad { color: var(--err); }
.hl-dim-track { height: 6px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 5px; }
.hl-dim-track i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--muted); animation: fxFill .8s cubic-bezier(.22,.9,.2,1) forwards; }
.hl-dim-track i.good { background: var(--ok); }
.hl-dim-track i.mid { background: var(--warn); }
.hl-dim-track i.bad { background: var(--err); }
.hl-dim small { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hl-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hl-stats > div { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 10px; min-width: 0; }
.hl-stats span { display: block; font-size: 10.5px; color: var(--muted); font-weight: 600; }
.hl-stats b { display: block; font-size: 16px; font-weight: 800; margin-top: 2px; }
.hl-stats small { display: block; font-size: 10.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-stats > div.good b { color: var(--ok); }
.hl-stats > div.bad { border-color: rgba(255,77,94,.35); background: var(--err-soft); }
.hl-stats > div.bad b { color: var(--err); }
.hl-stats > div.warn { border-color: rgba(255,176,32,.35); background: var(--warn-soft); }
.hl-stats > div.warn b { color: var(--warn); }
.hl-risk { margin: 0; font-size: 12px; color: var(--text-2); padding: 8px 10px; border-radius: var(--r); background: rgba(255,255,255,.04); border: 1px dashed var(--line-2); }

.hl-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hl-more { justify-content: center; gap: 8px; padding: 10px 12px; }
.hl-more em { font-style: normal; font-weight: 800; color: var(--text); background: rgba(255,255,255,.08); border-radius: 999px; padding: 1px 8px; font-size: 11.5px; }
.hl-more.warn { border-color: rgba(255,176,32,.45); color: var(--warn); }
.hl-more.warn em { color: var(--warn); background: var(--warn-soft); }
.hl-mstats-2 { grid-template-columns: repeat(3, 1fr); }
.hl-modal { width: 820px; max-width: 94vw; }
.hl-mhead { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.hl-mstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.hl-mstats > div { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; min-width: 0; }
.hl-mstats span { display: block; font-size: 10.5px; color: var(--muted); font-weight: 600; }
.hl-mstats b { display: block; font-size: 18px; font-weight: 800; margin-top: 2px; }
.hl-mstats small { display: block; font-size: 10.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-mstats > div.good b { color: var(--ok); }
.hl-mstats > div.mid b { color: var(--warn); }
.hl-mstats > div.bad b { color: var(--err); }
.hl-mstats > div.bad { border-color: rgba(255,77,94,.35); background: var(--err-soft); }
.hl-modal .hl-risk { margin-bottom: 12px; }
.hl-detail { display: flex; flex-direction: column; gap: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
@media (max-width: 640px) { .hl-mstats { grid-template-columns: 1fr 1fr; } }
.hl-sec > b { display: block; font-size: 12.5px; font-weight: 800; margin-bottom: 8px; }
.hl-ins { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-2); }
.hl-rec { border: 1px solid rgba(255,77,94,.3); background: var(--err-soft); border-radius: var(--r); padding: 9px 11px; margin-bottom: 6px; }
.hl-rec-top { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.hl-rec-top b { font-weight: 800; color: var(--err); }
.hl-rec-top span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.hl-rec p { margin: 5px 0 0; font-size: 12px; color: var(--text-2); white-space: pre-line; }
.hl-rec-sug { color: var(--text-2) !important; display: flex; gap: 6px; align-items: flex-start; padding-top: 6px; margin-top: 8px !important; border-top: 1px dashed rgba(255,77,94,.3); }
.hl-rec-sug .ic { color: var(--cyan); flex: none; margin-top: 2px; }
.hl-prods { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.hl-prod { display: flex; gap: 8px; align-items: center; min-width: 0; padding: 6px; border: 1px solid var(--line); border-radius: var(--r); background: rgba(255,255,255,.03); }
.hl-prod img, .hl-prod .an-ph { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex: none; background: var(--bg); }
.hl-prod div { min-width: 0; }
.hl-prod span { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-prod small { display: block; font-size: 10.5px; color: var(--muted); }
.hl-bens { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.hl-ben { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); font-size: 12px; color: var(--muted); }
.hl-ben .ic { flex: none; margin-top: 2px; }
.hl-ben.on { border-color: rgba(30,215,96,.35); color: var(--ok); }
.hl-ben b { display: block; color: var(--text); font-weight: 700; }
.hl-ben small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

@media (max-width: 900px) { .hl-grid { grid-template-columns: 1fr; } }
@media (max-width: 520px) {
  .hl-body { grid-template-columns: 1fr; }
  .hl-mgauge { display: none; }
  .hl-stats { grid-template-columns: 1fr; }
  .hl-btns { grid-template-columns: 1fr; }
}

/* ---------- PIN 6 หลัก: ล็อกข้อมูลรายได้ ---------- */
.pin-overlay { z-index: 140; }
.pin-box .modal-close { top: 10px; }
.pin-ic { background: var(--pink-soft); color: var(--pink); }
.pin-field { margin: 14px auto 0; max-width: 260px; }
.pin-field input {
  width: 100%; text-align: center; font-size: 30px; font-weight: 800; letter-spacing: .5em; padding: 12px 8px 12px 16px;
  background: rgba(255,255,255,.06); border: 1px solid var(--line-2); border-radius: var(--r-lg); color: var(--text);
  font-family: var(--font); font-variant-numeric: tabular-nums;
}
.pin-field input::placeholder { letter-spacing: .35em; color: rgba(255,255,255,.3); font-size: 26px; }
.pin-field input:focus { outline: none; border-color: var(--pink); box-shadow: 0 0 0 3px rgba(254,44,85,.2); }
#pinField2 { margin-top: 10px; }
.pin-show { justify-content: center; margin-top: 10px; font-size: 12px; color: var(--muted); }
.pin-forgot { font-size: 11.5px; margin: 10px 0 0; line-height: 1.5; }
.pin-box .modal-actions { margin-top: 16px; }

/* หน้าที่ถูกล็อค: ซ่อนเนื้อหา แสดงประตู */
section.is-locked > *:not(.pin-gate) { display: none !important; }
.pin-gate {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 8px; padding: 70px 20px; color: var(--muted);
  border: 1px dashed var(--line-2); border-radius: 20px;
  background:
    radial-gradient(520px 260px at 50% 0%, rgba(254,44,85,.14), transparent 65%),
    var(--card);
}
.pin-gate-ic {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 6px;
  background: var(--pink-soft); color: var(--pink); border: 1px solid rgba(254,44,85,.3);
}
.pin-gate h3 { margin: 0; color: var(--text); font-size: 18px; font-weight: 800; }
.pin-gate p { margin: 0 0 10px; font-size: 13px; max-width: 420px; line-height: 1.5; }

/* เมนูข้าง + ยอดบนแถบบนตอนล็อค */
.nav-lock { margin-left: auto; color: var(--muted); display: inline-flex; opacity: .8; }
.nav-item.active .nav-lock { color: var(--pink); }
.earn-chip.is-locked { border-color: var(--line-2); background: rgba(255,255,255,.05); }
.earn-chip.is-locked .earn-chip-ic { color: var(--muted); }
.earn-chip.is-locked .earn-chip-txt b { color: var(--text-2); letter-spacing: .12em; }
.earn-chip.is-locked:hover { border-color: rgba(254,44,85,.5); background: var(--pink-soft); }
#pinLockBtn .ic { color: var(--pink); }

/* ---------- แบรนด์บนแถบบน ---------- */
.topbar-brand { margin: 0; gap: 10px; flex: none; }
.topbar-brand .brand-logo { width: 36px; height: 36px; border-radius: 10px; }
.topbar-brand .brand-text b { font-size: 15px; overflow: visible; }
.topbar-brand .brand-text span { font-size: 11px; }
.topbar-sep { width: 1px; height: 28px; background: var(--line-2); flex: none; margin: 0 2px; }
.topbar h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar { padding-top: 22px; }
@media (max-width: 1100px) {
  .topbar-brand .brand-text span { display: none; }
}
@media (max-width: 820px) {
  .topbar-brand .brand-text { display: none; }
  .topbar-sep { display: none; }
  .topbar-brand .brand-logo { width: 32px; height: 32px; }
}

/* ---------- Loading overlay ---------- */
.loading-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: overlayIn .15s ease;
}
.loading-box {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r-xl);
  padding: 26px 34px; min-width: 260px; box-shadow: 0 30px 80px rgba(0,0,0,.6);
  animation: modalIn .2s cubic-bezier(.2,.9,.25,1.1);
}
.loading-box b { font-size: 15px; font-weight: 800; margin-top: 6px; }
.loading-box small { font-size: 12px; color: var(--muted); }
/* สปินเนอร์สองวงสี TikTok */
.loading-spin { position: relative; width: 56px; height: 56px; }
.loading-spin i {
  position: absolute; inset: 0; border-radius: 50%; border: 4px solid transparent;
  border-top-color: var(--pink); border-right-color: var(--pink);
  animation: spin .9s linear infinite;
}
.loading-spin i:last-child {
  inset: 9px; border-top-color: var(--cyan); border-right-color: var(--cyan);
  animation: spin .7s linear infinite reverse;
}
body.is-loading .btn-ic[id$="ReloadBtn"], body.is-loading #refreshBtn, body.is-loading #comReloadBtn,
body.is-loading #comDailyBtn, body.is-loading #comDetailReload, body.is-loading #anReloadBtn, body.is-loading #hlReloadBtn,
body.is-loading .com-more, body.is-loading .com-day {
  pointer-events: none; opacity: .55;
}

/* ---------- แถบแจ้งเวอร์ชันใหม่ ---------- */
.update-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 14px 26px 0; padding: 10px 14px; border-radius: var(--r-lg);
  background: linear-gradient(90deg, rgba(254,44,85,.16), rgba(37,244,238,.10));
  border: 1px solid rgba(254,44,85,.4);
  animation: modalIn .25s cubic-bezier(.2,.9,.25,1.1);
}
.update-bar-ic { color: var(--cyan); display: inline-flex; flex: none; }
.update-bar-text { font-size: 13.5px; font-weight: 600; min-width: 0; flex: 1; }
.update-bar-text b { color: var(--cyan); }
.update-bar-btns { display: flex; gap: 8px; flex: none; }
.loading-log {
  margin: 8px 0 0; max-width: 420px; width: 100%; max-height: 120px; overflow: auto; text-align: left;
  font: 11px/1.45 var(--mono); color: var(--muted); background: rgba(0,0,0,.35);
  border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; white-space: pre-wrap; word-break: break-all;
}
@media (max-width: 820px) { .update-bar { margin: 12px 16px 0; } }
@media (max-width: 520px) { .update-bar-btns { width: 100%; } .update-bar-btns button { flex: 1; } }

/* ---------- ข้อมูลสมาชิก ---------- */
.foot-user { cursor: pointer; transition: border-color .15s, background .15s; }
.foot-user:hover { border-color: var(--line-2); background: rgba(255,255,255,.05); }
.foot-user-exp { display: block; font-size: 11px; margin-top: 3px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.foot-user-exp.warn { color: var(--warn); font-weight: 700; }
.foot-user-exp.bad { color: var(--err); font-weight: 700; }
.foot-user-exp.ok { color: var(--muted); }
.member-bar { background: linear-gradient(90deg, rgba(255,176,32,.18), rgba(255,176,32,.06)); border-color: rgba(255,176,32,.45); }
.member-bar .update-bar-ic { color: var(--warn); }
.member-bar .update-bar-text b { color: var(--warn); }
.member-bar.is-expired { background: linear-gradient(90deg, rgba(255,77,94,.2), rgba(255,77,94,.06)); border-color: rgba(255,77,94,.5); }
.member-bar.is-expired .update-bar-ic, .member-bar.is-expired .update-bar-text b { color: var(--err); }
.mem-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px 7px 10px;
  border-radius: var(--r); border: 1px solid var(--line); background: rgba(255,255,255,.04);
  cursor: pointer; font-family: inherit; text-align: left; color: var(--text);
}
.mem-chip .ic { color: var(--muted); }
.mem-chip-txt { display: flex; flex-direction: column; line-height: 1.2; }
.mem-chip-txt b { font-size: 13px; font-weight: 800; }
.mem-chip-txt small { font-size: 10px; color: var(--muted); font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem-chip.warn { border-color: rgba(255,176,32,.5); background: var(--warn-soft); }
.mem-chip.warn b, .mem-chip.warn .ic { color: var(--warn); }
.mem-chip.bad { border-color: rgba(255,77,94,.5); background: var(--err-soft); }
.mem-chip.bad b, .mem-chip.bad .ic { color: var(--err); }
.mem-info-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.mem-info-grid { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.mem-info-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; font-size: 13px; border-bottom: 1px solid var(--line); }
.mem-info-row:last-child { border-bottom: 0; }
.mem-info-row span { color: var(--muted); }
.mem-info-row b { font-weight: 700; text-align: right; }
.mem-exp-ok { color: var(--ok); }
.mem-exp-warn { color: var(--warn); }
.mem-exp-bad { color: var(--err); }
.mem-info-note { font-size: 12px; margin: 12px 0 0; line-height: 1.5; }
@media (max-width: 1100px) { .mem-chip-txt small { display: none; } }

/* ---------- มือถือ: แถบเมนูล่างแบบแอป ---------- */
.tabbar { display: none; }
@media (max-width: 820px) {
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: rgba(0,0,0,.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line-2);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: transparent; border: 0; color: var(--muted); font-size: 10.5px; font-weight: 700;
    padding: 6px 2px; min-height: 52px; border-radius: var(--r);
  }
  .tabbar button .ic { width: 22px; height: 22px; }
  .tabbar button.active { color: var(--pink); }
  .tabbar button:active { background: rgba(255,255,255,.06); }
  body.backend-only .tabbar { display: none; }
  .content { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .sidebar { z-index: 60; padding-bottom: 90px; }
  .sidebar-scrim { z-index: 55; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .icon-btn.only-mobile { display: none; }
  .topbar { padding: 10px 12px; min-height: 56px; }
  .topbar-right { gap: 6px; }
  .mem-chip { padding: 6px 9px; }
  .mem-chip-txt b { font-size: 12px; }
}

/* มือถือ: modal เป็น bottom sheet เลื่อนดูได้เต็มจอ */
@media (max-width: 520px) {
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    width: 100% !important; max-width: 100% !important; max-height: 94dvh; border-radius: 20px 20px 0 0;
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom)); animation: sheetIn .25s cubic-bezier(.2,.9,.25,1);
  }
  .modal::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.25); margin: -6px auto 12px; }
  .modal h3 { font-size: 16px; }
  .modal-close { top: 14px; right: 10px; }
  .modal-actions button, .primary, .ghost { min-height: 44px; }
  .ac-icon, .icon-btn { min-width: 44px; min-height: 44px; }
  .chip-btn { padding: 9px 14px; }
  .nav-item { padding: 13px 12px; font-size: 15px; }
  .pm-table-wrap { max-height: none; }
  .an-search, .search-input { font-size: 16px; } /* กัน iOS ซูมเมื่อโฟกัส */
  .field input, .field textarea, .field select { font-size: 16px; }
  .update-bar, .member-bar { margin: 10px 12px 0; }
  .hl-grid { gap: 10px; }
  .account-grid { gap: 10px; }
  .an-kpis { grid-template-columns: 1fr 1fr; }
  .an-kpi b { font-size: 18px; }
}
@keyframes sheetIn { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 520px) {
  /* แถบบนมือถือ: ซ่อนชื่อหน้า (แถบล่างบอกอยู่แล้ว) ให้ป้ายสมาชิก/ยอดมีที่พอ */
  .topbar h1, .topbar-sep { display: none; }
  .topbar-brand .brand-logo { width: 34px; height: 34px; }
  .topbar-right { margin-left: auto; }
}
.foot-ver-row { display: flex; align-items: center; gap: 8px; margin-left: 6px; flex-wrap: wrap; }
.foot-ver-row .foot-ver { margin-left: 0; }
#checkUpdateBtn { padding: 4px 9px; min-height: 26px; font-size: 11.5px; }
#checkUpdateBtn .ic { width: 13px; height: 13px; }
body.backend-only #checkUpdateBtn { display: none; }
@media (max-width: 520px) { #checkUpdateBtn { min-height: 40px; padding: 8px 12px; font-size: 13px; } }

/* =====================================================================
   มือถือ (วางท้ายไฟล์ให้ชนะกฎทั่วไป)
   ===================================================================== */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 60;
    height: 100vh; overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .2s; box-shadow: 0 0 60px rgba(0,0,0,.7);
    background: var(--bg);
  }
  .sidebar.open { transform: translateX(0); }
  .only-mobile { display: inline-flex; }
  .icon-btn.only-mobile { display: inline-grid; }
  .two { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: 1fr; }
  .modal-lg { width: 100%; }

  .topbar { padding: 12px 16px; gap: 10px; }
  .topbar h1 { font-size: 17px; }
  .topbar-right { gap: 8px; }
  .content { padding: 16px; }
  .account-grid { grid-template-columns: 1fr; gap: 14px; }
}

/* จอมือถือแคบ */
@media (max-width: 520px) {
  .topbar-right .btn-ic span:not([data-icon]) { display: none; }
  .topbar-right .btn-ic { padding: 10px; }
  .topbar h1 { font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right { gap: 6px; flex: none; }
  .disk-chip { display: none; }
  .earn-chip { padding: 7px 10px; gap: 6px; }
  .earn-chip-txt b { font-size: 13px; }
  .content { padding: 14px 12px 32px; }
  .dash-hero { padding: 16px; border-radius: 16px; }
  .dash-hero-val { font-size: 32px; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .com-grid, .lib-grid { grid-template-columns: 1fr; }
  .dash-toolbar .search-input, .pm-toolbar .search-input, .music-picker-bar .search-input { min-width: 0; width: 100%; flex: 1 1 100%; }

  .modal-overlay { padding: 10px; }
  .modal { padding: 18px 16px; border-radius: 14px; }
  .modal-xl, .modal-lg, .modal-md { width: 100%; max-width: 100%; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }

  .pm-spacer { display: none; }
  .pm-toolbar > button, .pm-toolbar > .pm-bulk { flex: 1 1 auto; justify-content: center; }
  .pm-vis, .pm-showcase { flex: 1 1 100%; }
  .pm-table-wrap { max-height: 64vh; }
  .pm-title { max-width: 46vw; }

  .confirm-box .modal-actions { flex-direction: column-reverse; }
  .confirm-box .modal-actions button { width: 100%; }

  .toast { left: 12px; right: 12px; bottom: 14px; transform: none; text-align: center; border-radius: var(--r-lg); }
}

/* กันปุ่มกดยากบนจอสัมผัส */
@media (hover: none) {
  .ac-icon, .icon-btn, .pm-up, .pm-del, .pm-file { min-height: 40px; }
}


@media (max-width: 820px) {
  /* กัน layout viewport ขยายเกินจอเมื่อมี element กว้างเกิน (clip ไม่ทำลาย sticky) */
  html, body { overflow-x: clip; max-width: 100vw; }
  .layout, .main, .content { max-width: 100vw; min-width: 0; overflow-x: clip; }
  .content > section { min-width: 0; }
  .disk-chip { display: none !important; }
  .earn-chip-txt small { display: none; }
}

@media (max-width: 520px) {
  /* แถบบน 2 แถว: แถว 1 โลโก้ + ปุ่มไอคอน · แถว 2 ป้ายสมาชิก + ยอดรายได้ */
  .topbar { flex-wrap: wrap; row-gap: 8px; column-gap: 8px; padding: 10px 12px; }
  .topbar h1, .topbar-sep, .icon-btn.only-mobile { display: none; }
  .topbar-right { display: contents; }
  .topbar-brand { order: 0; margin-right: auto; }
  #pinLockBtn { order: 1; }
  #refreshBtn { order: 2; }
  #addAccountBtn { order: 3; }
  .topbar-right::before { content: ""; order: 4; flex-basis: 100%; height: 0; }
  .time-chip { order: 5; flex: 1 1 0; min-width: 0; justify-content: center; padding: 8px 10px; }
  .mem-chip, .earn-chip { order: 6; flex: 1 1 0; min-width: 0; justify-content: center; padding: 8px 10px; }
  .earn-chip { order: 7; }
  .mem-chip-txt small { display: block; }
  .mem-chip-txt b, .earn-chip-txt b { font-size: 13px; white-space: nowrap; }
  #pinLockBtn span:not([data-icon]), #refreshBtn span:not([data-icon]), #addAccountBtn span:not([data-icon]) { display: none; }
  #pinLockBtn, #refreshBtn, #addAccountBtn { padding: 10px; min-width: 42px; justify-content: center; }
  /* การ์ด/กริดต้องหดได้ต่ำกว่า 360px */
  .account-grid, .com-grid, .lib-grid, .hl-grid, .posts-grid { grid-template-columns: 1fr !important; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .dash-toolbar, .pm-toolbar { gap: 8px; }
  .pm-toolbar > *, .dash-toolbar > * { max-width: 100%; }
  .search-input { min-width: 0; width: 100%; flex: 1 1 100%; }
  .chip-row { gap: 6px; }
  .com-card-stats { grid-template-columns: repeat(2, 1fr); }
  .ac-stats { grid-template-columns: repeat(2, 1fr); }
  .vclip-grid { grid-template-columns: repeat(2, 1fr); }
  .an-main { grid-template-columns: 1fr; }
  .an-col-side { grid-template-columns: 1fr; }
  .hl-body { grid-template-columns: 1fr; }
  .hl-score { flex-direction: row; justify-content: center; gap: 12px; flex-wrap: wrap; }
  .hl-stats { grid-template-columns: 1fr 1fr; }
  .hl-btns { grid-template-columns: 1fr; }
  .update-bar, .member-bar { margin: 10px 12px 0; }
  .content { padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); }
  .modal { max-height: 94dvh; }
}
@media (max-width: 520px) {
  /* แถบบนสูง 2 แถว -> ไม่ต้องติดขอบบน (แถบล่างใช้สลับหน้าอยู่แล้ว) */
  .topbar { position: static; }
  .update-bar, .member-bar { position: static; }
}
@media (max-width: 520px) {
  /* แถบสถิติบนมือถือ: 3 คอลัมน์กะทัดรัด */
  .stat-strip { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-chip { padding: 10px 10px; gap: 3px; }
  .stat-chip .stat-label { font-size: 10.5px; line-height: 1.25; }
  .stat-chip .stat-value { font-size: 18px; }
}

/* ---------- แคปชันรายสินค้า: ข้อความ + ปุ่มแก้ + หน้าต่างแก้ไข ---------- */
.pm-c-cap { min-width: 200px; }
.pm-capbox { display: flex; align-items: center; gap: 8px; max-width: 260px; }
.pm-cap-text { flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.35; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pm-cap-edit { flex: none; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-2); background: transparent; color: var(--cyan); display: grid; place-items: center; cursor: pointer; transition: background .15s, border-color .15s; }
.pm-cap-edit:hover { background: var(--cyan-soft); border-color: var(--cyan); }
.pm-cap-edit.saved { color: var(--ok); border-color: rgba(30,215,96,.5); background: var(--ok-soft); }
.cap-modal textarea { min-height: 130px; line-height: 1.55; font-size: 14px; }
.cap-prod { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-lg); background: rgba(255,255,255,.04); margin-bottom: 14px; }
.cap-prod .pm-thumb { width: 52px; height: 52px; }
.cap-prod-txt { min-width: 0; }
.cap-prod-txt b { display: block; font-size: 13.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cap-prod-txt small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 3px; font-family: var(--mono); }
.cap-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; }
.cap-modal .modal-actions { align-items: center; }
@media (max-width: 520px) { .cap-modal .modal-actions .pm-spacer { display: none; } .cap-modal .modal-actions { flex-direction: column-reverse; } }
.sched-clock { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--cyan); }
