/* ฟอนต์ไทยหลัก — Noto Sans Thai (อ่านง่าย x-height ใหญ่ ดูไม่เล็ก) · display=swap = โชว์ทันทีแล้วค่อยสลับ */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700;800&display=swap');

:root {
  /* ══ ธีม "ม่วงขาว" (Purple-White) — โทนหลักของทั้งแอป ══ */
  --bg: #ffffff;
  --bg2: #f6f4fb;          /* ขาวอมม่วงอ่อน */
  --bg3: #ece7f6;          /* ม่วงอ่อน */
  --t1: #1c1830;           /* หมึก (ม่วงดำ) */
  --t2: #56506b;
  --t3: #948da8;
  --bd: rgba(109, 40, 217, 0.10);
  --bd2: rgba(109, 40, 217, 0.20);
  --r: 14px;
  --r-sm: 9px;
  --shadow: 0 2px 5px rgba(91,33,182,.07), 0 8px 24px rgba(91,33,182,.10);
  --shadow-h: 0 12px 30px rgba(124,58,237,.22);
  --shadow-modal: 0 20px 60px rgba(91,33,182,.28), 0 4px 12px rgba(91,33,182,.14);
  --ease: cubic-bezier(.22,.61,.36,1);
  --grad: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);

  /* primary = ม่วง (remap --blue ทั้งระบบ → ทุกที่ที่ใช้ var(--blue) กลายเป็นม่วง) */
  --blue: #7c3aed;
  --blue-bg: #f2ecfd;
  --blue-dk: #5b21b6;

  --green: #15803d;
  --green-bg: #e7f5ec;
  --green-mid: #16a34a;

  --red: #b91c1c;
  --red-bg: #fdebeb;
  --red-mid: #ef4444;

  --amber: #92500a;
  --amber-bg: #fcf2e1;
  --amber-mid: #f59e0b;

  --purple: #6d28d9;
  --purple-bg: #f2ecfd;
  --purple-mid: #8b5cf6;

  --tA: #7c3aed;           /* ทีม A — ม่วง */
  --tB: #0d9488;           /* ทีม B — เขียวน้ำทะเล */
  --tC: #db2777;           /* ทีม C — ชมพู */

  /* ขนาดตัวอักษร 3 ระดับหลัก — 19 ก.ย.69 เจ้าของขอ header > subheader > text ให้เท่ากันทั้งเว็บ
     ตัวเลขใหญ่ (KPI) และตัวเลขในจุดแจ้งเตือนไม่นับรวม */
  --fs-h: 17px;            /* header — หัวการ์ด / หัวพาเนล */
  --fs-sub: 14.5px;        /* subheader — หัวรอง / ตัวเลขรอง */
  --fs-body: 13px;         /* text — เนื้อความ / ช่องตาราง / ป้ายกำกับ / ปุ่ม */
  --on-blue: #ffffff;      /* ตัวอักษรบนพื้นสีหลักทึบ */

  color-scheme: light;
}

/* ══ โหมดกลางคืน (ม่วงเข้ม) — ตั้งผ่าน html[data-theme="dark"] (JS toggle + จำค่า) ══ */
html[data-theme="dark"] {
  --bg: #15121e;           /* ม่วงดำลึก */
  --bg2: #1e1a2c;
  --bg3: #2a2440;
  --t1: #efeafb;
  --t2: #aaa0c4;
  --t3: #6f6789;
  --bd: rgba(255, 255, 255, 0.09);
  --bd2: rgba(255, 255, 255, 0.17);

  --blue: #a78bfa;         /* ม่วงสว่าง (primary) */
  --blue-bg: #2c2147;
  --blue-dk: #c4b5fd;

  --green: #4ade80;
  --green-bg: #16331f;
  --green-mid: #34d399;

  --red: #f87171;
  --red-bg: #3a1414;
  --red-mid: #ef4444;

  --amber: #fbbf24;
  --amber-bg: #34230a;
  --amber-mid: #f59e0b;

  --purple: #c4b5fd;
  --purple-bg: #2e1d52;
  --purple-mid: #a78bfa;

  --tA: #a78bfa;
  --tB: #2dd4bf;
  --tC: #f472b6;

  --shadow: 0 2px 10px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
  --shadow-h: 0 12px 32px rgba(0,0,0,.55);
  --shadow-modal: 0 24px 70px rgba(0,0,0,.6), 0 4px 14px rgba(0,0,0,.4);
  --grad: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);

  --on-blue: #ffffff;

  color-scheme: dark;
}

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

