/* BeachCity Admin Panel — ธีมเดียวกับ mockup (ธีมมืด · IBM Plex Sans Thai · สีหลัก teal) */
:root {
  --bg: #0F141C;
  --side: #121924;
  --surface: #161D28;
  --raised: #1D2533;
  --hover: #1A2230;
  --line: #222B3A;
  --line2: #2A3446;
  --row: #1C2432;
  --text: #E8ECF3;
  --sub: #B3BCCB;
  --muted: #8D97A8;
  --accent: #3CC8C0;
  --accent-soft: rgba(60, 200, 192, .13);
  --link: #5FD6CF;
  --good: #0ca30c;
  --warn: #fab219;
  --serious: #ec835a;
  --bad: #d03b3b;
  --bad-text: #F28B8B;
  color-scheme: dark; /* ช่องติ๊ก / dropdown / scrollbar ของเบราว์เซอร์เป็นสีมืดตามธีม */
}

* { box-sizing: border-box; }
/* scrollbar บางสีมืดตามธีม (Chrome / Edge 121+ / Firefox ใช้ 2 บรรทัดนี้ · Chrome รุ่นเก่าใช้ ::-webkit-scrollbar ด้านล่าง) */
* { scrollbar-width: thin; scrollbar-color: #2E3A50 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: #2E3A50; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #3D4B66; }
[hidden] { display: none !important; } /* กันคลาสที่ตั้ง display ไว้ (เช่น .btn / .chat) ไปทับ attribute hidden */
body { margin: 0; background: var(--bg); }
a { color: var(--link); text-decoration: none; }
a:hover { color: #A5ECE7; }
button, input, select, textarea { font: inherit; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent) !important; box-shadow: 0 0 0 3px rgba(60, 200, 192, .25); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { font-family: "IBM Plex Sans Thai", system-ui, sans-serif; color: var(--text); background: var(--bg); display: flex; flex-wrap: wrap; align-items: stretch; min-height: 100vh; font-size: 15px; line-height: 1.5; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* เมนูด้านข้าง */
.side { flex: 1 1 236px; background: var(--side); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; color: var(--text); }
.brand:hover { color: var(--text); }
.mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #0B1418; font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center; flex: none; }
.logo { width: 48px; height: 48px; object-fit: contain; flex: none; }
.logo-lg { width: 168px; height: 168px; object-fit: contain; margin-bottom: 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nl { font-size: 12px; color: var(--muted); padding: 12px 12px 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 0 12px; min-height: 44px; border-radius: 10px; color: var(--sub); }
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--text); font-weight: 500; }
.nav a.on .ico { color: var(--accent); }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.me form { margin: 0; }
.me button, .me a.ib { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; color: var(--sub); background: transparent; border: 0; cursor: pointer; }
.me button:hover, .me a.ib:hover { background: var(--hover); color: var(--text); }
.av { width: 36px; height: 36px; border-radius: 50%; background: #243044; color: var(--text); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex: none; }

/* แถบบน + ค้นหา */
.main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 28px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1 1 320px; max-width: 600px; }
.search input { width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--line2); background: var(--surface); color: var(--text); padding: 0 14px 0 44px; font-size: 15px; }
.search input::placeholder { color: var(--muted); }
.search .si { position: absolute; left: 14px; top: 13px; color: var(--muted); }
.drop { position: absolute; left: 0; right: 0; top: 52px; background: var(--surface); border: 1px solid var(--line2); border-radius: 12px; padding: 6px; z-index: 20; box-shadow: 0 12px 32px rgba(0, 0, 0, .45); max-height: 70vh; overflow: auto; }
.drop a { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; color: var(--text); min-height: 48px; }
.drop a:hover, .drop a.on { background: var(--raised); color: var(--text); }
.drop .empty { padding: 12px; color: var(--muted); }

/* เนื้อหาขยายเต็มความกว้างจอ (จอกว้างไม่เหลือที่ว่างด้านขวา) */
.content { padding: 24px 28px 64px; display: flex; flex-direction: column; gap: 20px; width: 100%; }
.content.wrap { flex-direction: row; flex-wrap: wrap; align-items: flex-start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; min-width: 0; }
.ch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.ch h2 { margin: 0; font-size: 16px; font-weight: 600; }
.ch h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--sub); }
h1 { margin: 0; font-size: 24px; font-weight: 600; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.crumb { font-size: 14px; color: var(--muted); }
.muted { color: var(--muted); }
.sub { color: var(--sub); }
.small { font-size: 13px; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 13px; background: var(--raised); color: var(--sub); border: 1px solid var(--line2); white-space: nowrap; }
a.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.role { border-color: var(--accent); color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #5B6577; flex: none; display: inline-block; }
.dot.on { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--serious); }
.tag { font-size: 12px; color: var(--sub); background: var(--raised); border: 1px solid var(--line2); border-radius: 6px; padding: 1px 8px; flex: none; min-width: 58px; text-align: center; white-space: nowrap; }
.sw-box { width: 10px; height: 10px; border-radius: 2px; flex: none; display: inline-block; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line2); background: var(--raised); color: var(--text); font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #243044; color: var(--text); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #0B1418; font-weight: 600; }
.btn.pri:hover { background: var(--link); color: #0B1418; }
.btn.bad { background: transparent; border-color: #6B3036; color: var(--bad-text); }
.btn.bad:hover { background: #2A1A1F; color: #F8B4B4; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.ib { width: 44px; height: 44px; padding: 0; border-radius: 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ib:hover { background: #243044; color: var(--bad-text); }
.cp { width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.cp:hover { background: #243044; color: var(--text); }

.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line2); border-radius: 12px; padding: 3px; gap: 2px; background: var(--side); }
.seg a, .seg button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--sub); font-size: 14px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; }
.seg .on { background: #243044; color: var(--text); font-weight: 500; }
.fchip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line2); background: var(--side); color: var(--sub); font-size: 14px; cursor: pointer; white-space: nowrap; }
.fchip:hover { color: var(--text); }
.fchip.on { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

/* ตาราง */
.tbox { overflow-x: auto; }
.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 9px 12px; border-bottom: 1px solid var(--row); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: var(--hover); }
.t td.nw, .t th.nw { white-space: nowrap; }
/* หัวคอลัมน์ตัวเลขชิดขวาตรงกับข้อมูล (.t th ข้างบนชนะ .r เพราะ specificity สูงกว่า) */
.t th.r, .t td.r { text-align: right; }
/* หัวคอลัมน์กดเรียง : ↕ จาง ๆ = กดได้ · ▲ / ▼ สีหลัก = เรียงคอลัมน์นี้อยู่ */
.thsort { display: inline-flex; align-items: center; gap: 5px; padding: 2px 0; margin: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; white-space: nowrap; text-decoration: none; border-radius: 4px; }
.thsort:hover { color: var(--text); }
.thsort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.thsort .arr { display: inline-block; width: 10px; font-size: 10px; line-height: 1; opacity: .4; }
.thsort .arr::after { content: '↕'; }
.thsort:hover .arr { opacity: .8; }
th[aria-sort] .thsort { color: var(--text); }
th[aria-sort] .thsort .arr { opacity: 1; color: var(--accent); }
th[aria-sort="ascending"] .thsort .arr::after { content: '▲'; }
th[aria-sort="descending"] .thsort .arr::after { content: '▼'; }
.r { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--good); }

