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

/* คลาสที่ตั้ง display: flex/grid จะทับ attribute hidden ของ HTML ทำให้ซ่อนไม่ลง
   (เช่น .filterbar, .share-player-pick) — บังคับให้ hidden ชนะเสมอ */
[hidden] {
  display: none !important;
}

body {
  font-family: -apple-system, "Segoe UI", "Sarabun", sans-serif;
  background: #0f1115;
  color: #e6e6e6;
  line-height: 1.6;
}

header {
  padding: 24px;
  text-align: center;
  background: linear-gradient(135deg, #1a1d24, #11131a);
  border-bottom: 1px solid #262a33;
}

header h1 {
  font-size: 1.7rem;
}

header p {
  color: #9aa0ac;
  font-size: 0.9rem;
}

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 20px auto 0;
  padding: 0 24px;
}

.toolbar label {
  color: #9aa0ac;
  font-size: 0.9rem;
}

select,
button {
  font-size: 0.9rem;
  border-radius: 8px;
  padding: 8px 14px;
}

select {
  background: #1a1d24;
  color: #e6e6e6;
  border: 1px solid #2e333d;
}

button {
  background: #e63946;
  color: #fff;
  border: none;
  cursor: pointer;
}

button:hover {
  background: #d62836;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status {
  color: #9aa0ac;
  font-size: 0.85rem;
}

/* ---- Combobox เลือกผู้เล่น (พิมพ์ค้นหาได้) ---- */
.combo {
  position: relative;
}

.combo-input {
  background: #1a1d24;
  color: #e6e6e6;
  border: 1px solid #2e333d;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  min-width: 240px;
}

.combo-input:focus {
  outline: none;
  border-color: #e63946;
}

.combo-list {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
  list-style: none;
  background: #1a1d24;
  border: 1px solid #2e333d;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.combo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  font-size: 0.88rem;
  cursor: pointer;
}

.combo-item.selected {
  color: #ff8b95;
}

.combo-item.active,
.combo-item:hover {
  background: #262a33;
}

.combo-tags {
  color: #9aa0ac;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
}

.combo-empty {
  padding: 12px;
  color: #9aa0ac;
  font-size: 0.85rem;
  text-align: center;
}

/* ---- แถบตัวกรองช่วงเวลา ---- */
.filterbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 12px auto 0;
  padding: 0 24px;
}

.filterbar label,
.filterbar .sep {
  color: #9aa0ac;
  font-size: 0.9rem;
}

input[type='datetime-local'] {
  background: #1a1d24;
  color: #e6e6e6;
  border: 1px solid #2e333d;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.88rem;
  color-scheme: dark;
}

/* ปุ่มลัดเลือกช่วงวัน (วันนี้ / 3 วัน / 7 วันก่อนหน้า) */
.preset-group {
  display: flex;
  gap: 4px;
  background: #11131a;
  border: 1px solid #2e333d;
  border-radius: 9px;
  padding: 3px;
}

.preset-btn {
  background: transparent;
  color: #9aa0ac;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 0.85rem;
}

.preset-btn:hover {
  background: #1f232c;
}

.preset-btn.active {
  background: #e63946;
  color: #fff;
}

.btn-ghost {
  background: #262a33;
  color: #c4c8d0;
}

.btn-ghost:hover {
  background: #2e333d;
}

/* กฎ padding/radius ด้านบนจับเฉพาะ select กับ button — <a> ที่ใช้คลาสปุ่ม
   จึงไม่ได้กล่องปุ่มมาด้วย ต้องเติมให้ตรงนี้ */
a.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
}

/* ---- ปุ่มไปหน้าอัปโหลด CSV ---- */
/* padding 7px คู่กับ border 1px รวมแล้วสูงเท่าปุ่มอื่นที่ padding 8px ไม่มีขอบ */
.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  color: #c4c8d0;
  background: #1f232b;
  border: 1px solid #333944;
  transition: color 0.15s, background 0.15s, border-color 0.15s,
    box-shadow 0.15s, transform 0.15s;
}

.btn-upload:hover {
  color: #fff;
  background: #262b34;
  border-color: #e63946;
  box-shadow: 0 4px 14px rgba(230, 57, 70, 0.18);
  transform: translateY(-1px);
}