body {
  font-family: 'Noto Sans Thai', -apple-system, "Helvetica Neue", sans-serif;
  background: linear-gradient(180deg, var(--bg2) 0%, var(--bg) 40%);
  background-attachment: fixed;
  color: var(--t1);
  font-size: var(--fs-body);
  min-height: 100vh;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app { max-width: 1100px; margin: 0 auto; padding: 14px; }
.mut { color: var(--t3); }   /* ข้อความรอง (ใช้ในแท็บสถานะรถ ฯลฯ) */

/* topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-icon { width: 80px; height: 80px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-name { font-size: 24px; font-weight: 700; letter-spacing: 0.2px; line-height: 1.15; }
.brand-sub { font-size: var(--fs-body); color: var(--t3); margin-top: 3px; }

.nav { display: flex; gap: 2px; background: var(--bg2); padding: 3px; border-radius: 8px; border: 0.5px solid var(--bd); box-shadow: var(--shadow); }
.ntab { display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; padding: 6px 13px; font-size: var(--fs-body); border-radius: 8px; border: none; background: transparent; cursor: pointer; color: var(--t2); font-family: inherit; white-space: nowrap; transition: background .18s ease, color .18s ease; }
.ntab:hover { color: var(--t1); }
.ntab.on { background: var(--grad); color: #fff; font-weight: 600; box-shadow: 0 3px 10px rgba(124,58,237,.35); }

/* slide nav — แคปซูล gradient เลื่อนนุ่มระหว่างแท็บ (container id=nav-slide + .nav-ind)
   ⚠️ สไตล์ฐาน (แถบนอน) ต้องอยู่ในคลาสนี้ ห้ามเขียน inline บน element ใน index.html —
   ไม่งั้น media query sidebar ข้างล่าง override ไม่ได้ (inline style ชนะ CSS เสมอ) */
.nav-slide { position: relative; scrollbar-width: none; display: flex; gap: 2px; background: var(--bg2); padding: 3px; border-radius: 8px; border: .5px solid var(--bd); margin-bottom: 6px; overflow-x: auto; }
.nav-slide::-webkit-scrollbar { display: none; }
.nav-slide .ntab { position: relative; z-index: 1; transition: color .2s var(--ease); }
.nav-slide .ntab.on { background: transparent; box-shadow: none; }
.nav-ind { position: absolute; top: 3px; bottom: 3px; left: 0; width: 0; background: var(--grad); border-radius: 8px; box-shadow: 0 3px 10px rgba(124,58,237,.35); transition: left .25s var(--ease), width .25s var(--ease), top .25s var(--ease), height .25s var(--ease); z-index: 0; pointer-events: none; opacity: 0; }

/* ★ ส.ค.69 — เมนูสามขีด (hamburger drawer): ซ่อนแถบแท็บไว้ กดปุ่ม ☰ แล้วเลื่อนออกมาจากซ้าย + ฉากหลังมืด
   ใช้ทุกขนาดจอ (มือถือ/คอมเหมือนกัน) · drawer ลอยทับ ไม่กินพื้นที่ → เนื้อหาได้ความกว้างเต็มตลอด
   ⚠️ บทเรียนจากรอบ sidebar (อย่าให้กลับมา):
     1) container ของ index.html คือ #dashboard-root (ไม่ใช่ #root ซึ่งเป็นของ seller.html และไม่มี nav-slide)
     2) JS ต้องใช้ root.style.display='' (ล้าง inline) ห้าม ='block' — inline style ชนะ CSS เสมอ
     3) สไตล์ฐานของ #nav-slide อยู่ในคลาส .nav-slide เท่านั้น ห้าม inline บน element ใน render() */

/* ปุ่มสามขีดในหัวเว็บ */
.nav-burger { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; border: .5px solid var(--bd2); background: var(--bg2); color: var(--t1); cursor: pointer; transition: background .18s ease, color .18s ease, transform .12s ease; }
.nav-burger:hover { background: var(--purple-bg); color: var(--purple); }
.nav-burger:active { transform: scale(.94); }

/* ฉากหลังมืด — กดที่ไหนก็ปิด drawer */
.nav-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .48); opacity: 0; pointer-events: none; transition: opacity .25s var(--ease); z-index: 1250; }
body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }

/* ตัว drawer = #nav-slide เดิม (แถบแท็บ) แค่เปลี่ยนเป็นแผงลอยด้านซ้าย */
#nav-slide { position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh; width: 256px; z-index: 1260;
  transform: translateX(-104%); transition: transform .3s var(--ease);
  flex-direction: column; align-items: stretch; gap: 2px;
  margin: 0; padding: 14px 10px; border-radius: 0 18px 18px 0; border-left: none;
  overflow-x: visible; overflow-y: auto; box-shadow: 6px 0 28px rgba(0, 0, 0, .18); }
body.nav-open #nav-slide { transform: translateX(0); }
/* คืน scrollbar ให้ drawer — .nav-slide ฐานซ่อนไว้ (เขียนตอนยังเป็นแถบนอน) แต่แนวตั้งรายการยาวเกินจอ
   ถ้าซ่อนต่อ ผู้ใช้จะไม่รู้ว่ามีเมนูอยู่ข้างล่างอีก */
#nav-slide { scrollbar-width: thin; scrollbar-color: var(--bd2) transparent; }
#nav-slide::-webkit-scrollbar { display: block; width: 6px; }
#nav-slide::-webkit-scrollbar-thumb { background: var(--bd2); border-radius: 3px; }
#nav-slide::-webkit-scrollbar-track { background: transparent; }
/* ★ 19 ก.ย.69 เจ้าของแจ้ง "เมนูรก" — แถวเตี้ยลง (เดิมสูง ~46px ทำให้เมนูยาวเกินจอ) แต่ยังกดง่ายบนมือถือ (~38px) */
#nav-slide .ntab { justify-content: flex-start; gap: 10px; padding: 9px 14px; font-size: var(--fs-sub); border-radius: 12px; }
#nav-slide .nav-ind { border-radius: 12px; }
/* หัวข้อหมวดใน drawer (หน้าหลัก / ทีม & สิทธิ์ / ตั้งค่าระบบ / ตรวจสอบ & Log) */
/* ★ ก.ย.69 — หัวข้อหมวดเป็น "ปุ่มพับได้" (accordion) · เจ้าของแจ้งว่าเมนูยาวเกินไป
   เปิด/ปิดจำไว้ใน localStorage 'navSec' · หมวดจัดการพับไว้เป็นค่าเริ่มต้น เหลือแค่หัวข้อ
   ⚠️ ต้องเป็น <button> (ไม่ใช่ div) เพื่อให้กดด้วยคีย์บอร์ด/อ่านออกด้วย screen reader ได้ */
.nav-sec { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%;
  flex-shrink: 0; margin: 8px 0 2px; padding: 10px 12px 6px; font-size: var(--fs-body); font-weight: 800;
  letter-spacing: .6px; color: var(--t3); text-align: left; font-family: inherit; cursor: pointer;
  background: transparent; border: none; border-top: .5px solid var(--bd); border-radius: 0;
  position: relative; z-index: 1; transition: color .16s ease; }
.nav-sec:hover { color: var(--t1); }
.nav-sec svg { opacity: .65; transition: transform .2s var(--ease); }
.nav-sec.open svg { transform: rotate(180deg); }
/* รายการที่ถูกพับซ่อนด้วย inline display จาก JS (ดู toggleNavSec) — ไม่ต้องมีกฎที่นี่
   ตั้งใจไม่ผูกการพับกับ CSS ไฟล์นี้ เพราะถ้า CSS ยังไม่ถึงเบราว์เซอร์ เมนูจะกางหมดทันที */