/* ตัวเลขสรุป */
.grid-k { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.k .kl { font-size: 13px; color: var(--muted); }
.k .kv { font-size: 26px; font-weight: 600; margin-top: 2px; letter-spacing: -.01em; }
.k .ks { font-size: 13px; color: var(--sub); margin-top: 2px; }
a.k { color: var(--text); }
a.k:hover { border-color: var(--line2); color: var(--text); }
.cols { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* ภาพรวม */
.fi { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--row); align-items: baseline; }
.fi:last-child { border-bottom: 0; }
.bar-row { display: grid; grid-template-columns: 132px minmax(0, 1fr) 84px; gap: 12px; align-items: center; padding: 7px 4px; border-radius: 8px; color: var(--text); }
.bar-row:hover { background: var(--hover); color: var(--text); }
.bar { display: block; height: 12px; background: #3987e5; border-radius: 0 4px 4px 0; }
.alert { display: flex; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--hover); border: 1px solid var(--line2); }
.alert .ico { margin-top: 3px; }
.lrow { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 6px; border-radius: 8px; color: var(--text); min-height: 44px; }
.lrow:hover { background: var(--hover); color: var(--text); }

/* แบนเนอร์สถานะเซิร์ฟ */
.banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; font-size: 14px; border: 1px solid var(--line2); background: var(--hover); }
.banner.good { background: rgba(12, 163, 12, .08); border-color: rgba(12, 163, 12, .35); }
.banner.warn { background: rgba(250, 178, 25, .08); border-color: rgba(250, 178, 25, .4); }