.btn-upload:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-upload:focus-visible {
  outline: 2px solid #e63946;
  outline-offset: 2px;
}

/* ลูกศรขยับขึ้นตอน hover — สื่อว่าเป็นการอัปโหลด */
.btn-upload .ico {
  font-size: 0.95rem;
  line-height: 1;
  transition: transform 0.15s;
}

.btn-upload:hover .ico {
  transform: translateY(-2px);
}

.status.error {
  color: #ff6b6b;
}

main {
  max-width: 1200px;
  margin: 20px auto 60px;
  padding: 0 24px;
}

/* ---- แถบช่วงวันที่ ---- */
.daterange {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  background: #1a1d24;
  border: 1px solid #262a33;
  border-radius: 10px;
  padding: 12px 18px;
  margin-bottom: 20px;
  font-size: 0.88rem;
}

.dr-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.muted {
  color: #7d828d;
}

/* ---- การ์ดสรุป ---- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: #1a1d24;
  border: 1px solid #262a33;
  border-radius: 12px;
  padding: 18px;
}

.card .label {
  color: #9aa0ac;
  font-size: 0.85rem;
}

.card .value {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 4px 0;
}

.card .sub {
  font-size: 0.8rem;
  color: #7d828d;
}

.pos {
  color: #4ade80;
}

.neg {
  color: #ff6b6b;
}

/* ---- Panel ---- */
.panel {
  background: #1a1d24;
  border: 1px solid #262a33;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}

.panel h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
}

/* หัว panel ที่มีปุ่ม toggle ด้านขวา */
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin-bottom: 0;
}

.grain-toggle {
  display: flex;
  gap: 4px;
  background: #11131a;
  border: 1px solid #2e333d;
  border-radius: 9px;
  padding: 3px;
}

.grain-btn {
  background: transparent;
  color: #9aa0ac;
  padding: 5px 14px;
  border-radius: 7px;
  font-size: 0.82rem;
}

.grain-btn:hover {
  background: #1f232c;
}

.grain-btn.active {
  background: #e63946;
  color: #fff;
}

.sub-h {
  font-size: 0.95rem;
  font-weight: 600;
  color: #c4c8d0;
  margin: 8px 0 10px;
  padding-left: 10px;
  border-left: 3px solid #e63946;
}

.behavior + .sub-h,
.table-note + .sub-h {
  margin-top: 22px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.chart-box {
  background: #0f1115;
  border: 1px solid #262a33;
  border-radius: 10px;
  padding: 14px;
  min-width: 0;
}

.chart-box.wide {
  grid-column: span 2;
}

.chart-box h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #c4c8d0;
  margin-bottom: 10px;
}

.chart-box canvas {
  max-height: 260px;
}