.nav-sec.first { margin-top: 0; border-top: none; }
/* จำนวนรายการในหมวด (ข้างชื่อหัวข้อ) — ของแต่งล้วน ไม่มีก็ยังอ่านเป็นตัวเลขธรรมดาได้ */
.nav-cnt { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 6px; border-radius: 5px; background: var(--bg); border: .5px solid var(--bd); color: var(--t3); font-size: var(--fs-body); font-weight: 700; line-height: 16px; text-align: center; letter-spacing: 0; }
/* รายการเมนูจัดการใน drawer (กดแล้วเปิด modal — ไม่ใช่แท็บ จึงไม่มีแคปซูล gradient) */
.nav-act { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; flex-shrink: 0; padding: 8px 14px; font-size: var(--fs-body); border-radius: 10px; border: none; background: transparent; color: var(--t1); font-family: inherit; cursor: pointer; white-space: nowrap; position: relative; z-index: 1; transition: background .16s ease, color .16s ease; }
.nav-act:hover { background: var(--purple-bg); color: var(--purple); }

/* หัว drawer (โลโก้/ชื่อ + ปุ่มปิด) — ไม่ให้แคปซูล gradient ไปวางทับ */
.nav-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 6px 12px; margin-bottom: 6px; border-bottom: .5px solid var(--bd); position: relative; z-index: 1; }
.nav-head-t { font-size: var(--fs-body); font-weight: 800; color: var(--t1); letter-spacing: -.2px; }
.nav-close { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; border: .5px solid var(--bd2); background: var(--bg2); color: var(--t2); cursor: pointer; flex-shrink: 0; }
.nav-close:hover { background: var(--red-bg); color: var(--red); }

/* ════════════════════════════════════════════════════════════════════
   ★ 19 ก.ย.69 — แถบเมนูสีเข้ม (เจ้าของส่งรูปตัวอย่าง "อยากได้ประมาณนี้ แต่สีของเรา สัญลักษณ์ของเรา")
   · สีเข้มม่วง + แคปซูล gradient ม่วงของเรา + โลโก้บริษัทบนหัว + ผู้ใช้/ออกจากระบบท้ายแถบ
   · มือถือ/จอแคบ = ☰ drawer เหมือนเดิม (หน้าตาเดียวกัน) · จอ ≥1100px = แถบซ้ายถาวร (body.has-sidebar)
   · ⚠️ ทุกอย่างในนี้เป็น "ของแต่ง" — CSS ไม่มา = เมนูเป็น drawer สีอ่อนแบบเดิม ยังใช้ได้ครบ
   ════════════════════════════════════════════════════════════════════ */