/* โปรไฟล์ */
.hero { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.bigav { width: 72px; height: 72px; border-radius: 18px; background: #243044; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 600; flex: none; }
.ids { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 4px 18px; margin-top: 12px; }
.idr { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 32px; }
.idr .k { color: var(--muted); font-size: 13px; width: 70px; flex: none; }
.idr .v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: -6px -4px 16px; }
.tab { border-bottom: 2px solid transparent; color: var(--sub); font-size: 14px; padding: 0 14px; min-height: 46px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.tab .n { font-size: 12px; color: var(--sub); background: var(--raised); border-radius: 999px; padding: 0 7px; line-height: 20px; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
/* การ์ดไอเท็ม : รูป | ชื่อ (2 บรรทัด) + รหัส | จำนวน (บน) + ปุ่มลบ (ล่าง) — ชื่อได้ความกว้างเกือบทั้งการ์ด */
.it { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 10px; row-gap: 2px; align-items: center; padding: 9px 8px 9px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--side); min-width: 0; min-height: 70px; }
.it:hover { border-color: #2F3A4F; }
.it img { grid-column: 1; grid-row: 1 / 3; width: 48px; height: 48px; border-radius: 10px; background: var(--raised); object-fit: contain; }
.it .nm { grid-column: 2; grid-row: 1 / 3; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.it .nm > :first-child { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; overflow-wrap: anywhere; font-weight: 500; }
.it .nm > :not(:first-child) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.it .cnt { grid-column: 3; grid-row: 1; justify-self: end; align-self: end; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; padding: 0 6px; }
.it .ib { grid-column: 3; grid-row: 2; justify-self: end; align-self: start; width: 32px; height: 32px; border-radius: 8px; }
.it .ib .ico { width: 16px; height: 16px; }
.it:not(:has(.ib)) .cnt { grid-row: 1 / 3; align-self: center; }
/* ลบของแล้วเลขเปลี่ยน → ขอบการ์ดกะพริบสีหลักให้เห็นว่าอัปเดตแล้ว */
.it.flash { animation: it-flash 1.2s ease-out; }
@keyframes it-flash { 0%, 30% { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); } 100% { border-color: var(--line); box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { .it.flash { animation: none; } }
.ask-input #askNote { height: 42px; font-size: 14px; }
/* แถบค้นหา + เรียงลำดับเหนือการ์ดไอเท็ม : สรุป (ซ้าย) | ช่องค้นหา | ตัวเลือกเรียง */
.itools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-bottom: 12px; }
.itools .its-sum { flex: 1 1 260px; min-width: 0; }
.itools .its-sum .hl { color: var(--accent); font-weight: 500; }
.itools .search { flex: 0 1 340px; max-width: none; }
.itools .search input { height: 40px; font-size: 14px; padding-left: 40px; }
.itools .search .si { left: 12px; top: 11px; }
.itools select.sel { height: 40px; flex: 0 0 auto; }
.its-empty { padding: 18px 4px; }
/* ชื่อรุ่นรถที่กดได้ (ไปหน้ารถรุ่นนี้ทั้งหมด) — สีตัวอักษรปกติ เส้นใต้จุด ๆ ให้รู้ว่ากดได้ */
a.mlink { color: var(--text); text-decoration: underline dotted var(--muted); text-underline-offset: 4px; }
a.mlink:hover { color: var(--accent); text-decoration-color: var(--accent); }
/* รูปรถ (/img/vehicles/:รุ่น — custom ของการาจ → docs.fivem.net → ไอคอนรถ) : sm = ในตาราง · lg = หัวการ์ด */
.vimg { display: block; object-fit: contain; flex: none; }
.vimg.sm { width: 64px; height: 32px; }
.vimg.lg { width: 220px; max-width: 100%; height: 110px; padding: 6px; border-radius: 14px; background: radial-gradient(ellipse at 50% 70%, #1E2837 0%, var(--side) 70%); border: 1px solid var(--line); }
.vcell { display: inline-flex; align-items: center; gap: 12px; }
/* ช่อง "ท้ายรถ" ในรายการรถ : มีของ = ป้ายสีเขียวอมฟ้า · ว่าง = ตัวหนังสือจาง */
a.tk { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; background: var(--accent-soft); color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
a.tk .ico { color: var(--accent); }
a.tk:hover { box-shadow: inset 0 0 0 1px var(--accent); }
@media (max-width: 640px) { .itools .search { flex: 1 1 100%; } .itools select.sel { flex: 1 1 100%; } }
.two { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.two > * { flex: 1 1 340px; min-width: 0; }
.tl { display: flex; flex-direction: column; gap: 10px; }
.tli { display: flex; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--side); flex-wrap: wrap; align-items: flex-start; }
.badge { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.b-yellow { background: #fab219; color: #0B1418; }
.b-orange { background: #ec835a; color: #0B1418; }
.b-red, .b-ban { background: #d03b3b; color: #fff; }
.b-black { background: #0B0F15; color: #fff; border: 1px solid var(--line2); }
.b-off { background: var(--raised); color: var(--muted); }
.lock { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; border: 1px dashed var(--line2); font-size: 14px; color: var(--sub); margin-bottom: 14px; }

/* ฟอร์ม / แผงคำสั่ง */
.panel { border: 1px solid var(--line2); background: var(--side); border-radius: 12px; padding: 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 14px; }
.panel[hidden] { display: none; }
.panel .title { flex: 1 1 100%; font-weight: 600; }
/* ช่องฟอร์ม : เรียงลงในกล่องแนวตั้ง (ล็อกอิน / ตั้งรหัส) · ในแผงคำสั่ง (.panel แนวนอน) ค่อยขยายเต็มแถว */
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.panel .fld { flex: 1 1 180px; }
.panel .fld.narrow { flex: 0 1 150px; }
.fld label { font-size: 13px; color: var(--sub); }
.fld input, .fld select, .fld textarea, select.sel, input.inp { height: 44px; border-radius: 10px; border: 1px solid var(--line2); background: var(--surface); color: var(--text); padding: 0 12px; font-size: 14px; }
.chk { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; color: var(--sub); cursor: pointer; }
.chk input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

/* toast */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(460px, calc(100vw - 40px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--raised); border: 1px solid var(--line2); font-size: 14px; box-shadow: 0 10px 28px rgba(0, 0, 0, .45); font-family: "IBM Plex Sans Thai", system-ui, sans-serif; color: var(--text); }
.toast .dot { margin-top: 7px; }

/* modal (ย้ายบัญชี / wipe) */
.modal-bg { position: fixed; inset: 0; background: rgba(5, 8, 12, .72); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 40; overflow: auto; }
.modal-bg[hidden] { display: none; }
.modal { width: 100%; max-width: 820px; background: var(--surface); border: 1px solid var(--line2); border-radius: 16px; padding: 22px; font-family: "IBM Plex Sans Thai", system-ui, sans-serif; color: var(--text); font-size: 15px; line-height: 1.5; }
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.steps { font-size: 13px; color: var(--muted); }
.ck { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; margin-bottom: 8px; }
.ck .lbl { flex: none; min-width: 52px; font-size: 12px; font-weight: 600; border-radius: 6px; padding: 1px 8px; text-align: center; }
.lbl.ok { background: var(--good); color: #fff; }
.lbl.warn { background: var(--warn); color: #0B1418; }
.lbl.bad { background: var(--bad); color: #fff; }
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; margin: 10px 0; }
.swt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--side); color: var(--text); font-size: 14px; cursor: pointer; text-align: left; }
.swt:hover { border-color: #2F3A4F; }
.trk { width: 38px; height: 22px; border-radius: 999px; background: var(--line2); position: relative; flex: none; display: block; }
.knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); display: block; transition: left .12s; }
.swt.on .trk { background: var(--accent); }
.swt.on .knob { left: 19px; background: #0B1418; }
.swt[disabled] { opacity: .6; cursor: not-allowed; }
.mfoot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }

/* ไอเท็ม / แก๊ง (รายการทางซ้าย) */
.side-list { flex: 1 1 280px; max-width: 340px; }
.list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; max-height: 960px; overflow-y: auto; overflow-x: hidden; padding-right: 4px; }
.li .grow > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 10px; border-radius: 10px; color: var(--text); font-size: 14px; }
.li:hover { background: var(--hover); color: var(--text); }
.li.on { background: var(--accent-soft); }
.li img, .ic { width: 36px; height: 36px; border-radius: 9px; background: var(--raised); flex: none; object-fit: contain; }
.ic { border: 1px solid var(--line2); display: flex; align-items: center; justify-content: center; font-family: "IBM Plex Mono", monospace; font-size: 12px; font-weight: 600; color: var(--text); }
.bigic { width: 76px; height: 76px; border-radius: 18px; font-size: 22px; }
.stackbar { display: flex; gap: 2px; height: 20px; border-radius: 4px; overflow: hidden; margin: 6px 0 14px; background: var(--row); }
.stackbar span { display: block; height: 20px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.lg { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.meta > div { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.meta .kl { font-size: 12px; color: var(--muted); }
.meta .kv { font-size: 20px; font-weight: 600; }
.plate { display: inline-flex; align-items: center; height: 56px; padding: 0 18px; border-radius: 10px; background: #F3F5F8; color: #0B1418; font-family: "IBM Plex Mono", monospace; font-size: 26px; font-weight: 500; letter-spacing: .08em; border: 3px solid var(--line2); }
.meter { height: 8px; border-radius: 0 4px 4px 0; background: var(--row); margin-top: 6px; }
.meter span { display: block; height: 8px; border-radius: 0 4px 4px 0; background: #3987e5; }
/* ช่องสัดส่วน (หน้าไอเท็ม "ใครถืออยู่") : แถบยาวตาม % สีตามที่เก็บ + ตัวเลขชิดขวา */
.share { display: inline-flex; align-items: center; gap: 10px; justify-content: flex-end; }
.share > .muted { min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }
.share-bar { width: clamp(80px, 12vw, 220px); height: 8px; border-radius: 0 4px 4px 0; background: var(--row); overflow: hidden; }
.share-bar span { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.ev { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--row); align-items: baseline; }
.ev:last-child { border-bottom: 0; }
.pager { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 12px; }
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow: auto; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--side); }
.msg { max-width: 75%; align-self: flex-start; padding: 6px 10px; border-radius: 10px; background: var(--raised); font-size: 14px; overflow-wrap: anywhere; }
.msg.out { align-self: flex-end; background: rgba(60, 200, 192, .18); }
.msg .at { font-size: 11px; color: var(--muted); }

/* หน้าผู้เล่น : การ์ดสรุป */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.stat { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: var(--text); }
.stat:hover { border-color: #33405A; color: var(--text); }
.stat.on { border-color: var(--accent); background: rgba(60, 200, 192, .07); }
.stat-ic { width: 46px; height: 46px; border-radius: 12px; background: var(--raised); display: flex; align-items: center; justify-content: center; color: var(--sub); flex: none; }
.stat-ic .ico { width: 22px; height: 22px; }
.stat-ic.acc { color: var(--accent); background: rgba(60, 200, 192, .12); }
.stat-ic.good { background: rgba(12, 163, 12, .12); }
.stat-ic.warn { color: var(--warn); background: rgba(250, 178, 25, .12); }
.stat-ic.bad { color: var(--serious); background: rgba(236, 131, 90, .12); }
.stat-v { display: block; font-size: 26px; font-weight: 600; line-height: 1.15; }
.stat-l { display: block; font-size: 13px; color: var(--muted); }

/* หน้าผู้เล่น : ตาราง + แผงพรีวิวด้านขวา (เฉพาะจอกว้าง) */
.pl-wrap { display: flex; gap: 20px; align-items: flex-start; }
.pl-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.pv { flex: 0 0 420px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; padding: 0; }
@media (max-width: 1599px) { .pv { display: none; } }
.jobchips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.jchip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line2); background: var(--side); color: var(--sub); font-size: 13px; }
.jchip:hover { color: var(--text); border-color: #33405A; }
.jchip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.jchip.on { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.cbx { width: 18px; height: 18px; accent-color: var(--accent); vertical-align: middle; }
.ptable td { padding-top: 8px; padding-bottom: 8px; }
.prow { cursor: pointer; }
.prow:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.prow.sel td { background: var(--accent-soft) !important; }
.prow.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.pcell { display: inline-flex; align-items: center; gap: 12px; color: var(--text); min-width: 0; }
.pcell:hover { color: var(--text); }
.pcell:hover .nm { text-decoration: underline; }
.pav { position: relative; width: 40px; height: 40px; border-radius: 12px; background: #243044; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex: none; color: var(--text); }
.pav .st { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%; background: #5B6577; border: 2px solid var(--surface); }
.pav .st.on { background: var(--good); }
.pname { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; max-width: 360px; }
.pname > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pname .nm { color: var(--link); font-weight: 500; }
.newtag { display: inline-block; font-size: 11px; font-weight: 600; color: #0B1418; background: var(--accent); border-radius: 5px; padding: 0 6px; margin-left: 4px; vertical-align: 1px; }
.gtag { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border-radius: 7px; background: var(--raised); border: 1px solid var(--line2); font-size: 12px; font-weight: 600; color: var(--text); font-family: "IBM Plex Mono", monospace; }
.gtag:hover { color: var(--text); border-color: #33405A; }
.gtag i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* แผงพรีวิว */
.pv-head { padding: 20px; border-bottom: 1px solid var(--line); display: flex; gap: 14px; align-items: center; }
.pv-head .bigav { width: 64px; height: 64px; font-size: 22px; position: relative; }
.pv-head .bigav .st { position: absolute; right: -3px; bottom: -3px; width: 16px; height: 16px; border-radius: 50%; background: #5B6577; border: 3px solid var(--surface); }
.pv-head .bigav .st.on { background: var(--good); }
.pv-sec { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.pv-sec:last-child { border-bottom: 0; }
.pv-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.pv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pv-grid > div { background: var(--side); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.pv-grid .kl { display: block; font-size: 12px; color: var(--muted); }
.pv-grid b { display: block; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-items { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.pv-item { background: var(--side); border: 1px solid var(--line); border-radius: 10px; padding: 6px 4px; text-align: center; font-size: 12px; color: var(--text); min-width: 0; }
.pv-item:hover { border-color: #33405A; color: var(--text); }
.pv-item img { width: 40px; height: 40px; object-fit: contain; display: block; margin: 0 auto 2px; }
.pv-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-kv { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 6px 10px; font-size: 13px; margin: 0; }
.pv-kv dt { color: var(--muted); }
.pv-kv dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-acts { padding: 16px 20px; display: flex; flex-wrap: wrap; gap: 8px; }

/* ตู้เซฟ : จุดออนไลน์บนไอคอนในรายการ */
.vdot { position: absolute; right: -3px; bottom: -3px; width: 11px; height: 11px; border-radius: 50%; background: var(--good); border: 2px solid var(--surface); }
.stat-ic { font-weight: 700; font-size: 18px; }

/* กล่องถามยืนยัน / ถามจำนวน (แทน confirm / prompt ของเบราว์เซอร์) */
.ask-bg { z-index: 60; align-items: center; padding: 16px; }
.modal.ask { max-width: 460px; padding: 20px 22px; box-shadow: 0 24px 64px rgba(0, 0, 0, .55); }
.ask-head { display: flex; gap: 14px; align-items: flex-start; }
.ask-head h2 { margin: 2px 0 4px; font-size: 17px; }
.ask-head .sub { font-size: 14px; }
.ask-ic { width: 42px; height: 42px; border-radius: 12px; background: rgba(60, 200, 192, .12); color: var(--accent); display: flex; align-items: center; justify-content: center; flex: none; }
.ask-ic .ico { width: 20px; height: 20px; }
.ask-ic.bad { background: rgba(208, 59, 59, .14); color: var(--bad-text); }
.ask-input { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.ask-input .inp { width: 100%; height: 46px; font-size: 16px; }
.ask-quick { gap: 6px; }
.ask-err { color: var(--bad-text); font-size: 13px; }
button.jchip { cursor: pointer; font: inherit; font-size: 13px; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
.btn.danger:hover { background: #E04848; border-color: #E04848; color: #fff; }

/* Wipe ทั้งเซิร์ฟ : หมวดตาราง */
.wa-cat { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--side); margin-bottom: 8px; }
.wa-cat details { flex: 1; min-width: 0; }
.wa-cat summary { display: flex; gap: 10px; align-items: center; min-height: 28px; cursor: pointer; }
.wa-cat summary::marker { color: var(--muted); }
.wa-cat input[type=checkbox] { width: 20px; height: 20px; margin: 4px 0 0; accent-color: var(--accent); flex: none; }

/* หน้าเข้าสู่ระบบ */
.login-wrap { font-family: "IBM Plex Sans Thai", system-ui, sans-serif; color: var(--text); background: var(--bg); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 48px 16px; font-size: 15px; line-height: 1.5; }
.login-box { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px; display: flex; flex-direction: column; gap: 16px; }
.err { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: #2A1A1F; border: 1px solid #6B3036; color: #F8C4C4; font-size: 14px; }

@media (max-width: 820px) {
  .top, .content { padding-left: 16px; padding-right: 16px; }
  .side-list { max-width: none; }
  .bar-row { grid-template-columns: 100px minmax(0, 1fr) 70px; }
  /* จอเล็ก : เมนูด้านข้างกลายเป็นแถบบน (โลโก้ + ปุ่มบัญชี แล้วเมนูเลื่อนแนวนอน) */
  .side { flex: 1 1 100%; min-width: 0; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { flex: 1 1 auto; padding: 0; order: 1; }
  .logo { width: 40px; height: 40px; }
  .me { margin-top: 0; padding: 0; border: 0; gap: 4px; order: 2; }
  .nav { order: 3; }
  .me .av, .me > div { display: none; }
  .nav { flex: 1 1 100%; min-width: 0; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 2px; }
  .nl { display: none; }
  .nav a { white-space: nowrap; flex: none; min-height: 40px; padding: 0 12px; }
}

/* ---------------------------------------------------------------------
   แผนที่ผู้เล่นสด (/map) : แผนที่ซ้าย (สูงเต็มจอ) | รายชื่อขวา · จอแคบ = ซ้อนกัน
   --------------------------------------------------------------------- */
.content.mapwrap { flex-direction: row; flex-wrap: wrap; align-items: stretch; padding-bottom: 24px; }
.mappane { flex: 999 1 560px; min-width: 0; padding: 0; overflow: hidden; display: flex; flex-direction: column; height: calc(100vh - 122px); min-height: 520px; }
.mapbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.mapbar .chk { min-height: 38px; }
#lmap { flex: 1 1 auto; min-height: 0; }
.mapside { flex: 1 1 300px; max-width: 400px; display: flex; flex-direction: column; gap: 12px; height: calc(100vh - 122px); min-height: 520px; }
.mlist { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0 -10px; padding: 0 4px; }
.mrow { display: grid; grid-template-columns: 48px minmax(0, 1fr) 12px; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 6px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.mrow:hover { background: var(--hover); }
.mrow.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.mrow.nopos { opacity: .55; }
.mrow .mid { font-family: "IBM Plex Mono", monospace; font-size: 13px; color: var(--accent); background: var(--raised); border-radius: 8px; text-align: center; padding: 3px 0; }
.mrow .mnm { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.mrow .mnm > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .mst { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.mappane .leaflet-container { background: #173d66; font: inherit; } /* สีทะเล (leaflet.css โหลดทีหลังเลยต้องเจาะจงกว่า) */
.leaflet-control-zoom a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--line2) !important; width: 36px !important; height: 36px !important; line-height: 34px !important; }
.leaflet-control-zoom a:hover { background: var(--raised) !important; }
.leaflet-bar { border: 1px solid var(--line2) !important; box-shadow: 0 6px 18px rgba(0, 0, 0, .35) !important; }
.mcoord, .mlegend { background: rgba(15, 20, 28, .86); color: var(--text); border: 1px solid var(--line2); border-radius: 10px; padding: 6px 10px; font-size: 12px; }
.mcoord { font-family: "IBM Plex Mono", monospace; white-space: pre; }
.mlegend { display: flex; flex-direction: column; gap: 3px; }
.mlegend span { display: flex; align-items: center; gap: 8px; }
.mlegend i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #0b1220; flex: none; }
.mlegend i.hollow { border: 2px dashed #94a3b8; background: transparent; }
.mpop .leaflet-popup-content-wrapper, .mpop .leaflet-popup-tip { background: var(--surface); color: var(--text); border: 1px solid var(--line2); box-shadow: 0 12px 32px rgba(0, 0, 0, .5); }
.mpop .leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.45; min-width: 240px; }
.mpop a.leaflet-popup-close-button { color: var(--sub); }
.mp-h { font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.mp-g { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin-bottom: 10px; }
.mp-g > span { color: var(--muted); }
.mp-g > b { font-weight: 500; }
.mp-a { display: flex; flex-wrap: wrap; gap: 6px; }
.mpop .btn.sm { min-height: 32px; font-size: 12px; padding: 0 10px; }
.leaflet-tooltip.mtip, .leaflet-tooltip.mlabel { background: rgba(15, 20, 28, .9); color: var(--text); border: 1px solid var(--line2); border-radius: 6px; box-shadow: none; font-size: 12px; padding: 1px 6px; }
.leaflet-tooltip.mlabel b { color: var(--accent); font-weight: 500; margin-left: 2px; }
.leaflet-tooltip.mtip::before, .leaflet-tooltip.mlabel::before { display: none; }
/* ปิดเส้นรอยต่อระหว่าง tile ตอนซูมไม่เต็มขั้น (ปัญหาที่รู้กันของ Leaflet บน Chrome / Edge) */
.mappane .leaflet-tile { mix-blend-mode: plus-lighter; }
@media (max-width: 900px) {
  .mappane, .mapside { height: auto; min-height: 0; }
  #lmap { height: 62vh; }
  .mapside { max-width: none; }
  .mlist { max-height: 60vh; }
  .mlegend { display: none; }
}