/* ---- พฤติกรรม ---- */
.behavior {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.behavior .item {
  background: #0f1115;
  border: 1px solid #262a33;
  border-radius: 8px;
  padding: 12px 14px;
}

.behavior .item .k {
  font-size: 0.82rem;
  color: #9aa0ac;
}

.behavior .item .v {
  font-size: 1.1rem;
  font-weight: 600;
}

.behavior .item .v .pair {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.behavior .item .v .pair span {
  font-size: 0.92rem;
}

/* ---- ปุ่มสลับประเภท LIVE/STEP ---- */
.type-toggle {
  display: flex;
  gap: 4px;
  background: #11131a;
  border: 1px solid #2e333d;
  border-radius: 9px;
  padding: 3px;
}

.type-btn {
  background: transparent;
  color: #9aa0ac;
  padding: 5px 18px;
  border-radius: 7px;
}

.type-btn:hover {
  background: #1f232c;
}

.type-btn.active {
  background: #e63946;
  color: #fff;
}

/* ---- empty state ---- */
.empty-state {
  background: #1a1d24;
  border: 1px solid #262a33;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  color: #9aa0ac;
  font-size: 0.95rem;
}

/* ---- ตาราง ---- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid #262a33;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  padding: 8px 12px;
  text-align: left;
  white-space: nowrap;
}

thead th {
  background: #11131a;
  color: #9aa0ac;
  position: sticky;
  top: 0;
}

tbody tr {
  border-top: 1px solid #20242c;
}

tbody tr:nth-child(even) {
  background: #15181f;
}

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tag-live {
  background: #1e3a5f;
  color: #7cc4ff;
}

.tag-step {
  background: #3f2d5c;
  color: #c79bff;
}

.tag-win {
  background: #14432a;
  color: #4ade80;
}

.tag-lose {
  background: #4a1f24;
  color: #ff6b6b;
}

.tag-void {
  background: #3a3a1f;
  color: #e8d44d;
}

/* คอลัมน์ "แทงฝั่ง" — แดง / น้ำเงิน / เสมอ */
.tag-red {
  background: #4a1f24;
  color: #ff8b94;
}

.tag-blue {
  background: #1e3a5f;
  color: #7cc4ff;
}

.tag-draw {
  background: #3a3a1f;
  color: #e8d44d;
}

.table-note {
  color: #7d828d;
  font-size: 0.8rem;
  margin-top: 8px;
}

/* ช่อง "รายการ / คู่มวย" ในตารางรายการเดิมพัน (LIVE) — ชื่อศึก + คู่มวยหลายบรรทัด
   ตั้ง white-space ที่ตัว div เอง จะได้ไม่กระทบ nowrap ของ td ช่องอื่น */
.match-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: normal;
  max-width: 300px;
  line-height: 1.45;
}

.match-name {
  color: #7d828d;
  font-size: 0.78rem;
}

.boxer-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.corner {
  flex: none;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 0.68rem;
  font-weight: 600;
}

.corner-red {
  background: #4a1f24;
  color: #ff8b94;
}

.corner-blue {
  background: #1e3a5f;
  color: #7cc4ff;
}

.boxer-name {
  color: #c4c8d0;
}

/* ฝั่งที่ผู้เล่นแทงในบิลนั้น — ใช้สีของมุมนั้น */
.boxer-line.bet .boxer-name {
  font-weight: 700;
}

.boxer-line.red.bet .boxer-name {
  color: #ff8b94;
}

.boxer-line.blue.bet .boxer-name {
  color: #7cc4ff;
}

/* ---- มุมมอง "รายวันตามคู่" ในตารางรายการเดิมพัน (LIVE) ---- */
.group-row {
  cursor: pointer;
  background: #171b23;
}

.group-row:hover {
  background: #1f242e;
}

.group-row.open {
  background: #1c2430;
}

.group-row td {
  white-space: normal;
  border-left: 3px solid #2e333d;
}

.group-row.open td {
  border-left-color: #e63946;
}

.group-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.group-caret {
  color: #9aa0ac;
  width: 12px;
}

.group-date {
  color: #e6e6e6;
  font-weight: 600;
}

.group-match {
  color: #9aa0ac;
}

.group-boxers {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #c4c8d0;
}

.group-boxers .corner {
  margin-left: 6px;
}

.group-boxers .corner:first-child {
  margin-left: 0;
}

.group-stat {
  margin-left: auto;
  color: #9aa0ac;
  font-size: 0.82rem;
}

.group-stat + .group-stat {
  margin-left: 0;
}

/* คอลัมน์ "ชุดบิลย่อย" — แสดงหลายบรรทัด (บรรทัดละ 4 รหัส ตัดด้วย <br>) */
#repeat-bills td:first-child {
  color: #c4c8d0;
  line-height: 1.7;
  white-space: normal;
}

/* ---- Pagination (ตารางรายการเดิมพัน) ---- */
#table-note {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pager-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: #9aa0ac;
  font-size: 0.85rem;
}
.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pager-size-select {
  background: #0f1115;
  border: 1px solid #2a3447;
  color: #fff;
  padding: 4px 6px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.85rem;
}
.pager-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.pager-page {
  background: #1a1d24;
  color: #c4c8d0;
  border: 1px solid #2a3447;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  min-width: 32px;
}
.pager-page:hover:not(:disabled):not(.active) {
  background: #232831;
  color: #fff;
}
.pager-page.active {
  background: #457b9d;
  color: #fff;
  border-color: #457b9d;
  cursor: default;
}
.pager-page:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pager-ellipsis {
  color: #7d828d;
  padding: 0 4px;
}