:root { --sb-bg: #1c1631; --sb-bg2: #251d40; --sb-t1: #eeeaf8; --sb-t2: #b7afd0; --sb-t3: #8a81a8; --sb-bd: rgba(255,255,255,.08); --sb-w: 252px; }
[data-theme="dark"] { --sb-bg: #0f0c19; --sb-bg2: #1a1528; }
#nav-slide { background: var(--sb-bg); border-color: var(--sb-bd); color: var(--sb-t1); }
#nav-slide .ntab { color: var(--sb-t2); }
#nav-slide .ntab:hover { color: #fff; background: rgba(255,255,255,.06); }
#nav-slide .ntab.on { color: #fff; }
#nav-slide .nav-act { color: var(--sb-t2); }
#nav-slide .nav-act:hover { background: rgba(255,255,255,.07); color: #fff; }
#nav-slide .nav-sec { color: var(--sb-t3); border-top-color: var(--sb-bd); }
#nav-slide .nav-sec:hover { color: var(--sb-t1); }
#nav-slide .nav-cnt { background: rgba(255,255,255,.07); border-color: var(--sb-bd); color: var(--sb-t2); }
#nav-slide .nav-head { border-bottom-color: var(--sb-bd); padding: 2px 4px 14px; margin-bottom: 8px; }
#nav-slide .nav-head-t { color: #fff; font-size: var(--fs-sub); }
#nav-slide .nav-close { background: rgba(255,255,255,.06); border-color: var(--sb-bd); color: var(--sb-t2); }
#nav-slide .nav-close:hover { background: rgba(239,68,68,.18); color: #fca5a5; }
#nav-slide::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); }
#nav-slide { scrollbar-color: rgba(255,255,255,.14) transparent; }
.nav-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nav-logo { height: 36px; width: auto; border-radius: 8px; display: block; flex-shrink: 0; }
.nav-brand-t { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.nav-head-s { font-size: var(--fs-body); color: var(--sb-t3); font-weight: 500; }
.nav-foot { margin-top: auto; flex-shrink: 0; display: flex; align-items: center; gap: 9px; padding: 12px 8px 4px; border-top: .5px solid var(--sb-bd); position: relative; z-index: 1; font-size: var(--fs-body); color: var(--sb-t2); }
.nav-foot b { color: #fff; font-weight: 700; }
.nav-foot-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); flex-shrink: 0; }
.nav-foot-u { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-foot-out { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 9px; border: .5px solid var(--sb-bd); background: rgba(255,255,255,.05); color: var(--sb-t2); cursor: pointer; flex-shrink: 0; }
.nav-foot-out:hover { background: rgba(239,68,68,.18); color: #fca5a5; }
/* ชื่อหน้าบนหัวเว็บ (โชว์เฉพาะตอนมีแถบซ้าย — โลโก้ย้ายไปอยู่ในแถบแล้ว) */
.hdr-crumb { font-size: var(--fs-body); color: var(--t3); display: flex; align-items: center; gap: 4px; }
.hdr-h1 { font-size: 21px; font-weight: 800; color: var(--t1); letter-spacing: -.3px; line-height: 1.25; }



@media (min-width: 1100px) {
  body.has-sidebar #nav-slide { transform: none; width: var(--sb-w); z-index: 900; border-radius: 0; box-shadow: none; border: none; padding: 16px 12px 12px; }
  body.has-sidebar .nav-backdrop { display: none; }
  body.has-sidebar .nav-burger,
  body.has-sidebar .nav-close,
  body.has-sidebar .hdr-logo,
  body.has-sidebar .hdr-title,
  body.has-sidebar .hdr-logout { display: none !important; }   /* ออกจากระบบอยู่ท้ายแถบซ้ายแล้ว */
  body.has-sidebar .hdr-page { display: block !important; }
  body.has-sidebar .app { padding-left: calc(var(--sb-w) + 22px); padding-right: 22px; }
}

@media (prefers-reduced-motion: reduce) { #nav-slide, .nav-backdrop { transition: none; } }

.btn-sm { font-size: var(--fs-body); padding: 4px 10px; border-radius: 7px; border: 0.5px solid var(--bd2); background: var(--bg2); color: var(--t2); cursor: pointer; font-family: inherit; transition: background .15s ease, border-color .15s ease, transform .12s ease; }
.btn-sm:hover { background: var(--bg3); border-color: var(--blue); color: var(--t1); }
.btn-sm:active { transform: scale(.96); }

/* loading/error */
.loading-container { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 260px; gap: 12px; color: var(--t3); }
.spin { width: 28px; height: 28px; border: 2.5px solid var(--bd2); border-top-color: var(--blue); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.err-bar { position: sticky; top: 0; z-index: 99; background: var(--red-bg); border: 0.5px solid var(--red-mid); border-radius: var(--r); padding: 9px 12px; color: var(--red); font-size: var(--fs-body); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.err-bar button { margin-left: auto; background: transparent; border: none; cursor: pointer; color: var(--red); font-size: var(--fs-sub); }

/* cards */
.card { background: var(--bg); border: 0.5px solid var(--bd); border-radius: var(--r); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); transition: box-shadow .2s var(--ease), transform .2s var(--ease); }
.card-title { font-size: var(--fs-h); font-weight: 700; margin-bottom: 11px; display: flex; align-items: center; gap: 7px; letter-spacing: -0.2px; }
.card-title::before { content: ""; width: 4px; height: 16px; border-radius: 3px; background: var(--grad); flex-shrink: 0; box-shadow: 0 1px 4px rgba(124,58,237,.4); }

/* kpi */
.kgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; margin-bottom: 10px; }
.kpi { position: relative; overflow: hidden; background: var(--bg); border: 0.5px solid var(--bd); border-radius: var(--r-sm); padding: 12px 12px 11px; box-shadow: var(--shadow); transition: transform .16s ease, box-shadow .16s ease; }
.kpi::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--grad); opacity: .85; }
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-h); }
.kl { font-size: var(--fs-body); color: var(--t2); margin-bottom: 3px; }
.kv { font-size: 24px; font-weight: 800; line-height: 1; letter-spacing: -0.3px; }
.ks { font-size: var(--fs-body); color: var(--t3); margin-top: 2px; }

/* pipe */
.pipe-row { display: flex; gap: 7px; flex-wrap: wrap; }
.pipe-item { background: var(--bg2); border-radius: var(--r-sm); padding: 7px 11px; flex: 1; min-width: 65px; text-align: center; }
.pipe-num { font-size: 20px; font-weight: 600; }
.pipe-lbl { font-size: var(--fs-body); color: var(--t2); margin-top: 2px; }

/* grids */
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; margin-bottom: 10px; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 10px; }

/* team card */
.team-card { border-radius: var(--r); padding: 12px; margin-bottom: 8px; }
.team-card.A { background: rgba(124, 58, 237, 0.08); border: 0.5px solid rgba(124, 58, 237, 0.25); }
.team-card.B { background: rgba(13, 148, 136, 0.08); border: 0.5px solid rgba(13, 148, 136, 0.25); }
.team-card.C { background: rgba(219, 39, 119, 0.08); border: 0.5px solid rgba(219, 39, 119, 0.25); }

/* seller table */
.shdr, .srow { display: grid; grid-template-columns: 82px 38px 44px 40px 44px 50px 46px 1fr; gap: 5px; align-items: center; padding: 7px 8px; font-size: var(--fs-body); }
.shdr { font-size: var(--fs-body); color: var(--t3); font-weight: 500; border-bottom: 0.5px solid var(--bd); padding-bottom: 5px; }
.srow { border-radius: 7px; cursor: pointer; }
.srow:hover { background: var(--bg2); }

/* bars */
.pbr { height: 4px; border-radius: 2px; background: var(--bg3); overflow: hidden; margin-top: 2px; }
.pbf { height: 100%; border-radius: 2px; }
.sbdg { font-size: var(--fs-body); padding: 2px 6px; border-radius: 5px; font-weight: 500; }

/* panel rows */
.prow { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 0.5px solid var(--bd); cursor: pointer; font-size: var(--fs-body); }
.prow:last-child { border-bottom: none; }

/* hot cases */
.hlhdr, .hlrow { display: grid; grid-template-columns: 106px 62px 1fr 54px 44px; gap: 5px; align-items: center; padding: 6px 5px; font-size: var(--fs-body); }
.hlhdr { font-size: var(--fs-body); color: var(--t3); font-weight: 500; border-bottom: 0.5px solid var(--bd); }
.hlrow { border-bottom: 0.5px solid var(--bd); cursor: pointer; }
.hlrow:last-child { border-bottom: none; }
.hlrow:hover { background: var(--bg2); border-radius: 6px; }

/* diligence */
.dilrow { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 0.5px solid var(--bd); }
.dilrow:last-child { border-bottom: none; }
.dilbar { flex: 1; height: 5px; border-radius: 3px; background: var(--bg3); overflow: hidden; }
.dilfill { height: 100%; border-radius: 3px; }

/* follow list */
.lfhdr, .lfrow { display: grid; grid-template-columns: 110px 1fr 56px; gap: 6px; align-items: start; padding: 8px 0; font-size: var(--fs-body); }
.lfhdr { font-size: var(--fs-body); color: var(--t3); font-weight: 500; border-bottom: 0.5px solid var(--bd); padding-bottom: 5px; }
.lfrow { border-bottom: 0.5px solid var(--bd); cursor: pointer; }
.lfrow:last-child { border-bottom: none; }
.lfrow:hover { background: var(--bg2); }
.hr { border-left: 2px solid var(--red-mid); padding-left: 7px; margin-left: -7px; background: rgba(226, 75, 74, 0.04); border-radius: 0 5px 5px 0; }
.ha { border-left: 2px solid var(--amber-mid); padding-left: 7px; margin-left: -7px; background: rgba(239, 159, 39, 0.04); border-radius: 0 5px 5px 0; }
.hb { border-left: 2px solid var(--blue); padding-left: 7px; margin-left: -7px; background: rgba(24, 95, 165, 0.04); border-radius: 0 5px 5px 0; }