/* เน้นสีฝั่งนักมวยที่ผู้เล่นแทงในสเต็ป */
.side-red {
  color: #ff8b94;
  font-weight: 600;
}

.side-blue {
  color: #7cc4ff;
  font-weight: 600;
}

/* ---- Header actions (admin login state, ปุ่ม logout) ---- */
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  gap: 16px;
  text-align: left;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-actions a {
  color: inherit;
  text-decoration: none;
}

/* ---- ปุ่ม "สร้างลิงก์แชร์" ---- */
.btn-share {
  background: #4ade80;
  color: #0a0d12;
  font-weight: 600;
}
.btn-share:hover {
  background: #5beb8e;
}

/* ---- Share banner (บนหน้า share.html) ---- */
.share-banner {
  max-width: 1200px;
  margin: 20px auto 0;
  padding: 12px 18px;
  background: #1c2330;
  border: 1px solid #2a3447;
  border-left: 4px solid #4ade80;
  border-radius: 8px;
  color: #c4c8d0;
  font-size: 0.9rem;
}
.share-banner b {
  color: #fff;
}

/* แถบเลือกผู้เล่น + ปุ่มสลับ LIVE/STEP บนหน้า share */
.share-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 14px auto 0;
  padding: 0 24px;
}

.share-player-pick {
  display: flex;
  align-items: center;
  gap: 8px;
}

.share-player-pick label {
  color: #9aa0ac;
  font-size: 0.9rem;
}

/* ---- รายการติ๊กเลือกผู้เล่นใน modal สร้างลิงก์ ---- */
.picker-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 6px;
}

.picker-actions button {
  padding: 5px 12px;
  font-size: 0.8rem;
}

.picker-count {
  margin-left: auto;
  color: #9aa0ac;
  font-size: 0.85rem;
}

.picker-list {
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  background: #11131a;
  border: 1px solid #2e333d;
  border-radius: 8px;
}

.picker-item label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  font-size: 0.88rem;
  cursor: pointer;
}

.picker-item label:hover {
  background: #1f232c;
}

.picker-item input[type='checkbox'] {
  accent-color: #e63946;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.picker-name {
  flex: 1;
}

/* ---- Modal (share link) ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal[hidden] {
  display: none;
}
.modal-card {
  background: #1a1d24;
  border: 1px solid #262a33;
  border-radius: 12px;
  width: min(500px, 90vw);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #262a33;
}
.modal-head h2 {
  font-size: 1.1rem;
}
.modal-close {
  background: none;
  border: none;
  color: #9aa0ac;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
}
.modal-close:hover {
  color: #fff;
}
.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-info {
  padding: 10px 12px;
  background: #0f1115;
  border-radius: 6px;
  color: #c4c8d0;
  font-size: 0.9rem;
}
.modal-body label {
  font-size: 0.85rem;
  color: #9aa0ac;
  margin-top: 8px;
}
.modal-body select,
.modal-body input[type="text"] {
  background: #0f1115;
  border: 1px solid #2a3447;
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}
.btn-primary {
  background: #457b9d;
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
}
.btn-primary:hover {
  background: #5a92b5;
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.duration-row {
  display: flex;
  gap: 8px;
}
.duration-row input {
  flex: 1;
  width: 0;
}
.duration-row select {
  flex: 0 0 auto;
}

.share-url-row {
  display: flex;
  gap: 8px;
}
.share-url-row input {
  flex: 1;
}
.share-hint {
  color: #7d828d;
  font-size: 0.8rem;
}

/* ---- หน้า Login ---- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  background: #1a1d24;
  border: 1px solid #262a33;
  border-radius: 12px;
  padding: 32px;
  width: min(380px, 100%);
}
.login-card h1 {
  font-size: 1.5rem;
  text-align: center;
}
.login-sub {
  color: #9aa0ac;
  text-align: center;
  margin-bottom: 24px;
  font-size: 0.9rem;
}
.login-card form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login-card label {
  color: #9aa0ac;
  font-size: 0.85rem;
  margin-top: 8px;
}
.login-card input {
  background: #0f1115;
  border: 1px solid #2a3447;
  color: #fff;
  padding: 10px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
}
.login-card button {
  background: #457b9d;
  color: #fff;
  border: none;
  padding: 11px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 16px;
}
.login-card button:disabled {
  opacity: 0.6;
}
.login-error {
  color: #ff8b94;
  font-size: 0.85rem;
  margin-top: 8px;
}

@media (max-width: 720px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }
  .chart-box.wide {
    grid-column: span 1;
  }
  .header-inner {
    flex-direction: column;
    text-align: center;
  }
}

/* ---- หน้าอัปโหลด CSV ---- */
.upload-wrap {
  max-width: 1000px;
  margin: 24px auto;
  padding: 0 24px;
}