/* booking cards */
.booking-card { border: 0.5px solid var(--bd); border-radius: var(--r); overflow: hidden; margin-bottom: 10px; }
.booking-head { padding: 11px 13px; }
.booking-body { padding: 11px 13px; }
.brow { display: flex; gap: 8px; padding: 4px 0; border-bottom: 0.5px solid var(--bd); font-size: var(--fs-body); }
.brow:last-child { border-bottom: none; }
.blbl { color: var(--t3); min-width: 72px; flex-shrink: 0; font-size: var(--fs-body); }
.bval { color: var(--t1); flex: 1; }

/* case detail */
.cd-kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 12px; }
.cd-kpi { background: var(--bg2); border-radius: var(--r-sm); padding: 9px 10px; }
.cd-kl { font-size: var(--fs-body); color: var(--t3); margin-bottom: 3px; }
.cd-kv { font-size: var(--fs-body); font-weight: 600; line-height: 1.3; }
.irow { display: flex; gap: 8px; padding: 6px 0; border-bottom: 0.5px solid var(--bd); font-size: var(--fs-body); }
.irow:last-child { border-bottom: none; }
.ilbl { color: var(--t3); min-width: 70px; flex-shrink: 0; font-size: var(--fs-body); }
.ival { color: var(--t1); flex: 1; line-height: 1.5; }
.upd-item { display: flex; gap: 8px; padding: 6px 0; border-bottom: 0.5px solid var(--bd); font-size: var(--fs-body); }
.upd-item:last-child { border-bottom: none; }
.upd-n { color: var(--t3); min-width: 22px; font-size: var(--fs-body); padding-top: 1px; }

/* activity */
.act-hdr { display: grid; grid-template-columns: 70px 1fr 55px; gap: 5px; font-size: var(--fs-body); color: var(--t3); padding-bottom: 5px; border-bottom: 0.5px solid var(--bd); }
.act-row { display: grid; grid-template-columns: 70px 1fr 55px; gap: 5px; align-items: center; padding: 6px 0; border-bottom: 0.5px solid var(--bd); font-size: var(--fs-body); cursor: pointer; }
.act-row:last-child { border-bottom: none; }
.act-row:hover { background: var(--bg2); }

/* chips */
.chips { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 11px; font-size: var(--fs-body); border-radius: 8px; border: 0.5px solid var(--bd2); background: transparent; cursor: pointer; color: var(--t2); font-family: inherit; white-space: nowrap; transition: background .15s ease, border-color .15s ease, color .15s ease; }
.chip:hover { border-color: var(--blue); color: var(--t1); }
.chip.on { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 3px 10px rgba(124,58,237,.32); }
.cpill { font-size: var(--fs-body); padding: 1px 4px; border-radius: 5px; background: var(--bg2); color: var(--t2); }
.chip.on .cpill { background: rgba(255, 255, 255, 0.2); color: inherit; }
.bdg { font-size: var(--fs-body); font-weight: 500; padding: 2px 6px; border-radius: 5px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 2px; }

/* sort/search */
.sbtn { font-size: var(--fs-body); padding: 3px 9px; border-radius: 6px; border: 0.5px solid var(--bd2); background: transparent; color: var(--t2); cursor: pointer; font-family: inherit; }
.sbtn.on { background: var(--bg2); color: var(--t1); font-weight: 500; }
input[type="text"], input[type="date"], input[type="month"], input[type="number"], select, textarea { background: var(--bg2); border: 0.5px solid var(--bd2); border-radius: 8px; padding: 6px 9px; font-size: var(--fs-body); color: var(--t1); font-family: inherit; outline: none; transition: border-color .15s ease, box-shadow .15s ease; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-bg); }
select { border-radius: 8px; cursor: pointer; }
.bbtn { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-body); color: var(--t2); cursor: pointer; padding: 4px 10px; border-radius: 7px; border: 0.5px solid var(--bd); background: var(--bg2); font-family: inherit; }
.av { width: 32px; height: 32px; border-radius: 50%; background: var(--blue-bg); color: var(--blue-dk); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: var(--fs-body); flex-shrink: 0; }

/* pagination */
.pg-btn { font-size: var(--fs-body); padding: 6px 14px; border-radius: 8px; border: 0.5px solid var(--bd2); background: var(--bg2); color: var(--t2); cursor: pointer; font-family: inherit; }
.pg-btn.primary { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 3px 10px rgba(124,58,237,.32); }

/* date filter bar */
.df-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; background: var(--bg); border: 0.5px solid var(--bd); border-radius: var(--r-sm); padding: 8px 11px; margin-bottom: 9px; box-shadow: var(--shadow); }
.df-btn { font-size: var(--fs-body); padding: 4px 10px; border-radius: 6px; border: 0.5px solid var(--bd2); background: transparent; color: var(--t2); cursor: pointer; font-family: inherit; white-space: nowrap; transition: background .15s ease, border-color .15s ease, color .15s ease; }
.df-btn:hover { border-color: var(--blue); color: var(--t1); }
.df-btn.on { background: var(--blue); border-color: var(--blue); color:var(--on-blue); font-weight: 500; }

/* lead type bar */
.lt-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: var(--fs-body); }
.lt-bar { height: 5px; border-radius: 3px; min-width: 2px; }

/* ── ความนุ่มนวลรวม (polish) ── */
.srow, .hlrow, .lfrow, .act-row, .prow, .pg-btn, .sbtn, .bbtn, .av { transition: background .15s ease, transform .12s ease, box-shadow .15s ease, border-color .15s ease; }
.pg-btn:hover { border-color: var(--blue); color: var(--t1); }
.pg-btn:active, .sbtn:active { transform: scale(.97); }
.team-card { transition: transform .18s ease, box-shadow .18s ease; }
.team-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-h); }
.pbf, .dilfill, .lt-bar { transition: width .5s cubic-bezier(.22,.61,.36,1); }
.av { box-shadow: var(--shadow); }

/* progress bars — ไล่สีนุ่มขึ้น */
.pbf { background-image: linear-gradient(90deg, rgba(255,255,255,.18), rgba(255,255,255,0)); }

/* scrollbar บางๆ ให้เข้าธีม */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bd2); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--t3); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ลด motion สำหรับคนตั้งค่า reduce-motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01ms !important; }
}

@media (max-width: 640px) {
  .g3 { grid-template-columns: 1fr; }
  .g2 { grid-template-columns: 1fr; }
  .shdr, .srow { grid-template-columns: 78px 34px 42px 1fr; }
  .shdr span:nth-child(n + 5), .srow span:nth-child(n + 5), .srow div:nth-child(n + 5) { display: none; }
  /* ตารางที่เลื่อนแนวนอนได้ (ห่อด้วย .hscroll เช่น ตารางคะแนน 12 คอลัมน์) — ไม่ยุบ/ไม่ซ่อนคอลัมน์ ให้เลื่อนดูครบแทน */
  .hscroll .shdr, .hscroll .srow { grid-template-columns: unset; }
  .hscroll .shdr span:nth-child(n + 5), .hscroll .srow span:nth-child(n + 5), .hscroll .srow div:nth-child(n + 5) { display: revert; }
  .cd-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .act-hdr, .act-row { grid-template-columns: 64px 1fr 42px; }
}

/* ★ 19 ก.ย.69 — ป้ายทีมในคอลัมน์ "ทีม" ของตาราง (teamCell ใน index.html)
   ขนาดตายตัว → ทุกแถวตรงกัน · เดิมป้ายต่อท้ายชื่อ ทำให้ความยาวแต่ละแถวไม่เท่ากัน · สีประจำทีมมาจาก inline style */
.tm-tag { display: inline-block; min-width: 34px; padding: 1px 8px; border-radius: 6px;
  color: #fff; font-size: var(--fs-body); font-weight: 700; line-height: 1.5; text-align: center; }