.dropzone {
  border: 2px dashed #2e333d;
  border-radius: 12px;
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: #e63946;
  background: #1d2028;
  outline: none;
}

.dropzone.dragover {
  border-color: #e63946;
  background: #24181b;
}

.dropzone.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dz-icon {
  font-size: 2rem;
}

.dz-title {
  font-weight: 600;
  margin-top: 6px;
}

.dz-sub {
  color: #7d828d;
  font-size: 0.85rem;
  margin-top: 2px;
}

/* แถวตั้งค่าใต้ dropzone (เวลาหน่วงระหว่างไฟล์) */
.upload-opts {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #262a33;
}

.upload-opts label {
  color: #9aa0ac;
  font-size: 0.9rem;
}

.queue-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* แถบความคืบหน้ารวมของคิว */
.progress-bar {
  height: 6px;
  background: #262a33;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: #e63946;
  border-radius: 999px;
  transition: width 0.25s;
}

#queue-table code {
  background: #11131a;
  border: 1px solid #262a33;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.8rem;
}

#queue-table .cell-name {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#queue-table .num {
  text-align: right;
  white-space: nowrap;
}

/* ข้อความอธิบายผลใต้ป้ายสถานะรายไฟล์ */
.row-msg {
  color: #7d828d;
  font-size: 0.78rem;
  margin-top: 2px;
  white-space: normal;
}

/* ---- หน้าเปรียบเทียบผู้เล่น ---- */
.compare-wrap {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 24px;
}

.compare-wrap .combo-input {
  width: 100%;
  margin-bottom: 10px;
}

/* แถบตัวเลือกใต้รายชื่อ (ประเภท + ช่วงเวลา + ปุ่มเปรียบเทียบ) */
.compare-opts {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #262a33;
}

.compare-opts label {
  color: #9aa0ac;
  font-size: 0.9rem;
}

.compare-opts input[type='datetime-local'] {
  background: #1a1d24;
  color: #e6e6e6;
  border: 1px solid #2e333d;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.85rem;
}

/* ตารางเทียบ: คอลัมน์แรกเป็นชื่อตัวชี้วัด ตรึงความกว้างไว้ให้อ่านง่าย */
#overview td:first-child,
#overview th:first-child {
  color: #9aa0ac;
  white-space: nowrap;
  min-width: 190px;
}

#overview th:not(:first-child) {
  color: #e6e6e6;
}

#overview td:not(:first-child) {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.picker-name {
  flex: 1;
}

/* ข้อความบอกโหมดที่กำลังเปรียบเทียบอยู่ (LIVE/STEP) บนหน้า compare */
.compare-mode-note {
  color: #7d828d;
  font-size: 0.82rem;
  margin: -8px 0 12px;
}

/* ข้อความสรุปหลังวางรายชื่อหลายคนในกล่องแชร์ */
.list-note {
  color: #7d828d;
  font-size: 0.8rem;
  margin-top: 6px;
}

.list-note.has-error {
  color: #e8d44d;
}

/* ตารางความทับซ้อนรายคู่บนหน้า compare */
#pairs th,
#pairs td {
  white-space: nowrap;
}

#pairs td:nth-child(n + 3) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#pairs td:last-child {
  text-align: center;
}

/* ============================================================
   หน้ารายงานราคามวย (/ratio.html)
   ใช้โทนและคอมโพเนนต์เดิมของโปรเจ็ค (.panel .card .pos .neg .tag .table-wrap)
   คลาสในนี้ขึ้นต้นด้วย rt- ทั้งหมด กันชนกับของเดิม
   ============================================================ */

/* หน้านี้ตารางกว้าง จึงใช้เต็มความกว้างจอแทน max-width 1200px ของ main */
.ratio-wrap {
  max-width: none;
  padding: 0 24px 80px;
  margin: 20px auto 0;
}

.rt-note {
  background: #1a1d24;
  border: 1px solid #262a33;
  border-left: 3px solid #7d828d;
  border-radius: 10px;
  padding: 11px 15px;
  color: #c4c8d0;
  font-size: 0.88rem;
  margin-bottom: 20px;
}
.rt-note:empty { display: none; }

.rt-verdict {
  border-left: 3px solid #e8d44d;
}
.rt-verdict h2 { margin-bottom: 6px; }
.rt-verdict p { color: #c4c8d0; font-size: 0.92rem; max-width: 80ch; }
.rt-verdict b { color: #e6e6e6; }

.rt-sec-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.rt-sec-head h2 { font-size: 1.15rem; }

.rt-desc {
  color: #c4c8d0;
  font-size: 0.88rem;
  margin: 6px 0 16px;
  max-width: 88ch;
}
.rt-desc b { color: #e6e6e6; }

.rt-duo { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; margin-bottom: 24px; }
.rt-trio { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 24px; }
.rt-duo > *, .rt-trio > * { min-width: 0; }

.rt-legend { display: flex; gap: 20px; align-items: center; margin-bottom: 14px; font-size: 0.85rem; color: #9aa0ac; }
.rt-legend span { display: inline-flex; align-items: center; gap: 7px; }
.rt-sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.rt-sw-pos { background: #4ade80; }
.rt-sw-neg { background: #ff6b6b; }

/* ---- กราฟแท่งแนวตั้ง (ไม่ใช้ Chart.js — แท่งธรรมดาพอ) ---- */
.rt-chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.rt-chart-head h3 { font-size: 0.98rem; }
.rt-chart-unit { font-size: 0.72rem; color: #7d828d; }
.rt-cols-shell { position: relative; }
.rt-cols { display: flex; align-items: stretch; gap: 5px; height: 160px; }
.rt-col { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rt-col-plot { flex: 1; position: relative; }
.rt-col-zero { position: absolute; left: 0; right: 0; height: 1px; background: #2e333d; }
.rt-col-bar { position: absolute; left: 8%; right: 8%; border-radius: 3px; }
.rt-col-bar.pos { background: #4ade80; }
.rt-col-bar.neg { background: #ff6b6b; }
.rt-col-bar.vol { background: #4a5468; }
.rt-col-x { text-align: center; font-size: 0.7rem; color: #7d828d; white-space: nowrap; }
.rt-col-v { text-align: center; font-size: 0.66rem; color: #9aa0ac; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rt-chart-foot { font-size: 0.78rem; color: #7d828d; border-top: 1px solid #262a33; padding-top: 10px; margin-top: 14px; }
.rt-thr { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed #7d828d; pointer-events: none; }
.rt-thr span { position: absolute; left: 0; transform: translateY(2px); font-size: 0.66rem; color: #9aa0ac; background: #1a1d24; padding: 0 4px; white-space: nowrap; }

/* ---- กราฟรูรั่ว (แท่งแนวนอน สองทาง) ---- */
.rt-leak { padding: 18px 20px 8px; }
.rt-leak-row { display: grid; grid-template-columns: 130px 1fr 140px; align-items: center; gap: 14px; padding: 3px 0; border-radius: 6px; }
.rt-leak-row:hover { background: #11131a; }
.rt-leak-key { display: flex; align-items: baseline; gap: 7px; justify-content: flex-end; }
.rt-ratio { font-size: 0.83rem; font-weight: 600; color: #e6e6e6; font-variant-numeric: tabular-nums; }
.rt-leak-track { position: relative; height: 19px; }
.rt-leak-zero { position: absolute; top: -3px; bottom: -3px; width: 1px; background: #2e333d; }
.rt-leak-bar { position: absolute; top: 3px; height: 13px; border-radius: 3px; }
.rt-leak-bar.pos { background: #4ade80; }
.rt-leak-bar.neg { background: #ff6b6b; }
.rt-leak-val { font-size: 0.8rem; text-align: right; font-variant-numeric: tabular-nums; }
.rt-leak-axis { display: grid; grid-template-columns: 130px 1fr 140px; gap: 14px; font-size: 0.7rem; color: #7d828d; padding-top: 8px; margin-top: 6px; border-top: 1px solid #262a33; }
.rt-leak-axis-in { position: relative; height: 14px; }
.rt-leak-axis-in span { position: absolute; transform: translateX(-50%); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---- ตาราง (ใช้ .table-wrap เดิม จึงเลื่อนแนวนอนได้เองบนจอเล็ก) ---- */
.rt-table th { cursor: pointer; user-select: none; white-space: nowrap; }
.rt-table th:hover { color: #e6e6e6; }
.rt-table th:focus-visible { outline: 2px solid #4ade80; outline-offset: -2px; }
.rt-table td { font-variant-numeric: tabular-nums; }
.rt-table td.num, .rt-table th.num { text-align: right; }
.rt-arw { font-size: 0.6rem; color: #7d828d; margin-left: 3px; }
.rt-warn { color: #e8d44d; }

/* ---- การ์ดย่อย ---- */
.rt-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.rt-card-name { font-size: 1rem; font-weight: 700; }
.rt-card-sub { color: #7d828d; font-size: 0.78rem; font-weight: 400; margin-left: 7px; }
.rt-share { height: 6px; border-radius: 3px; background: #262a33; overflow: hidden; margin-bottom: 12px; }
.rt-share > i { display: block; height: 100%; border-radius: 3px; background: #4a5468; }
.rt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.rt-g-l { font-size: 0.75rem; color: #7d828d; }
.rt-g-v { font-size: 0.95rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- ทำไมถึงรั่ว ---- */
.rt-sw-row { display: grid; grid-template-columns: 84px 1fr 62px; align-items: center; gap: 10px; margin-bottom: 9px; }
.rt-sw-l { font-size: 0.78rem; color: #7d828d; }
.rt-sw-track { position: relative; height: 10px; background: #262a33; border-radius: 3px; }
.rt-sw-fill { position: absolute; top: 0; left: 0; height: 100%; border-radius: 3px; }
.rt-sw-be { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #c4c8d0; border-radius: 1px; }
.rt-sw-v { font-size: 0.83rem; text-align: right; font-variant-numeric: tabular-nums; }
.rt-pill { font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.rt-pill.bad { color: #ff6b6b; background: #4a1f24; }
.rt-pill.ok { color: #4ade80; background: #14432a; }

/* ---- ธงเตือน ---- */
.rt-flag { border-left: 3px solid #e8d44d; }
.rt-flag.critical { border-left-color: #ff6b6b; }
.rt-flag h3 { font-size: 0.98rem; margin-bottom: 8px; }
.rt-flag p { font-size: 0.85rem; color: #c4c8d0; margin-bottom: 10px; }
.rt-flag b { color: #e6e6e6; }
.rt-flag code { background: #11131a; border: 1px solid #262a33; border-radius: 4px; padding: 1px 5px; font-size: 0.8rem; }
.rt-months { display: flex; gap: 3px; margin-bottom: 10px; }
.rt-m { flex: 1; text-align: center; font-size: 0.66rem; padding: 3px 0; border-radius: 4px; background: #11131a; color: #7d828d; }
.rt-m.on { background: #3a3a1f; color: #e8d44d; font-weight: 600; }
.rt-flag.critical .rt-m.on { background: #4a1f24; color: #ff6b6b; }
.rt-nums { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.rt-n-l { font-size: 0.7rem; color: #7d828d; }
.rt-n-v { font-size: 0.88rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- วิธีคิด ---- */
.rt-method dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 0.85rem; }
.rt-method dt { color: #e6e6e6; font-weight: 600; white-space: nowrap; }
.rt-method dd { color: #9aa0ac; }
.rt-method code { background: #11131a; border: 1px solid #262a33; border-radius: 4px; padding: 1px 5px; font-size: 0.8rem; }

.rt-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }

@media (max-width: 640px) {
  .ratio-wrap { padding: 0 14px 60px; }
  .rt-leak-row, .rt-leak-axis { grid-template-columns: 92px 1fr 110px; gap: 8px; }
  .rt-col-v { display: none; }
}

/* ============================================================
   หน้าเลือกเมนูหลัง login (/menu.html)
   ============================================================ */
.menu-wrap {
  max-width: 980px;
  margin: 40px auto 80px;
  padding: 0 24px;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.menu-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: #1a1d24;
  border: 1px solid #262a33;
  border-radius: 14px;
  padding: 22px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.menu-card:hover {
  background: #1f232c;
  border-color: #e63946;
  transform: translateY(-2px);
}

.menu-card:focus-visible {
  outline: 2px solid #e63946;
  outline-offset: 2px;
}

.menu-ico {
  font-size: 2rem;
  line-height: 1;
  flex: none;
}

.menu-card h2 {
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.menu-card p {
  color: #9aa0ac;
  font-size: 0.85rem;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .menu-wrap { margin-top: 24px; padding: 0 14px; }
  .menu-card { padding: 18px; }
}

/* คอลัมน์รองในตารางเทียบ (สัดส่วน A / B) ให้เบากว่าตัวเลขหลัก */
#pairs .muted-cell {
  color: #9aa0ac;
  font-size: 0.82rem;
}

#pairs thead th {
  text-align: center;
  vertical-align: middle;
}

/* ---- โหมดเลือกผู้เล่น (หน้า compare): ค้นหาจากชื่อ / วางรายชื่อเต็ม ---- */
.pick-modes {
  width: fit-content;
  margin-bottom: 10px;
}

.paste-box {
  display: block;
  width: 100%;
  resize: vertical;
  line-height: 1.5;
}

/* ---- สถานะกำลังโหลด ---- */
/* กล่องรอผลที่อยู่นอก <main> (หน้า index) ต้องมีตัวครอบให้กว้างเท่ากับเนื้อหาหน้า */
.loading-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.loading-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #1a1d24;
  border: 1px solid #262a33;
  border-radius: 12px;
  padding: 44px 24px;
  margin: 20px 0 24px;
  color: #9aa0ac;
  font-size: 0.95rem;
}

.spinner {
  flex: none;
  width: 22px;
  height: 22px;
  border: 3px solid #2e333d;
  border-top-color: #e63946;
  border-radius: 50%;
  animation: rp-spin 0.8s linear infinite;
}

/* ปุ่มที่กำลังทำงาน — วงหมุนเล็ก ๆ นำหน้าข้อความในปุ่ม */
button.is-loading::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-inline-end: 7px;
  vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: rp-spin 0.8s linear infinite;
}

@keyframes rp-spin {
  to { transform: rotate(360deg); }
}

/* เครื่องที่ตั้งค่าลดการเคลื่อนไหว — ยังหมุนอยู่แต่ช้าลงมาก */
@media (prefers-reduced-motion: reduce) {
  .spinner,
  button.is-loading::before {
    animation-duration: 2.4s;
  }
}

/* ---- กล่องแจ้งเตือนในหน้า (เช่น STEP ยังเทียบไม่ได้) ---- */
.notice {
  border: 1px solid #3a3a1f;
  background: #1e1d14;
  border-radius: 10px;
  padding: 16px 18px;
}

.notice-warn {
  border-color: #4a4526;
  background: #1f1d15;
}

.notice-title {
  font-weight: 700;
  color: #e8d44d;
  margin-bottom: 8px;
}

.notice p {
  font-size: 0.88rem;
  color: #c4c8d0;
}

.notice p + p {
  margin-top: 8px;
}

.notice p.muted {
  color: #7d828d;
  font-size: 0.82rem;
}

/* ตารางหลักฐานรายบิล — 1 คู่บิลกินสองแถว ให้เห็นเป็นก้อนเดียวกัน */
#evidence td,
#evidence th {
  white-space: nowrap;
  vertical-align: middle;
}

#evidence tr.ev-first td {
  border-top: 1px solid #2e333d;
}

#evidence tr.ev-first,
#evidence tr.ev-second {
  background: transparent;
}

#evidence tr.ev-second td {
  padding-top: 2px;
}

#evidence .match-cell {
  min-width: 220px;
}

/* ตัวครอบแถบแบ่งหน้าของตารางหลักฐานในหน้า compare
   (คลาสลูก .pager-info / .pager-nav / .pager-page มีอยู่แล้วด้านบน) */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}
