/* ===================================================================
   components.css — ปุ่ม, การ์ด, input, badge, table
   ใช้ร่วมกันทุกหน้าในระบบ
   =================================================================== */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--btn-hover-border);
  background: var(--btn-hover-bg);
}
.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  font-weight: 600;
  font-family: var(--font-sans);
}
.btn-primary:hover {
  background: var(--btn-primary-hover-bg);
  border-color: var(--btn-primary-hover-bg);
}

.btn-danger {
  background: var(--btn-danger-bg);
  border-color: var(--btn-danger-text);
  color: var(--btn-danger-text);
}
.btn-danger:hover {
  background: var(--btn-danger-hover-bg);
}

.btn-success {
  background: var(--btn-success-bg);
  border-color: var(--btn-success-bg);
  color: var(--btn-success-text);
  font-weight: 600;
}
.btn-success:hover {
  background: var(--btn-success-hover-bg);
  border-color: var(--btn-success-hover-bg);
}

.btn-danger-solid {
  background: var(--btn-danger-solid-bg);
  border-color: var(--btn-danger-solid-bg);
  color: var(--btn-danger-solid-text);
  font-weight: 600;
}
.btn-danger-solid:hover {
  background: var(--btn-danger-solid-hover-bg);
  border-color: var(--btn-danger-solid-hover-bg);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
}

.btn-block {
  width: 100%;
}

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

/* ---------- Form fields ---------- */
.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235C6A70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 15px;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--line-strong);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.field select:disabled,
.field input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background-color: var(--bg-soft);
}

.field-error {
  font-size: 12px;
  color: var(--red);
  margin-top: 6px;
}

.field input.has-error {
  border-color: var(--red);
}

/* ---------- .input — ช่องกรอกข้อมูล/dropdown ทั่วไปที่ไม่ได้ห่อด้วย .field
   (พบในหน้า POS: เลือกห้อง/ช่องทางรับเงิน/VAT/ส่วนลด, หน้ารายงาน/ตรวจนับสต็อก/มินิบาร์: กรองวันที่-ห้อง-สาขา ฯลฯ)
   เดิมมีแค่ class="input" เฉยๆ ไม่มี base style ส่วนกลาง ทำให้ <select> ใช้หน้าตา default ของเบราว์เซอร์
   (กรอบเหลี่ยม ลูกศร native) ดูหลุดจากดีไซน์ระบบ — ตอนนี้ให้หน้าตาเดียวกับ .field input/select ทุกจุด ---------- */
.input {
  width: 100%;
  padding: 11px 14px;
  background-color: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.input:hover {
  border-color: var(--line-strong);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.input::placeholder {
  color: var(--text-faint);
}

.input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background-color: var(--bg-soft);
}

select.input {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235C6A70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 15px;
}

select.input option:disabled {
  color: var(--text-faint);
}

/* ---------- Combo เลือกห้องพัก (custom dropdown แทน native <select>) ----------
   ใช้ในโมดัล "เพิ่มการเข้าพักใหม่/แก้ไขการเข้าพัก" — โครงสร้าง:
   input[hidden] เก็บค่าจริง (ยังยิง 'change' event เหมือน select เดิม ตัว logic อื่นๆ ในไฟล์ไม่ต้องแก้)
   + ปุ่ม trigger (โฟกัสได้ ทำหน้าที่แทนหน้าตา select ที่ปิดอยู่)
   + panel ลอยด้านล่าง (ไม่ใช่ native listbox จึงใส่ป้ายไอคอนสถานะห้องในแต่ละแถวได้) */
.room-combo {
  position: relative;
}
.room-combo-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14.5px;
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.room-combo-trigger:hover {
  border-color: var(--line-strong);
}
.room-combo-trigger:focus,
.room-combo-trigger[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.room-combo-trigger i {
  font-size: 16px;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform 0.15s;
}
.room-combo-trigger[aria-expanded="true"] i {
  transform: rotate(180deg);
  color: var(--accent);
}
.room-combo-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 999;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .14), 0 2px 8px rgba(0, 0, 0, .06);
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.room-combo-panel::-webkit-scrollbar {
  width: 8px;
}
.room-combo-panel::-webkit-scrollbar-track {
  background: transparent;
}
.room-combo-panel::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 99px;
  border: 2px solid var(--bg);
}
.room-combo-group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 6px;
  margin-top: 6px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}
.room-combo-group-label:first-child {
  margin-top: 0;
}
.room-combo-group-label i {
  font-size: 12px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.room-combo-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin: 1px 0;
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.1s;
}
.room-combo-option:hover,
.room-combo-option.is-highlighted {
  background: var(--panel-hover);
}
.room-combo-option.is-selected {
  background: var(--accent-dim);
}
.room-combo-option-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-faint);
}
.room-combo-option-icon i {
  font-size: 14px;
}
.room-combo-option.is-selected .room-combo-option-icon {
  background: var(--accent);
  color: var(--btn-primary-text);
}
.room-combo-option-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  overflow: hidden;
}
.room-combo-option-num {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.room-combo-option.is-selected .room-combo-option-num {
  color: var(--accent-deep);
}
.room-combo-option-type {
  font-size: 12.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-combo-option-check {
  font-size: 15px;
  color: var(--accent);
  flex-shrink: 0;
}
.room-combo-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}
.room-combo-badge i { font-size: 11px; }
.room-combo-badge.is-occupied    { background: var(--badge-red-bg);     color: var(--badge-red-text); }
.room-combo-badge.is-reserved    { background: var(--badge-blue-bg);    color: var(--badge-blue-text); }
.room-combo-badge.is-cleaning    { background: var(--badge-amber-bg);   color: var(--badge-amber-text); }
.room-combo-badge.is-maintenance { background: var(--badge-neutral-bg); color: var(--badge-neutral-text); }

/* ---------- ช่องกรอกเวลาแบบ 24 ชม. (HH:MM) พร้อมไอคอนนาฬิกา ---------- */
.time-input-wrap {
  position: relative;
}

.time-input-wrap input.time-input {
  padding-right: 38px;
  font-family: var(--font-sans);
  letter-spacing: 0.02em;
}

.time-input-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 16px;
  pointer-events: none;
}

/* ---------- กล่องแสดงค่าแบบอ่านอย่างเดียว (ดึงมาจากที่อื่น แก้ตรงนี้ไม่ได้) ---------- */
.readonly-field {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 14.5px;
}

.readonly-field i {
  font-size: 15px;
  color: var(--text-faint);
  flex-shrink: 0;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* การ์ดสรุปแบบ .card ธรรมดา (พื้นหลัง var(--card-bg)) ที่มี .stat-num/.stat-label อยู่ข้างใน
   เช่น การ์ด "การเงินเดือนนี้" ในหน้า Dashboard — ใช้สีตัวอักษรของตัวเอง (--card-num / --card-label)
   แยกอิสระจาก --text/--text-dim ที่ใช้ทั่วแอป และแยกจาก --bento-mint-text/--bento-mint-sub
   (ค่า default เดิมของ .stat-num/.stat-label ที่ออกแบบมาคู่กับพื้นหลัง --bento-mint ของ .stat เท่านั้น)
   เพื่อไม่ให้ตัวอักษรกลืนกับพื้น --card-bg และไม่ลากตามกันเวลาปรับสีตัวอักษรหลักของทั้งแอป */
.card .stat-num {
  color: var(--card-num);
}
.card .stat-label {
  color: var(--card-label);
}
/* ต้อง specificity สูงกว่า .card .stat-num เสมอ (ไม่พึ่งลำดับไฟล์) เพื่อให้สีเตือน/อันตราย
   ของการ์ดสรุปแบบ .card ธรรมดา (เช่น "ปิดปรับปรุง", "ค้างชำระ") ใช้ token อิสระของตัวเองได้จริง */
.card .stat-num.warn { color: var(--stat-warn); }
.card .stat-num.danger { color: var(--stat-danger); }

/* ---------- Stat / metric cards (สไตล์ Bento) ---------- */
.stat-grid {
  display: grid;
  /* min(160px, 100%) กันไม่ให้คอลัมน์ถูกบังคับกว้างเกิน viewport บนจอมือถือแคบๆ
     (เดิมใช้ 160px ตรงๆ ทำให้การ์ด 3 ใบรวมกันกว้างเกินหน้าจอและดันทั้งหน้าล้นแนวนอน) */
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  gap: 12px;
}

@media (max-width: 860px) {
  /* บังคับ 2 คอลัมน์ที่แน่นอนบนมือถือแทนการพึ่ง auto-fit อย่างเดียว — คาดเดาผลลัพธ์ได้ชัดเจนกว่า
     การ์ดใบที่ 3 (ถ้ามี) จะขึ้นบรรทัดใหม่เต็มความกว้างเอง */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

@media (max-width: 420px) {
  /* จอแคบมาก: ตัวเลขใหญ่ 30px + label ยาวๆ อยู่ 2 คอลัมน์แล้วบีบเกินไป เรียงเดี่ยวแทน */
  .stat-grid {
    grid-template-columns: 1fr;
  }

  /* ยกเว้น .stat-grid-compact (label สั้นๆ เช่น "ห้องว่าง", "มีผู้เข้าพัก" ในหน้า Dashboard) —
     คงกริด 2 คอลัมน์ต่อไป ไม่ต้องเรียงเดี่ยวจนเปลืองพื้นที่แนวตั้งเกินจำเป็น */
  .stat-grid.stat-grid-compact {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 860px) {
  .stat {
    padding: 14px 16px;
  }
  .stat-num {
    font-size: 26px;
  }
}

.stat {
  background: var(--bento-mint);
  border-radius: 18px;
  padding: 18px 18px;
}

.stat-num {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 700;
  color: var(--bento-mint-text);
  line-height: 1.2;
}

.stat-num.warn,
.stat-grid .stat:nth-child(n) .stat-num.warn { color: var(--stat-warn); }
.stat-num.danger,
.stat-grid .stat:nth-child(n) .stat-num.danger { color: var(--stat-danger); }

.stat-label {
  font-size: 12px;
  color: var(--bento-mint-sub);
  margin-top: 6px;
  font-weight: 500;
}

/* การ์ดสถิติ (.stat) ใช้สีมินท์เป็นค่าเริ่มต้นเสมอ (ไม่ต้องมี class เพิ่ม)
   ส่วนการ์ดที่ต้องการสีอื่น ให้เติม class ตรงๆ ตามความหมาย (stat-purple / stat-tangerine / stat-slate / stat-neutral)
   *** ห้ามใช้ :nth-child() เลือกสีอีก เพราะ .stat-grid ถูกใช้ซ้ำในหลายหน้า (checkin.js, dashboard.js, settings.js)
   ที่มีจำนวน/ลำดับการ์ดต่างกัน ตำแหน่งเดียวกันจึงมีความหมายคนละอย่างกันในแต่ละหน้า ใช้ nth-child ทำให้สีสลับมั่ว ***/

/* สีเทาเขียวกลาง ใช้ token --bento-neutral แยกอิสระจาก --bento-mint โดยตั้งใจ
   สำหรับการ์ดสรุปทั่วไปที่ "ไม่ใช่สถานะห้อง" เช่น "ห้องทั้งหมด" (dashboard.js), "เช็คอินวันนี้ (ตามจอง)" (checkin.js)
   ส่วน .stat เปล่า (ไม่มี class เพิ่ม) ยังคงหมายถึงสถานะ "ห้องว่าง" เท่านั้น ใช้มินท์ต่อไปตามเดิม
   เพื่อให้สีตรงกับผังห้อง .room-tile.st-available เสมอ ไม่ปนกับการ์ดสรุปทั่วไปที่ไม่เกี่ยวกับสถานะห้อง */
.stat-grid .stat.stat-neutral {
  background: var(--bento-neutral);
}
.stat-grid .stat.stat-neutral .stat-num {
  color: var(--bento-neutral-text);
}
.stat-grid .stat.stat-neutral .stat-label {
  color: var(--bento-neutral-sub);
}

/* เด่นสุดด้วยม่วงเข้ม ตัวอักษรขาว — การ์ด "กำลังเข้าพัก / มีผู้เข้าพัก"
   ใช้ token --bento-purple-stat แยกอิสระจาก --bento-purple ของเมนูที่เลือก (sidebar) โดยตั้งใจ */
.stat-grid .stat.stat-purple {
  background: var(--bento-purple-stat);
}
.stat-grid .stat.stat-purple .stat-num {
  color: var(--bento-purple-stat-text);
}
.stat-grid .stat.stat-purple .stat-label {
  color: var(--bento-purple-stat-soft);
}

/* ใช้สีของตัวเอง (bento-tangerine) แยกขาดจากสถานะ "ปิดปรับปรุง" (โคล่อล)
   เป็นสีอิสระสำหรับการ์ด "เช็คเอาท์วันนี้" โดยเฉพาะ ไม่ผูกกับสีของสถานะห้องอื่น */
.stat-grid .stat.stat-tangerine {
  background: var(--bento-tangerine);
}
.stat-grid .stat.stat-tangerine .stat-num {
  color: var(--bento-tangerine-text);
}
.stat-grid .stat.stat-tangerine .stat-label {
  color: var(--bento-tangerine-sub);
}

/* ใช้สีของตัวเอง (bento-slate) แยกขาดจากการ์ด "เช็คเอาท์วันนี้" (tangerine)
   และแยกขาดจากสถานะ "ทำความสะอาด" (อำพัน) — เป็นสีอิสระสำหรับการ์ดสรุป "ปิดปรับปรุง" (หน้าภาพรวม) โดยเฉพาะ */
.stat-grid .stat.stat-slate {
  background: var(--bento-slate);
}
.stat-grid .stat.stat-slate .stat-num {
  color: var(--bento-slate-text);
}
.stat-grid .stat.stat-slate .stat-label {
  color: var(--bento-slate-sub);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.01em;
  min-width: 96px;
  white-space: nowrap;
}

.badge-accent { background: var(--badge-accent-bg); color: var(--badge-accent-text); }
.badge-green { background: var(--badge-green-bg); color: var(--badge-green-text); }
.badge-amber { background: var(--badge-amber-bg); color: var(--badge-amber-text); }
.badge-red { background: var(--badge-red-bg); color: var(--badge-red-text); }
.badge-blue { background: var(--badge-blue-bg); color: var(--badge-blue-text); }
.badge-neutral { background: var(--badge-neutral-bg); color: var(--badge-neutral-text); border: 1px solid var(--line); }

/* ป้าย "ประเภทบิล" ในหน้าบิล/ใบเสร็จ (การจอง/เช็คอิน/มัดจำ/สัญญา) — ใช้ token --invoice-* แยกอิสระจาก .badge-* ชุดบนโดยตั้งใจ */
.invoice-badge-booking  { background: var(--invoice-booking-bg);  color: var(--invoice-booking-text); }
.invoice-badge-checkin  { background: var(--invoice-checkin-bg);  color: var(--invoice-checkin-text); }
.invoice-badge-deposit  { background: var(--invoice-deposit-bg);  color: var(--invoice-deposit-text); }
.invoice-badge-contract { background: var(--invoice-contract-bg); color: var(--invoice-contract-text); }

/* ป้าย "ประเภท" ในหน้าประวัติกิจกรรม — ใช้ token --activity-* แยกอิสระจาก .badge-* ชุดบนโดยตั้งใจ */
.activity-badge-checkin  { background: var(--activity-checkin-bg);  color: var(--activity-checkin-text); }
.activity-badge-checkout { background: var(--activity-checkout-bg); color: var(--activity-checkout-text); }
.activity-badge-reserve  { background: var(--activity-reserve-bg);  color: var(--activity-reserve-text); }
.activity-badge-cancel   { background: var(--activity-cancel-bg);   color: var(--activity-cancel-text); }
.activity-badge-invoice  { background: var(--activity-invoice-bg);  color: var(--activity-invoice-text); border: 1px solid var(--line); }
.activity-badge-payment  { background: var(--activity-payment-bg);  color: var(--activity-payment-text); }
.activity-badge-receipt  { background: var(--activity-receipt-bg);  color: var(--activity-receipt-text); border: 1px solid var(--line); }
.activity-badge-contract { background: var(--activity-contract-bg); color: var(--activity-contract-text); }
.activity-badge-move     { background: var(--activity-move-bg);     color: var(--activity-move-text); }
.activity-badge-other    { background: var(--activity-other-bg);    color: var(--activity-other-text); border: 1px solid var(--line); }
.activity-badge-system   { background: var(--activity-system-bg);   color: var(--activity-system-text); border: 1px solid var(--line); }

/* ป้ายสถานะในหน้า "สัญญาเช่า" — ใช้ token --contract-* แยกอิสระจาก .badge-* ชุดบนโดยตั้งใจ */
.contract-badge-active    { background: var(--contract-active-bg);    color: var(--contract-active-text); }
.contract-badge-ended     { background: var(--contract-ended-bg);     color: var(--contract-ended-text); border: 1px solid var(--line); }
.contract-badge-cancelled { background: var(--contract-cancelled-bg); color: var(--contract-cancelled-text); }

/* ป้ายในหน้า "จัดการสาขา/ผู้ใช้" — ใช้ token --admin-* แยกอิสระจาก .badge-* ชุดบนโดยตั้งใจ */
.admin-badge-branch-active    { background: var(--admin-branch-active-bg);    color: var(--admin-branch-active-text); }
.admin-badge-branch-inactive  { background: var(--admin-branch-inactive-bg);  color: var(--admin-branch-inactive-text); border: 1px solid var(--line); }
.admin-badge-role-superadmin  { background: var(--admin-role-superadmin-bg);  color: var(--admin-role-superadmin-text); }
.admin-badge-role-normal      { background: var(--admin-role-normal-bg);      color: var(--admin-role-normal-text); border: 1px solid var(--line); }
.admin-badge-user-active      { background: var(--admin-user-active-bg);      color: var(--admin-user-active-text); }
.admin-badge-user-suspended   { background: var(--admin-user-suspended-bg);   color: var(--admin-user-suspended-text); }
.admin-badge-access-role      { background: var(--admin-access-role-bg);       color: var(--admin-access-role-text); }

/* ---------- Status dot ---------- */
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.dot-accent { background: var(--accent); }
.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.dot-red { background: var(--red); }
.dot-blue { background: var(--blue); }
.dot-faint { background: var(--text-faint); }

/* dot สีตาม bento — ใช้คู่กับ room-tile (ผังห้องพัก) ให้สี legend ตรงกับสีในผังจริง */
.dot-bento-mint { background: var(--bento-mint); }
.dot-bento-pink { background: var(--bento-pink); }
.dot-bento-pink-soft { background: var(--bento-pink-soft); }
.dot-bento-coral { background: var(--bento-coral); }
.dot-bento-amber { background: var(--bento-amber); }

.dot-pulse {
  position: relative;
}
.dot-pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  animation: dot-pulse 2s infinite;
}
@keyframes dot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(46, 148, 97, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(46, 148, 97, 0); }
  100% { box-shadow: 0 0 0 0 rgba(46, 148, 97, 0); }
}

/* ---------- Table ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

/* ตารางที่กำหนด width ของ th ไว้แน่นอน (เช่น หมวดหมู่/รูปแบบเตียงในหน้าตั้งค่า)
   ใช้ class นี้เพิ่มเพื่อบังคับให้คอลัมน์กว้างตามที่ตั้งไว้เป๊ะๆ ไม่ขยายตามเนื้อหา
   ทำให้หลายตารางที่อยู่ติดกันมีคอลัมน์ตรงแนวกัน — ข้อความยาวจะตัดบรรทัดเอง
   (ไม่ใช้ ellipsis รวมทุกคอลัมน์ เพราะจะไปบังปุ่ม action ในคอลัมน์สุดท้ายด้วย) */
table.data-table.fixed-cols {
  table-layout: fixed;
}

table.data-table.fixed-cols td {
  word-wrap: break-word;
}

table.data-table th {
  text-align: left;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.01em;
  padding: 12px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

table.data-table tbody tr:last-child td {
  border-bottom: none;
}

table.data-table tbody tr:hover {
  background: var(--bg-soft);
}

/* ---------- ปรับขนาดคอลัมน์/ความสูงแถวตาราง (โมดูลกลาง TableResize — ดู table-resize.js) ----------
   ใช้ในหลายหน้า เช่น ประวัติการเปลี่ยนแปลง, สัญญาเช่า ฯลฯ — เฉพาะ superadmin ที่ลาก/ปรับได้ */
.col-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 3;
  touch-action: none;
}
.col-resize-handle::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3px;
  width: 2px;
  background: transparent;
}
.col-resize-handle:hover::after,
.col-resize-handle.active::after {
  background: var(--accent, #2e9461);
}
.stay-row-resize-handle-end {
  width: 10px;
}
.stay-row-resize-handle-end::after {
  left: 4px;
  width: 2px;
  border-radius: 2px;
}
.stay-row-resize-handle-end:hover::after,
.stay-row-resize-handle-end.active::after {
  background: var(--accent, #2e9461);
  box-shadow: 3px 0 0 var(--accent, #2e9461);
}

/* ปรับความสูงแถวผ่าน CSS var --tr-row-py ที่ตั้งบน .table-wrap[data-row-resize]
   scope ด้วย attribute เฉพาะ เพื่อไม่ให้กระทบตาราง .data-table อื่นๆ ที่ไม่ได้เปิดใช้ฟีเจอร์นี้ */
.table-wrap[data-row-resize] table.data-table td {
  padding-top: var(--tr-row-py, 12px);
  padding-bottom: var(--tr-row-py, 12px);
}

/* ซ่อนแถบเลื่อนแนวนอนที่โผล่มาตอนตารางกว้างเกิน container (จากการลากปรับความกว้างคอลัมน์)
   ยังเลื่อนดูได้ปกติ (ลากเมาส์/trackpad/shift+scroll) แค่ไม่โชว์แถบให้เกะกะสายตา */
.table-wrap[data-row-resize] {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge เก่า */
}
.table-wrap[data-row-resize]::-webkit-scrollbar {
  display: none; /* Chrome/Safari/Edge ใหม่ */
}

/* ---------- ลากแถวเพื่อย้ายลำดับ (ใช้กับตารางที่มี [data-drag-handle], เช่น ช่องทางการจอง) ---------- */
table.data-table tbody tr.dragging {
  opacity: 0.4;
}

table.data-table tbody tr.drag-over {
  box-shadow: inset 0 2px 0 0 var(--accent);
}

/* ===================================================================
   รายการเข้าพัก — จอกว้างใช้ตาราง .checkin-table-desktop ตามปกติ
   จอมือถือใช้การ์ด .stay-card (โครง HTML แยกจากตาราง ไม่ใช่การบิด <td>)
   เพราะการบิดคอลัมน์ตารางด้วย flex/order ทำให้ตัดคำ/จัดวางเพี้ยนไม่คงที่
   ตามความยาวข้อความ — สลับการแสดงผลด้วย CSS ตาม breakpoint เดียวกัน
   =================================================================== */
.checkin-cards-mobile { display: none; }

@media (max-width: 640px) {
  .checkin-table-desktop { display: none; }
  .checkin-cards-mobile { display: block; }
}

.stay-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--text-faint);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(28, 35, 38, 0.05);
  cursor: pointer;
}
.stay-card:last-child { margin-bottom: 0; }
.stay-card[data-status="checked_in"]  { border-left-color: var(--blue); }
.stay-card[data-status="reserved"]    { border-left-color: var(--amber); }
.stay-card[data-status="cancelled"]   { border-left-color: var(--red); }
.stay-card[data-status="checked_out"] { border-left-color: var(--text-faint); }

.stay-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stay-card-room {
  font-weight: 700;
  font-size: 14.5px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.stay-card-guest {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stay-card-status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  white-space: nowrap;
  color: var(--text-dim);
}
.stay-card-meta {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-faint);
}

.stay-card-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.stay-card-date-k {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  margin-bottom: 3px;
}
.stay-card-date-v {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text);
  line-height: 1.5;
}

.stay-card-action {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.stay-card-action .btn {
  flex: 1 1 0;
  width: auto;
  justify-content: center;
}

/* ===================================================================
   Utility ทั่วไป: สลับตาราง (จอกว้าง) / การ์ด (มือถือ) — ใช้ได้กับหลายหน้า
   ต่างจาก .checkin-table-desktop/.checkin-cards-mobile ที่ผูกกับหน้าเช็คอินโดยเฉพาะ
   =================================================================== */
.list-cards-mobile { display: none; }

@media (max-width: 640px) {
  .table-desktop-only { display: none; }
  .list-cards-mobile { display: block; }

  /* แถบ "ลากขอบหัวคอลัมน์เพื่อปรับความกว้าง" — ใช้ไม่ได้จริงบนจอสัมผัส และตารางถูกซ่อนไปแล้ว */
  .table-resize-toolbar { display: none; }
}

/* ---------- การ์ดลูกค้า (มือถือ) — ใช้ .info-row เดิมของระบบสำหรับแถวข้อมูล ---------- */
.customer-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(28, 35, 38, 0.05);
}
.customer-card:last-child { margin-bottom: 0; }
.customer-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.customer-card-name {
  font-weight: 700;
  font-size: 14.5px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.customer-card-actions {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}

/* ---------- การ์ดจดมิเตอร์ (มือถือ) — ห้อง+ผู้เช่าแถวบน แล้วแยกส่วนน้ำ/ไฟด้วยเส้นคั่น ---------- */
.meter-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(28, 35, 38, 0.05);
}
.meter-card:last-child { margin-bottom: 0; }
.meter-card-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.meter-card-room {
  font-weight: 700;
  font-size: 14.5px;
  font-family: var(--font-mono);
  flex: 0 0 auto;
}
.meter-card-tenant {
  font-size: 13px;
  color: var(--text-dim);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meter-card-section {
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid var(--line);
}
.meter-card-section:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}
.meter-card-section-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-faint);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
}

/* ---------- การ์ดบิล/ใบเสร็จ (มือถือ) — checkbox+เลขที่บิล+สถานะแถวบน แล้วตามด้วย .info-row ---------- */
.invoice-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(28, 35, 38, 0.05);
}
.invoice-card:last-child { margin-bottom: 0; }
.invoice-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.invoice-card-top input[type="checkbox"] {
  flex: 0 0 auto;
}
.invoice-card-number {
  flex: 1 1 auto;
  font-weight: 700;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.invoice-card-tags {
  margin-bottom: 6px;
}

/* ---------- การ์ดสัญญาเช่า (มือถือ) ---------- */
.contract-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(28, 35, 38, 0.05);
}
.contract-card:last-child { margin-bottom: 0; }
.contract-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.contract-card-number {
  font-weight: 700;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contract-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.contract-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.contract-card-actions .icon-btn {
  flex: 1 1 auto;
}

/* ---------- การ์ดรายงานการย้ายห้อง (มือถือ) ---------- */
.move-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(28, 35, 38, 0.05);
}
.move-card:last-child { margin-bottom: 0; }
.move-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.move-card-rooms {
  font-weight: 600;
  font-size: 13.5px;
}
.move-card-time {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  flex: 0 0 auto;
}
.move-card-note {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- การ์ดจัดการสาขา/ผู้ใช้/สิทธิ์การเข้าถึง (มือถือ) — ใช้ร่วม 3 แท็บในหน้า admin ---------- */
.admin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(28, 35, 38, 0.05);
}
.admin-card:last-child { margin-bottom: 0; }
.admin-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.admin-card-title {
  font-weight: 700;
  font-size: 14.5px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.admin-card-actions .icon-btn {
  flex: 1 1 auto;
}

/* ---------- การ์ดประวัติการเปลี่ยนแปลง (มือถือ) ---------- */
.log-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(28, 35, 38, 0.05);
}
.log-card:last-child { margin-bottom: 0; }
.log-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.log-card-time {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  flex: 0 0 auto;
}
.log-card-note {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- เมนูตั้งค่า (settings.js) — จัดเป็นกลุ่มมีหัวข้อ + กริดปุ่ม แทน chip-row ยาวเส้นเดียว ---------- */
.settings-menu {
  margin-bottom: 24px;
}
.settings-menu-group {
  margin-bottom: 18px;
}
.settings-menu-group:last-child {
  margin-bottom: 0;
}
.settings-menu-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin-bottom: 8px;
  padding-left: 2px;
}
.settings-menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.settings-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
}
.settings-menu-item i {
  font-size: 16px;
  flex-shrink: 0;
  color: var(--text-faint);
}
.settings-menu-item:hover {
  border-color: var(--accent);
}
.settings-menu-item.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.settings-menu-item.active i {
  color: #fff;
}

@media (max-width: 640px) {
  .settings-menu-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .settings-menu-item {
    font-size: 12.5px;
    padding: 10px;
  }
}

/* ---------- แสดงผล <input type="date"> เป็น "วว/ดด/ปปปป" เสมอ ไม่ขึ้นกับ locale ของเบราว์เซอร์/OS ----------
   ตัวจริงของ input ยังเป็น native date input ปกติ (ปฎิทินกดเลือกได้ผ่าน showPicker(), .value ยังเป็น "YYYY-MM-DD" เหมือนเดิม)
   ซ่อนตัวจริงด้วย opacity:0 (ไม่ใช่ color:transparent เพราะ browser จะยังโชว์เลขของ segment ที่ไฮไลท์ตอน focus) แล้วเอา label ทับแสดงผลแทน ดู Utils.bindDateDisplay() */
.date-display-wrap {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color 0.15s;
}

.date-display-wrap:focus-within {
  border-color: var(--accent);
}

.date-display-wrap input[type='date'] {
  background: transparent;
  border: none;
  opacity: 0; /* ใช้ opacity ไม่ใช่ color:transparent — กัน browser โชว์เลขของ segment ที่ถูกไฮไลท์ตอน focus/เปิดปฏิทิน ซึ่ง color:transparent เพียงอย่างเดียวเอาไม่อยู่ */
  pointer-events: none; /* ห้ามคลิก/พิมพ์ตรงที่ตัว input เด็ดขาด ต้องผ่าน .date-cal-trigger เท่านั้น */
}

.date-display-label {
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  height: 100%;
  display: flex;
  align-items: center;
  pointer-events: none;
  font-family: var(--font-sans);
  font-size: 14.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.date-display-label.is-empty {
  color: var(--text-faint);
}

/* คลุมทั้งช่อง — คลิกตรงไหนในช่องก็ได้ จะเปิดปฏิทินของเบราว์เซอร์ (showPicker) เสมอ
   ไม่ให้ผู้ใช้แก้ไขตัวเลขวันที่ด้วยการพิมพ์โดยตรง */
.date-cal-trigger {
  position: absolute;
  inset: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 14px;
}

.date-cal-trigger i {
  color: var(--text-dim);
  font-size: 15px;
  pointer-events: none;
}

.date-cal-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-md);
}

.date-display-readonly .date-cal-trigger {
  display: none;
}

/* ---------- วันที่ออก (แผน) แบบคำนวณอัตโนมัติจากวันเข้าพัก+จำนวนคืน — แก้ไขเองไม่ได้ ----------
   ใช้คู่กับ input[disabled] เพื่อให้ค่ายังอ่านได้ผ่าน .value ใน JS แต่ผู้ใช้กดเลือกวันที่ไม่ได้ */
.date-display-readonly {
  background: var(--bg-soft);
  border-radius: var(--radius-md);
}
.date-display-readonly input[type='date'] {
  background: transparent;
  border-color: transparent;
  padding-right: 38px;
}
.date-display-readonly .date-display-label {
  color: var(--text-dim);
}
.date-display-readonly i.ti-lock {
  position: absolute;
  right: 14px;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  color: var(--text-faint);
  font-size: 14px;
  pointer-events: none;
}

/* ---------- Tooltip คำอธิบายช่องกรอกข้อมูล — เอาเมาส์ไปชี้ที่ช่องแล้วค่อยขึ้น (ใช้กับช่องที่แก้ไขไม่ได้/ต้องอธิบายเพิ่ม) ---------- */
.field-tooltip-wrap {
  position: relative;
}

.field-tooltip {
  position: absolute;
  z-index: 50;
  top: calc(100% + 6px);
  left: 0;
  width: max-content;
  max-width: 280px;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
}

.field-tooltip-wrap:hover .field-tooltip,
.field-tooltip-wrap:focus-within .field-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.field-tooltip a {
  color: var(--bg);
  text-decoration: underline;
  font-weight: 600;
}

/* ---------- Segmented toggle — เลือกรูปแบบ 2 ทาง (เช่น อาคารหลายชั้น vs วิลล่า/บังกะโล) ---------- */
.segmented-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--segmented-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.segmented-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 10px;
  border: none;
  border-radius: calc(var(--radius-md) - 3px);
  background: transparent;
  color: var(--segmented-text);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.segmented-option i {
  font-size: 18px;
}

.segmented-option:hover:not(.active) {
  color: var(--segmented-hover-text);
  background: var(--segmented-hover-bg);
}

.segmented-option.active {
  background: var(--segmented-active-bg);
  color: var(--segmented-active-text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ตัวเลือก "พิมพ์เอกสารหลังสร้างสัญญา" — ใช้ token --print-option-* แยกอิสระจาก component อื่น */
.print-option-group {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.print-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 12px 16px;
  cursor: pointer;
  border-right: 1px solid var(--line);
  background: var(--print-option-bg);
  flex: 1;
  text-align: center;
  transition: background 0.15s, color 0.15s;
}
.print-option:last-child {
  border-right: none;
}
.print-option .print-option-icon-wrap {
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.print-option .print-option-icon-wrap i {
  font-size: 20px;
  color: var(--print-option-icon);
}
.print-option .print-option-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--print-option-text);
  white-space: nowrap;
  line-height: 1.3;
}
.print-option .print-option-sub {
  font-size: 11px;
  color: var(--print-option-text);
  opacity: 0.72;
  white-space: nowrap;
  line-height: 1.3;
}
.print-option.active {
  background: var(--print-option-active-bg);
}
.print-option.active .print-option-icon-wrap i {
  color: var(--print-option-active-icon);
}
.print-option.active .print-option-title,
.print-option.active .print-option-sub {
  color: var(--print-option-active-text);
  font-weight: 600;
  opacity: 1;
}

/* ---- ตัวเลือกพิมพ์เอกสารแบบย่อ (แถวเดียว, ชิปเล็ก) — ใช้ร่วมกันทุกหน้า (สร้างสัญญา/เช็คอิน/เช็คเอาท์) ---- */
.print-option-group-compact {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  flex: 0 0 auto; /* ค่าเริ่มต้น: กว้างเท่าเนื้อหา — กลุ่มที่มีช่องเดียว เช่น "พิมพ์สลิป WiFi" จะไม่แย่งพื้นที่แถวเกินจำเป็น */
  min-width: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
/* กลุ่มที่มีตั้งแต่ 2 ช่องขึ้นไป (เช่น ไม่พิมพ์ / A4 / อย่างย่อ 80mm) ให้ขยายกินพื้นที่ที่เหลือในแถว
   เพื่อให้แต่ละช่องมีที่พอสำหรับข้อความยาวๆ แทนที่จะถูกบีบเท่ากลุ่มช่องเดียว */
.print-option-group-compact:has(.print-option-compact ~ .print-option-compact) {
  flex: 1 1 320px;
}
.print-option.print-option-compact {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  cursor: pointer;
  border-right: 1px solid var(--line);
  background: var(--print-option-bg);
  transition: background 0.15s, color 0.15s;
  position: relative;
  flex: 1 1 0; /* ทุกช่องในกลุ่มเดียวกันกว้างเท่ากันเสมอ ไม่ว่าข้อความจะยาวแค่ไหน */
  min-width: 0;
  min-height: 41px; /* ให้สูงเท่ากับช่องที่มี 2 บรรทัด (หัวข้อ+คำอธิบายย่อย) แม้ช่องนี้จะมีข้อความบรรทัดเดียว เช่น "พิมพ์สลิป WiFi" */
  box-sizing: border-box;
}
.print-option.print-option-compact:last-child { border-right: none; }
.print-option.print-option-compact:hover { background: var(--hover, rgba(0,0,0,0.035)); }
.print-option.print-option-compact .print-option-compact-icon {
  font-size: 15px; color: var(--print-option-icon); flex: 0 0 auto;
}
.print-option.print-option-compact .print-option-compact-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: left;
  min-width: 0;
  flex: 1 1 auto;
}
.print-option.print-option-compact .print-option-title {
  font-size: 11.5px; font-weight: 500; color: var(--print-option-text);
  line-height: 1.25; white-space: normal; /* ให้ข้อความยาวตัดขึ้นบรรทัดใหม่แทนการถูกตัดด้วย ... เมื่อพื้นที่แคบ */
  word-break: break-word;
}
.print-option.print-option-compact .print-option-compact-sub {
  font-size: 10px; color: var(--print-option-text); opacity: 0.7;
  line-height: 1.15; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.print-option.print-option-compact.active { background: var(--print-option-active-bg); }
.print-option.print-option-compact.active .print-option-compact-icon { color: var(--print-option-active-icon); }
.print-option.print-option-compact.active .print-option-title,
.print-option.print-option-compact.active .print-option-compact-sub {
  color: var(--print-option-active-text); font-weight: 600;
}
.print-option-compact-preview-btn {
  width: 16px; height: 16px; border-radius: 50%;
  background: rgba(0,0,0,0.08); border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; margin-left: 2px; flex: 0 0 auto;
  transition: background 0.15s;
}
.print-option-compact-preview-btn:hover { background: rgba(0,0,0,0.18); }
.print-option-compact-preview-btn i { font-size: 10px; }
@media (max-width: 640px) {
  .print-option-group-compact:has(.print-option-compact ~ .print-option-compact) { width: 100%; flex-basis: 100%; }
}

.segmented-option:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* ---------- Property list (เลือก/สลับสาขา) ---------- */
.property-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.property-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s;
  text-align: left;
}
.property-card:hover {
  border-color: var(--accent);
}
.p-status {
  flex-shrink: 0;
}
.p-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.p-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-meta {
  font-size: 11px;
  color: var(--text-faint);
}
.p-role {
  flex-shrink: 0;
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dim);
}

.empty-state .ti {
  font-size: 32px;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.empty-state-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state-sub {
  font-size: 13px;
  color: var(--text-faint);
}

/* ---------- Loading spinner ---------- */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Toast notification ---------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px -10px rgba(28, 35, 38, 0.18);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  animation: toast-in 0.2s ease-out;
}

.toast-success { border-color: var(--green); }
.toast-error { border-color: var(--red); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===================================================================
   หน้า "ผังห้องพัก" — chip selector, entity card, room tile (สไตล์ตั๋ว/ตราประทับ)
   =================================================================== */

/* ---------- Chips (เลือกโซน / เลือกชั้น) ---------- */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
}
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.chip .chip-edit,
.chip .chip-delete {
  opacity: 0;
  font-size: 13px;
  transition: opacity 0.12s, color 0.12s;
}
.chip:hover .chip-edit,
.chip:hover .chip-delete {
  opacity: 0.65;
}
.chip.active .chip-edit,
.chip.active .chip-delete {
  color: var(--bg);
}
.chip .chip-edit:hover {
  opacity: 1;
}
.chip .chip-delete:hover {
  opacity: 1;
  color: var(--red);
}

/* ---------- Entity card grid (ตึก/อาคาร) ---------- */
.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.entity-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.entity-card:hover {
  border-color: var(--line-strong);
}
.entity-card.active {
  border-color: var(--accent);
}
.entity-card-name {
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 8px;
  padding-right: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entity-card-meta {
  font-size: 12px;
  color: var(--text-faint);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.entity-card-meta .ti {
  margin-right: 3px;
}
.entity-card-zone {
  font-size: 11px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.entity-card-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.12s;
}
.entity-card:hover .entity-card-actions {
  opacity: 1;
}

.icon-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 13px;
  vertical-align: middle;
}
.icon-btn + .icon-btn {
  margin-left: 6px;
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--line-strong);
}
.icon-btn.danger:hover {
  color: var(--red);
  border-color: var(--red);
}

/* ---------- Room tile grid (ผังห้องแบบกราฟิก — ทึบสี + กรอบจุดไข่ปลา ลายตั๋ว/ตราประทับ) ---------- */
.legend-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text-faint);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-row-inline {
  margin-bottom: 0;
  margin-left: 14px;
  font-weight: 400;
  font-family: var(--font-sans, sans-serif);
}

@media (max-width: 860px) {
  /* บนมือถือพื้นที่ไม่พอให้ legend ต่อท้ายหัวข้อแบบเดิม (ทำให้แต่ละป้ายตกไปคนละบรรทัดและ
     ตัวเลขกระเด็นไปชนแถบค้นหา/โซนที่อยู่ข้าง ๆ) จึงแยกลงมาเป็นแถบของตัวเองเต็มความกว้าง
     เดิมทำเป็นเส้นเดียวเลื่อนแนวนอน แต่ป้ายท้ายแถว (เช่น "ทำความสะอาด") จะโดนตัดครึ่งจนกว่าจะเลื่อน
     ทำให้ดูเหมือนล้นจอ — เปลี่ยนเป็นห่อขึ้นบรรทัดใหม่แทน (wrap) ให้เห็นครบทุกป้ายทันทีไม่ต้องเลื่อน */
  .legend-row-inline {
    width: 100%;
    margin-left: 0;
    margin-top: 8px;
    flex-wrap: wrap;
    row-gap: 6px;
    column-gap: 12px;
  }
  .legend-row-inline .legend-item {
    white-space: nowrap;
    font-size: 12px;
  }
}

@media (max-width: 420px) {
  /* จอแคบมาก: ย่อระยะห่างอีกนิดให้แต่ละป้ายชิดกันพอดี ไม่ต้องขึ้นบรรทัดใหม่บ่อยเกินไป */
  .legend-row-inline {
    column-gap: 9px;
  }
  .legend-row-inline .legend-item {
    gap: 4px;
    font-size: 11.5px;
  }
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--room-tile-min-width, 108px), 1fr));
  gap: 10px;
}
.room-tile {
  border-radius: 16px;
  padding: 5px;
  cursor: pointer;
  transition: transform 0.1s;
}
.room-tile:hover {
  transform: translateY(-2px);
}
.room-tile[draggable] {
  cursor: grab;
}
.room-tile.dragging {
  opacity: 0.4;
}
.room-tile.dragging .room-tile-inner {
  border-style: dashed;
}
.room-tile.drag-over .room-tile-inner {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.room-tile-inner {
  border: 1px dashed currentColor;
  opacity: 1;
  border-radius: 12px;
  padding: 9px 4px;
  text-align: center;
}
.room-tile-inner > * {
  opacity: 1;
}
.room-tile-number {
  font-family: var(--font-mono);
  font-size: var(--room-tile-number-size, 15px);
  font-weight: 700;
}
.room-tile-type {
  font-size: var(--room-tile-type-size, 10.5px);
  margin-top: 3px;
  opacity: 0.85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-tile.st-available { background: var(--bento-mint); color: var(--bento-mint-text); }
.room-tile.st-available .room-tile-inner { border-color: color-mix(in srgb, var(--bento-mint-text) 45%, transparent); }
.room-tile.st-available .room-tile-type { color: var(--bento-mint-sub); opacity: 1; }
.room-tile.st-available .room-tile-guest { color: var(--room-tile-guest-mint); }
.room-tile.st-occupied { background: var(--bento-pink); color: var(--bento-pink-occupied-text); }
.room-tile.st-occupied .room-tile-inner { border-color: color-mix(in srgb, var(--bento-pink-occupied-text) 55%, transparent); }
.room-tile.st-occupied .room-tile-type { color: var(--bento-pink-occupied-sub); opacity: 1; }
.room-tile.st-occupied .room-tile-guest { color: var(--room-tile-guest-pink); }
.room-tile.st-reserved { background: var(--bento-pink-soft); color: var(--bento-pink-text); }
.room-tile.st-reserved .room-tile-inner { border-color: color-mix(in srgb, var(--bento-pink-text) 45%, transparent); }
.room-tile.st-reserved .room-tile-type { color: var(--bento-pink-sub); opacity: 1; }
.room-tile.st-maintenance { background: var(--bento-coral); color: var(--bento-coral-text); }
.room-tile.st-maintenance .room-tile-inner { border-color: color-mix(in srgb, var(--bento-coral-text) 45%, transparent); }
.room-tile.st-maintenance .room-tile-type { color: var(--bento-coral-sub); opacity: 1; }
.room-tile.st-cleaning { background: var(--bento-amber); color: var(--bento-amber-text); }
.room-tile.st-cleaning .room-tile-inner { border-color: color-mix(in srgb, var(--bento-amber-text) 45%, transparent); }
.room-tile.st-cleaning .room-tile-type { color: var(--bento-amber-sub); opacity: 1; }

.room-tile.dim {
  opacity: 0.25;
  pointer-events: none;
}
.room-tile-status-icon {
  position: absolute;
  top: -2px;
  right: 0;
  font-size: var(--room-tile-status-icon-size, 12px);
  opacity: 0.85;
}
/* ป้าย "ย้ายห้องแล้ว" — เดิมใช้ currentColor + opacity 0.85 ลอยเฉยๆ แบบเดียวกับ .room-tile-status-icon
   แต่สีตัวอักษร/พื้นหลังของไทล์แต่ละสถานะใกล้เคียงกันเกินไป (เช่น ชมพูบนชมพู) ทำให้แทบมองไม่เห็น
   จึงเปลี่ยนเป็นวงกลมพื้นขาวตัด ไม่พึ่ง currentColor ของไทล์ ให้เด่นสม่ำเสมอทุกสถานะ */
.room-tile-moved-badge {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--panel, #fff);
  color: var(--accent, #146C68);
  font-size: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  opacity: 1;
  z-index: 2;
}
.room-tile-guest {
  font-size: var(--room-tile-guest-size, 9.5px);
  margin-top: 3px;
  opacity: 0.92;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.room-tile-billing {
  display: var(--room-tile-billing-display, inline-block);
  font-size: var(--room-tile-billing-size, 10.5px);
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-top: 4px;
  padding: 2px 9px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--room-tile-billing-bg) 35%, transparent);
  color: var(--room-tile-billing-text);
  opacity: 0.95;
  max-width: 100%;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}
.room-tile-dates {
  display: var(--room-tile-dates-display, block);
  font-size: var(--room-tile-dates-size, 10px);
  margin-top: 3px;
  opacity: 0.85;
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* ป้ายสถานะ "ทำความสะอาด"/"ปิดปรับปรุง" — เป็นคลาสอิสระของตัวเอง ไม่ใช้ร่วมกับ .room-tile-billing อีกต่อไป
   *** เดิมใช้ class="room-tile-billing room-tile-status-badge" ร่วมกัน ทำให้เกิดบั๊ก 2 จุด:
   1) พื้นหลัง/รูปทรงของป้ายนี้ไปผูกกับโทเค็น "ป้ายประเภทการเช่า" ทั้งที่คนละความหมายกันโดยสิ้นเชิง
   2) ถ้าปิดสวิตช์ "โชว์ป้ายประเภทการเช่า" ในหน้าตั้งค่า ป้ายสถานะทำความสะอาด/ปิดปรับปรุง และลิงก์ยืนยันจะหายไปด้วย
      ทั้งที่ควรโชว์เสมอ ไม่เกี่ยวข้องกับสวิตช์นั้นเลย
   จึงแยกเป็นคลาสอิสระ มีสไตล์ (ขนาด/ระยะห่าง/รูปทรงเม็ดยา) ครบในตัวเอง ไม่ต้องพึ่ง .room-tile-billing */
.room-tile-status-badge {
  display: inline-block;
  font-size: var(--room-tile-status-badge-size, 10.5px);
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-top: 4px;
  padding: 2px 9px;
  border-radius: 99px;
  opacity: 0.95;
  max-width: 100%;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}
/* ปิดปรับปรุง กับ ทำความสะอาด ใช้คนละ token สี ปรับสีป้ายใดป้ายหนึ่งจะไม่กระทบอีกป้าย
   (เดิมใช้ token เดียวกัน --room-tile-status-badge-bg/text ร่วมกันทั้ง 2 สถานะ) */
.room-tile-status-badge.is-maintenance {
  background: color-mix(in srgb, var(--room-tile-maint-badge-bg) 55%, transparent);
  color: var(--room-tile-maint-badge-text);
}
.room-tile-status-badge.is-cleaning {
  background: color-mix(in srgb, var(--room-tile-clean-badge-bg) 55%, transparent);
  color: var(--room-tile-clean-badge-text);
}
/* บรรทัด "พร้อมแล้ว" / "เหลือ mm:ss" — เดิมต่อท้ายในป้ายเดียวกับ "ทำความสะอาด" ทำให้ยาวเกินป้ายจนถูกตัดด้วย ...
   แยกลงมาเป็นอีกบรรทัดต่างหาก มีพื้นหลัง+สีตัวอักษรเป็นของตัวเอง แยกคนละ token กันระหว่าง 2 สถานะ
   (roomTileCountdownBg/Text ตอนกำลังนับถอยหลัง กับ roomTileReadyBg/Text ตอนพร้อมแล้ว) ปรับสีใดสีหนึ่งไม่กระทบอีกสถานะ */
.room-tile-status-ready {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 8px;
  border-radius: 99px;
  font-size: var(--room-tile-status-ready-size, 9.5px);
  font-weight: 700;
  opacity: 0.9;
  max-width: 100%;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}
.room-tile-status-ready.is-counting {
  background: color-mix(in srgb, var(--room-tile-countdown-bg) 30%, transparent);
  color: var(--room-tile-countdown-text);
}
.room-tile-status-ready.is-ready {
  background: color-mix(in srgb, var(--room-tile-ready-bg) 30%, transparent);
  color: var(--room-tile-ready-text);
}
.room-tile-status-confirm {
  display: block;
  background: transparent;
  margin-top: 4px;
  padding: 1px 0 0;
  font-size: var(--room-tile-status-confirm-size, 9.5px);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  color: var(--room-tile-status-confirm-text);
  opacity: 0.85;
}

/* ป้ายเตือน "ใกล้เช็คเอาท์"/"เลยเช็คเอาท์" (หน้าเช็คอิน/เช็คเอาท์ เฉพาะห้องที่มีผู้เข้าพักอยู่จริง)
   ใช้ token สีอิสระของตัวเอง (roomTileCheckoutWarn.../roomTileCheckoutOverdue...) ไม่ผูกกับ badge-amber/badge-red
   ที่ใช้กับป้ายสถานะบิล/การชำระเงินอยู่แล้ว ปรับได้แยกจากหน้าตั้งค่า → สีธีม → กลุ่ม "ผังห้อง"
   ตั้งใจแยกทั้ง .room-tile-checkout-alert (ตัวป้าย) และ .room-tile.is-checkout-warning/-overdue (กรอบทั้งไทล์)
   เพื่อให้มองเห็นห้องที่ต้องรีบตามได้ทันทีแม้สแกนดูผังไกลๆ ไม่ต้องอ่านตัวหนังสือในป้ายก่อน */
.room-tile-checkout-alert {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1px 3px;
  margin-top: 3px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: var(--room-tile-status-ready-size, 9.5px);
  font-weight: 700;
  max-width: 100%;
  box-sizing: border-box;
  white-space: normal;
  vertical-align: top;
  line-height: 1.35;
}
.room-tile-checkout-alert-icon { font-size: 10px; }
/* บังคับให้เวลานับถอยหลังตกไปอยู่บรรทัดใหม่ ไม่เบียดกับป้าย "เลยเช็คเอาท์แล้ว"/"ใกล้เช็คเอาท์" จนโดนตัดด้วย ellipsis */
.room-tile-checkout-countdown {
  flex-basis: 100%;
  text-align: center;
}
.room-tile-checkout-alert.is-warning {
  background: color-mix(in srgb, var(--room-tile-checkout-warn-bg) 70%, transparent);
  color: var(--room-tile-checkout-warn-text);
}
.room-tile-checkout-alert.is-overdue {
  background: color-mix(in srgb, var(--room-tile-checkout-overdue-bg) 75%, transparent);
  color: var(--room-tile-checkout-overdue-text);
}
.room-tile.is-checkout-warning .room-tile-inner {
  outline: 2px solid color-mix(in srgb, var(--room-tile-checkout-warn-text) 70%, transparent);
  outline-offset: 1px;
}
.room-tile.is-checkout-overdue .room-tile-inner {
  outline: 2px solid var(--room-tile-checkout-overdue-text);
  outline-offset: 1px;
}
/* พื้นหลังทั้งไทล์เมื่อ "เลยเช็คเอาท์แล้ว" — ใช้ token อิสระของตัวเอง (ไม่ผูกกับ --bento-pink ของสถานะ "เข้าพัก" ปกติ)
   ปรับสีพื้นตอนเลยเช็คเอาท์ในหน้าตั้งค่า → สีธีม → ผังห้อง ได้โดยไม่กระทบสีพื้นห้องเข้าพักปกติ */
.room-tile.st-occupied.is-checkout-overdue {
  background: var(--room-tile-checkout-overdue-tile-bg);
  color: var(--room-tile-checkout-overdue-tile-text);
}
.room-tile.st-occupied.is-checkout-overdue .room-tile-inner {
  border-color: color-mix(in srgb, var(--room-tile-checkout-overdue-tile-text) 55%, transparent);
}
.room-tile.st-occupied.is-checkout-overdue .room-tile-type {
  color: var(--room-tile-checkout-overdue-tile-text);
  opacity: 0.85;
}

/* ---------- สลับมุมมอง (ผังห้องพัก / รายการ) ---------- */
.view-switch {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.view-switch button {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.view-switch button.active {
  background: var(--panel);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(28, 35, 38, 0.10);
}

@media (max-width: 860px) {
  /* บนมือถือ view-switch ต้องพอดีความกว้างจอ — แบ่ง 3 ปุ่มเท่ากันแทนที่จะดันล้น */
  .view-switch {
    width: 100%;
    padding: 3px;
  }
  .view-switch button {
    flex: 1 1 0;
    justify-content: center;
    padding: 9px 4px;
    font-size: 12.5px;
    gap: 5px;
    white-space: nowrap;
  }
}

@media (max-width: 420px) {
  /* จอแคบมาก: เหลือแค่ไอคอน กันข้อความตัดบรรทัด/ล้น */
  .view-switch button {
    padding: 10px 4px;
  }
  .view-switch button .view-switch-label {
    display: none;
  }
  .view-switch button i {
    font-size: 18px;
  }
}

/* ---------- ค้นหา (ช่องค้นหามีไอคอนแว่นขยาย + ปุ่มล้าง) ---------- */
.search-wrap {
  position: relative;
  max-width: 340px;
  flex: 1;
  min-width: 220px;
}
.search-wrap .ti-search {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 15px;
}
.search-wrap input {
  width: 100%;
  padding: 10px 34px 10px 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  outline: none;
  font-size: 13.5px;
}
.search-wrap input:focus {
  border-color: var(--accent);
}
.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-faint);
  padding: 4px;
}
.search-clear:hover {
  color: var(--text);
}

/* ---------- การ์ดผังอาคาร (ใช้ครอบ building-tabs + floor-block) ---------- */
.blueprint-card {
  background: var(--bg-soft);
  border: none;
  border-radius: 18px;
  padding: 20px 22px;
}

/* แท็บเลือกตึก/อาคาร — pill เต็มแถว */
.building-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.building-tab {
  flex: 1;
  min-width: 96px;
  text-align: center;
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  border: none;
  background: transparent;
  transition: background 0.15s, color 0.15s;
}
.building-tab.active {
  background: var(--panel);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(28, 35, 38, 0.10);
}
.building-tab .b-count {
  font-weight: 500;
  font-size: 11px;
  opacity: 0.75;
  margin-left: 4px;
}

/* ---------- บล็อกชั้น (ใช้แสดงทุกชั้นของตึกต่อกันในหน้าเดียว) ---------- */
.floor-block {
  margin-bottom: 20px;
}
.floor-block:last-child {
  margin-bottom: 0;
}
.floor-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.floor-label .line {
  flex: 1;
  height: 1px;
  background: var(--line);
}
.floor-group-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 3px 9px;
  border-radius: 999px;
}

.search-group-heading {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-faint);
  margin: 18px 0 8px;
  letter-spacing: 0.02em;
}
.search-group-heading:first-child {
  margin-top: 0;
}

/* ---------- ตาราง Timeline / รายวัน (มุมมองเสริมแบบ Gantt) ---------- */
.timeline-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.timeline-scroll {
  overflow-x: auto;
}
.timeline-grid {
  display: grid;
  grid-template-columns: 148px repeat(var(--days), 68px);
  min-width: max-content;
}
.tl-head, .tl-room-col, .tl-cell {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.tl-head {
  position: sticky;
  top: 0;
  background: var(--bg-soft);
  padding: 10px 6px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  z-index: 2;
}
.tl-head.today {
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-dim);
}
.tl-head-room {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 3;
  background: var(--bg-soft);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  display: flex;
  align-items: center;
}
.tl-room-col {
  position: sticky;
  left: 0;
  background: var(--row-room-bg);
  padding: 10px 14px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
}
.tl-room-num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
}
.tl-room-type {
  font-size: 11px;
  color: var(--text-faint);
}
.tl-cell {
  position: relative;
  min-height: 46px;
}
.tl-row-bg:nth-child(odd) .tl-room-col,
.tl-row-bg:nth-child(odd) .tl-cell {
  background: var(--bg-soft);
}
.tl-bar {
  position: absolute;
  top: 7px;
  bottom: 7px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 9px;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
  transition: filter 0.1s;
}
.tl-bar:hover {
  filter: brightness(1.08);
}
.tl-bar.checked_in { background: var(--blue); }
.tl-bar.reserved { background: var(--amber); }

/* ---------- Calendar Gantt (cal-*) ---------- */
.cal-scroll {
  overflow-x: auto;
  overflow-y: visible;
}
.cal-grid {
  display: grid;
  grid-template-columns: var(--cal-room-w, 148px) repeat(var(--cal-days), var(--cal-cell-w, 68px));
  width: max-content;
  position: relative;
}
/* header */
.cal-room-head {
  position: sticky; left: 0; top: 0; z-index: 3;
  background: var(--cal-head-bg);
  padding: 10px 14px;
  font-size: 12px; font-weight: 700; color: var(--text-dim);
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.cal-head-cell {
  position: sticky; top: 0; z-index: 2;
  background: var(--cal-head-bg);
  text-align: center;
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.cal-head-cell.today {
  background: var(--accent-dim);
}
.cal-day-name { font-size: 10px; color: var(--text-faint); }
.cal-day-num  { font-size: 14px; font-weight: 700; color: var(--text); }
.cal-head-cell.today .cal-day-num { color: var(--accent); }
.cal-month-name { font-size: 10px; color: var(--text-faint); }
/* room label col */
.cal-row-room {
  position: sticky; left: 0; z-index: 1;
  background: var(--row-room-bg);
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  cursor: pointer;
  display: flex; flex-direction: column; justify-content: center;
  min-height: 56px;
}
.cal-row-room:hover { background: var(--bg-soft); }
.cal-room-num  { font-family: var(--font-mono); font-weight: 700; font-size: 14px; }
.cal-room-type { font-size: 11px; color: var(--text-faint); }
/* cells */
.cal-cell {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-height: 56px;
  cursor: pointer;
}
.cal-cell:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.cal-today-col { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.cal-today-col:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.cal-maint {
  background: repeating-linear-gradient(
    135deg,
    var(--cal-maint-stripe) 0, var(--cal-maint-stripe) 4px,
    var(--line) 4px, var(--line) 8px
  );
  cursor: default;
}
/* alternating row tint — ใช้ nth-child ไม่ได้กับ display:grid ข้าม row
   ใช้ CSS Grid subgrid ไม่ได้ใน Safari เก่า — ข้ามได้ */
/* bar layer */
.cal-bar-layer {
  grid-column: 1 / -1;
  position: absolute;
  left: 0; width: 100%;
  pointer-events: none;
}
/* bar — แคปซูลเตี้ย อยู่กึ่งกลางแถว เว้นระยะขอบบน-ล่างให้เห็นชัด */
.cal-bar {
  position: absolute;
  top: 16px; bottom: 16px;
  border-radius: 12px;
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  overflow: hidden; white-space: nowrap;
  text-align: center;
  cursor: pointer;
  transition: filter .1s;
  pointer-events: auto;
}
.cal-bar:hover { filter: brightness(1.1); }
.cal-bar.checked_in { background: var(--blue); color: var(--cal-bar-checkedin-text); }
.cal-bar.reserved   { background: var(--amber); color: var(--cal-bar-reserved-text); }
/* legend */
.cal-legend {
  display: inline-flex; gap: 16px; flex-wrap: wrap;
  font-size: 12px;
  font-weight: 400;
  font-family: var(--font-sans, sans-serif);
  margin-left: 14px;
  vertical-align: middle;
}
.cal-legend span { display: flex; align-items: center; gap: 5px; }
.cal-legend-dot { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.cal-empty { padding: 48px; text-align: center; color: var(--text-faint); }

/* ---------- Calendar toolbar (nav + view-switch) ---------- */
.cal-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.cal-nav {
  display: flex;
  gap: 8px;
  align-items: center;
}
.cal-range-label {
  font-size: 13px;
  min-width: 180px;
  text-align: center;
  font-family: var(--font-mono);
}

/* ---------- Calendar filter chip rows (โซน/ตึก) ---------- */
.cal-filter-row {
  margin-bottom: 10px;
}

/* sticky room column ได้ขอบลอยนุ่มๆ แทนเส้นขอบตรงๆ ให้รู้สึกลอยเหนือคอลัมน์วันที่เวลาเลื่อนแนวนอน */
.cal-room-head,
.cal-row-room {
  box-shadow: 2px 0 6px -3px rgba(28, 35, 38, 0.18);
}

/* ===================================================================
   Mobile redesign — ปฏิทินการจอง (คุมเฉพาะ cal-* เพื่อไม่กระทบหน้าอื่น)
   เป้าหมาย: ย่อคอลัมน์ห้อง/วัน ลดระยะ padding ทุกจุด และเปลี่ยนแถบตัวกรอง
   โซน/ตึกจาก wrap (กินพื้นที่แนวตั้งเยอะ) เป็นเลื่อนแนวนอนแถวเดียว แบบชิปสมัยใหม่
   =================================================================== */
@media (max-width: 640px) {
  #cal-root .section-title {
    width: 100%;
  }
  #cal-root .cal-legend {
    margin-left: 0;
    margin-top: 4px;
    gap: 10px;
    font-size: 11px;
    width: 100%;
  }
  .cal-toolbar {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }
  .cal-nav {
    order: 1;
    flex: 1 1 auto;
    justify-content: space-between;
  }
  .cal-range-label {
    min-width: 0;
    flex: 1;
    font-size: 12.5px;
  }
  .cal-toolbar .view-switch {
    order: 2;
  }
  #cal-today {
    order: 0;
  }

  /* แถบเลือกโซน/ตึก: เลื่อนแนวนอนแถวเดียว แทนการ wrap ล้นจอ */
  .cal-filter-row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    margin: 0 -16px 10px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .cal-filter-row::-webkit-scrollbar { display: none; }
  .cal-filter-row .chip {
    flex: 0 0 auto;
    padding: 6px 12px;
    font-size: 12px;
  }

  .timeline-card {
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(28, 35, 38, 0.06);
  }

  /* คอลัมน์/แถวย่อลง ให้เห็นวันได้มากขึ้นในความกว้างจอเท่าเดิม */
  .cal-room-head {
    padding: 8px 10px;
    font-size: 11px;
  }
  .cal-row-room {
    padding: 6px 10px;
    min-height: 44px;
  }
  .cal-room-num  { font-size: 12.5px; }
  .cal-room-type { font-size: 9.5px; }
  .cal-head-cell {
    padding: 5px 2px;
  }
  .cal-day-name   { font-size: 9px; }
  .cal-day-num    { font-size: 12.5px; }
  .cal-month-name { font-size: 9px; }
  .cal-cell { min-height: 44px; }
  .cal-bar {
    top: 9px; bottom: 9px;
    font-size: 9.5px;
    border-radius: 9px;
  }

  /* เลื่อนทีละวันแบบนุ่มนวล พร้อม snap ให้หยุดพอดีคอลัมน์ */
  .cal-scroll {
    scroll-snap-type: x proximity;
    scroll-padding-left: var(--cal-room-w, 96px);
  }
  .cal-head-cell { scroll-snap-align: start; }
}

@media (max-width: 380px) {
  .cal-room-type { display: none; }
  .cal-range-label { font-size: 11.5px; }
}

.tl-maintenance {
  background: repeating-linear-gradient(
    135deg,
    var(--cal-maint-stripe) 0,
    var(--cal-maint-stripe) 4px,
    var(--line) 4px,
    var(--line) 8px
  );
}

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.info-row:last-child {
  border-bottom: none;
}
.info-row .k {
  color: var(--text-dim);
}
.info-row .v {
  font-weight: 600;
  text-align: right;
}
.charge-line {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 6px 0;
}

/* ---------- บิลของการเข้าพักนี้ (การ์ดรายการบิล พร้อมสถานะชำระแล้ว/ค้างชำระ ในหน้ารายละเอียดห้อง) ---------- */
.room-invoice-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  background: var(--panel);
}
.room-invoice-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.room-invoice-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13.5px;
  cursor: pointer;
  border-top: 1px solid var(--line);
  transition: opacity 0.15s ease;
}
.room-invoice-row:first-of-type {
  border-top: none;
  padding-top: 0;
}
.room-invoice-row:hover {
  opacity: 0.75;
}

/* ---------- ค่าใช้จ่ายเพิ่มเติม (รายการแยกกรอบ + ป้ายสถานะชำระแล้ว/ค้างชำระ) ---------- */
.charge-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.charge-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.charge-card-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.charge-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  transition: border-color 0.15s ease;
}
.charge-card.is-paid {
  border-left: 3px solid var(--badge-green-text);
}
.charge-card.is-pending {
  border-left: 3px solid var(--badge-red-text);
}
.charge-card-icon {
  flex: none;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 13px;
}
.charge-card.is-paid .charge-card-icon {
  background: var(--badge-green-bg);
  color: var(--badge-green-text);
}
.charge-card.is-pending .charge-card-icon {
  background: var(--badge-red-bg);
  color: var(--badge-red-text);
}
.charge-card-mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.charge-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.charge-card-qty {
  font-weight: 500;
  color: var(--text-faint);
  font-size: 12px;
}
.charge-status-pill {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.5;
}
.charge-status-pill.paid {
  background: var(--badge-green-bg);
  color: var(--badge-green-text);
}
.charge-status-pill.pending {
  background: var(--badge-red-bg);
  color: var(--badge-red-text);
}
.charge-card-amt {
  flex: none;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.charge-section-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  border: 1px dashed var(--line-strong);
  font-size: 13px;
  font-weight: 700;
}
.charge-summary-box {
  margin-top: 12px;
  padding: 4px 0 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.charge-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 700;
}
.charge-summary-row.is-paid {
  background: var(--badge-green-bg);
  color: var(--badge-green-text);
}
.charge-summary-row.is-pending {
  background: var(--badge-red-bg);
  color: var(--badge-red-text);
}
.charge-summary-row.is-clear {
  background: var(--badge-green-bg);
  color: var(--badge-green-text);
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.modal-actions .btn {
  flex: 1;
}
/* ปุ่มไอคอนล้วน ขนาดกะทัดรัด ใช้สำหรับ action รอง (เช่น "ย้ายห้อง") ที่วางแถวเดียวกับปุ่มหลัก
   ไม่ต้องการให้ยืดเต็มพื้นที่เท่าปุ่มหลัก จึงตรึงความกว้างคงที่แทน flex:1 ปกติ */
.modal-actions .btn-square {
  flex: 0 0 46px;
  width: 46px;
  padding: 0;
  font-size: 16.5px;
  background: var(--bg-soft);
  color: var(--text-dim);
}
.modal-actions .btn-square:hover {
  background: var(--btn-hover-bg);
  color: var(--text);
  border-color: var(--line-strong);
}

/* ---------- Modal overlay (ใช้ร่วมกันทุกหน้าที่ต้องมีฟอร์ม popup) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 35, 38, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}
/* Popup รูปภาพขนาดใหญ่ (คลิ๊กรูปพรีวิว เช่น รูปผู้เข้าพัก) — z-index สูงกว่า .modal-overlay เสมอ
   เพราะมักถูกเปิดซ้อนจากข้างในฟอร์มที่เป็น modal อยู่แล้ว (เช่น ฟอร์มเพิ่มผู้เข้าพักใหม่) */
.image-lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 14, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 32px;
  cursor: zoom-out;
  animation: image-lightbox-fade-in 0.12s ease-out;
}
@keyframes image-lightbox-fade-in { from { opacity: 0; } to { opacity: 1; } }
.image-lightbox-img {
  width: var(--photo-lightbox-w, 46vw);
  height: var(--photo-lightbox-h, 46vh);
  max-width: var(--photo-lightbox-w, 46vw);
  max-height: var(--photo-lightbox-h, 46vh);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
  cursor: default;
  touch-action: none;
  user-select: none;
}
.image-lightbox-zoom-controls {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 4px;
  cursor: default;
}
.image-lightbox-zoom-btn,
.image-lightbox-zoom-reset {
  border: none;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}
.image-lightbox-zoom-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 16px;
}
.image-lightbox-zoom-btn:hover,
.image-lightbox-zoom-reset:hover { background: rgba(255, 255, 255, 0.22); }
.image-lightbox-zoom-reset {
  min-width: 52px;
  height: 34px;
  border-radius: 17px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 0 8px;
}
.image-lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: none;
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}
.image-lightbox-close:hover { background: rgba(255, 255, 255, 0.28); }
.modal-card {
  max-width: 680px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
}
/* การ์ด modal แบบกว้าง — ใช้กับฟอร์มที่มีฟิลด์เยอะ (เช่น เช็คอิน, สัญญาเช่า)
   วางเป็นแนวนอน 2 คอลัมน์ได้ ลดความสูงรวมของฟอร์ม ป้องกันเนื้อหาล้นจอแนวตั้งบนจอเล็ก */
.modal-card-wide {
  max-width: 1400px;
  max-height: 94vh;
  padding: 18px;
}
/* แบ่งฟอร์มเช็คอิน (และฟอร์มอื่นที่ยาวคล้ายกัน) เป็น 2 คอลัมน์เคียงข้างกัน
   เพื่อใช้พื้นที่แนวนอนของ .modal-card-wide แทนการเรียงต่อกันยาวลงแนวตั้ง */
.checkin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 28px;
  align-items: start;
}
.checkin-col {
  min-width: 0;
}
.checkin-col-title {
  font-family: var(--font-serif);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.01em;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
@media (max-width: 900px) {
  .checkin-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
}
/* ลดระยะห่าง/ขนาดฟิลด์ภายในฟอร์มเช็คอิน 2 คอลัมน์ ให้ฟอร์มเตี้ยลง ไม่ล้นจอแนวตั้ง
   (ปรับเฉพาะภายใน .checkin-grid เท่านั้น ไม่กระทบฟอร์มอื่นในระบบ) */
.checkin-grid .field,
.checkin-compact-row .field {
  margin-bottom: 10px;
}
.checkin-grid .field label,
.checkin-compact-row .field label {
  margin-bottom: 4px;
  font-size: 11.5px;
  text-align: center;
}
/* ช่อง "ออกใบเสร็จ/ใบกำกับภาษีในนาม" + ข้อมูลบริษัท (ชื่อ/เลขผู้เสียภาษี/สาขา/ที่อยู่) และแถวการชำระเงิน/ภาษี
   (สถานะการชำระค่าห้อง/วิธีการชำระเงิน/ภาษีมูลค่าเพิ่ม/อัตราภาษี) — label ชิดซ้ายตรงกับขอบช่อง แทนการจัดกึ่งกลาง
   แบบฟิลด์อื่นในฟอร์มเช็คอิน (ใช้ selector ที่มี #id ให้ specificity สูงกว่ากฎด้านบน ไม่ต้องพึ่ง !important) */
.checkin-grid #stay-billing-company-row .field label,
.checkin-grid #stay-company-fields-wrap .field label,
.checkin-grid #stay-company-address-wrap label,
.checkin-grid #stay-payment-vat-row .field label {
  text-align: left;
}
.checkin-grid .field input,
.checkin-grid .field select,
.checkin-compact-row .field input,
.checkin-compact-row .field select {
  padding: 8px 11px;
  font-size: 13.5px;
}
.checkin-grid .field .readonly-field,
.checkin-compact-row .field .readonly-field {
  padding: 8px 11px;
  font-size: 13.5px;
}
.checkin-grid .grid-3,
.checkin-grid .grid-auto,
.checkin-grid .grid-2,
.checkin-compact-row.grid-3 {
  gap: 12px;
}
/* ราคาห้อง/คืน แคบลงอีกหน่อย ให้ยอดค่าห้องรวม (ที่มีรายละเอียดสูตรคำนวณยาวกว่า) กว้างพอไม่ตกไปอีกบรรทัด */
@media (min-width: 861px) {
  .stay-rate-total-grid {
    grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr);
  }
}
.checkin-col-title {
  margin-bottom: 8px;
  padding-bottom: 5px;
  font-size: 12.5px;
}

/* ── Stepper (ผู้ใหญ่ / เด็ก) ────────────────────── */
.stepper-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  height: 38px;
}
.stepper-btn {
  flex: 0 0 38px;
  height: 100%;
  background: var(--bg-soft);
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s;
  user-select: none;
}
.stepper-btn:hover {
  background: var(--line);
}
.stepper-btn:active {
  background: var(--accent);
  color: #fff;
}
.stepper-input {
  flex: 1;
  border: none !important;
  border-left: 1px solid var(--line) !important;
  border-right: 1px solid var(--line) !important;
  border-radius: 0 !important;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  background: var(--panel) !important;
  -moz-appearance: textfield;
  height: 100%;
  padding: 0 !important;
}
.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}
/* ตัวแปรเล็กลงของ stepper (option A จากตัวอย่างที่เลือก) — ใช้เฉพาะจุดที่ต้องการให้เล็กลง
   ผ่าน class เสริม .stepper-wrap-sm ไม่กระทบ .stepper-wrap ปกติที่ใช้อยู่จุดอื่น (เช่น ผู้ใหญ่/เด็ก) */
.stepper-wrap-sm {
  height: 28px;
}
.stepper-wrap-sm .stepper-btn {
  flex: 0 0 28px;
  font-size: 14px;
}
.stepper-wrap-sm .stepper-input {
  font-size: 13px;
}

/* ===== Radio card — เลือกโหมดแบบการ์ด เช่น โหมดทำความสะอาดห้อง ===== */
.radio-card-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.radio-card:hover {
  border-color: var(--line-strong);
}
.radio-card input[type="radio"] {
  width: auto;
  margin-top: 3px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.radio-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.radio-card-title {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.radio-card-sub {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* ===================================================================
   หน้า "ตั้งค่า" → แท็บ "ธีม/สี/ฟอนต์" (appearance — รวมฟอนต์/สีธีม/สีไอคอนเมนูเป็นหน้าเดียว)
   ส่วนนี้คือตัวแก้สีทุกตัวแปร + กรอบ Preview จริง
   กรอบ preview ใช้คลาส component จริง (.btn, .badge, .stat, .room-tile,
   .nav-item, .chip ฯลฯ) ครอบด้วย CSS variable ชุดใหม่ที่ id="appearance-preview-scope"
   (หน้านี้รวมฟอนต์/สีธีม/สีไอคอนเมนูเป็นหน้าเดียวแล้ว ดู SettingsPage.renderAppearanceSection ใน settings.js)
   เพื่อให้เห็นผลตรงกับของจริงทุกหน้า ไม่ใช่แค่สวอตช์สีลอยๆ
   =================================================================== */
.theme-preview-wrap {
  background: #EEF0F1;
  padding: 18px;
  border-radius: 16px;
}

.theme-preview-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #5C6A70;
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}

.theme-preview-panel {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
}

/* คลิกที่องค์ประกอบใน preview แล้วเลื่อนไปกระพริบ field สีที่เกี่ยวข้องในฝั่งขวา */
.theme-jump {
  cursor: pointer;
  outline-offset: 2px;
  transition: outline-color 0.15s, filter 0.1s;
}
.theme-jump:hover {
  filter: brightness(1.06);
  outline: 2px dashed var(--accent);
}
.theme-jump:active {
  filter: brightness(0.97);
}

@keyframes theme-field-flash {
  0%, 100% { background: transparent; box-shadow: none; }
  15%, 45%, 75% { background: var(--accent-dim); box-shadow: 0 0 0 2px var(--accent); }
  30%, 60%, 90% { background: transparent; box-shadow: none; }
}
.theme-field-flash {
  animation: theme-field-flash 1.4s ease-in-out;
  border-radius: var(--radius-md);
}

.theme-preview-section {
  margin-bottom: 18px;
}

.theme-preview-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.theme-preview-stats {
  margin-bottom: 18px;
}

.theme-preview-rooms {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.theme-preview-split {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 14px;
}

.theme-preview-sidebar {
  background: var(--sidebar-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-preview-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
}

/* กล่อง "ตั้งค่าสี" แต่ละหมวดในหน้าตั้งค่าธีม (ฝั่งขวาของหน้า) — ใช้สีพื้นหลังคงที่ของตัวเอง
   แยกออกจาก .card / --card-bg โดยตั้งใจ เดิมใช้ class="card theme-group-card" ร่วมกัน
   ทำให้ปรับ "พื้นหลังการ์ดสรุป" (--card-bg) ที่ใช้ในแอปจริงแล้ว กล่องตั้งค่าทั้งหน้าเปลี่ยนสีตามไปด้วย
   มองไม่เห็น field ที่จะปรับต่อ ตอนนี้กล่องตั้งค่าใช้สีคงที่เสมอ ไม่ขึ้นกับธีมที่กำลังปรับอยู่ */
.theme-group-card {
  background: #FAFBFB;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
}

@media (max-width: 640px) {
  .theme-preview-split {
    grid-template-columns: 1fr;
  }
}

/* ---------- กลุ่มสีแต่ละการ์ด ---------- */
.theme-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}

.theme-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px 18px;
}

.theme-field {
  padding: 6px;
  margin: -6px;
  border-radius: var(--radius-md);
}

.theme-field label {
  display: block;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}

/* ---------- ช่องเลือกสี (color picker + hex) ---------- */
.theme-color-input {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  background: var(--panel);
  transition: border-color 0.15s;
}
.theme-color-input:focus-within {
  border-color: var(--accent);
}

.theme-color-picker {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}
.theme-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}
.theme-color-picker::-webkit-color-swatch {
  border: 1px solid var(--line);
  border-radius: 7px;
}
.theme-color-picker::-moz-color-swatch {
  border: 1px solid var(--line);
  border-radius: 7px;
}

/* สวอตช์ตัวอย่างไอคอนจริง — ใช้ในหน้าตั้งค่า "สีไอคอนเมนู" ข้างช่องเลือกสี ให้เห็นไอคอนจริงพร้อมสีที่กำลังปรับ */
.sidebaricon-preview-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebaricon-preview-badge .ti {
  font-size: 16px;
}

.theme-color-hex {
  flex: 1;
  width: 100%;
  border: none;
  background: none;
  padding: 4px 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  text-transform: uppercase;
}
.theme-color-hex:focus {
  outline: none;
}

/* --- Building drag & drop --- */
.entity-card-drag-handle {
  position: absolute;
  top: 50%;
  left: 8px;
  transform: translateY(-50%);
  color: var(--text-faint);
  opacity: 0;
  cursor: grab;
  font-size: 16px;
  transition: opacity 0.15s;
  padding: 4px;
}
.entity-card:hover .entity-card-drag-handle {
  opacity: 1;
}
.entity-card[draggable] {
  cursor: pointer;
}
.entity-card.dragging {
  opacity: 0.4;
  border-style: dashed;
}
.entity-card.drag-over {
  border-color: var(--accent);
  background: var(--bg-hover);
  transform: scale(1.02);
}

/* --- Connection banner (js/connection-monitor.js) ---
   แจ้งเตือนลอยเหนือทุกหน้าเมื่อต่อ NAS/เซิร์ฟเวอร์ไม่ได้ระหว่างใช้งานอยู่ */
.connection-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: #FFFFFF;
  background: var(--red);
  transform: translateY(-100%);
  transition: transform 0.2s ease, background 0.2s ease;
}
.connection-banner.is-hidden {
  display: none;
}
.connection-banner.is-visible {
  transform: translateY(0);
}
.connection-banner.is-reconnected {
  background: var(--green);
}
.connection-banner .connection-banner-retry {
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: transparent;
  color: #FFFFFF;
  border-radius: var(--radius-md);
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.connection-banner .connection-banner-retry:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ---------- Splash / connection-check screen (js/app.js renderLoadingScreen) ----------
   ใช้ตอนเปิดแอปครั้งแรกระหว่างรอเช็คว่าต่อเซิร์ฟเวอร์ได้ไหม — ตั้งใจแยกจาก .card ทั่วไป
   เพราะต้องการความรู้สึก "กำลังมีชีวิต/กำลังทำงาน" มากกว่าการ์ดนิ่งๆ ทั่วแอป */
.splash-card {
  position: relative;
  max-width: 360px;
  width: 100%;
  text-align: center;
  padding: 52px 36px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(20, 30, 30, 0.05), 0 20px 44px -20px rgba(20, 108, 104, 0.28);
  overflow: hidden;
  animation: splash-rise 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes splash-rise {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* แสงฟุ้งสีแบรนด์เบาๆ ด้านบนการ์ด ให้มีมิติแทนพื้นเรียบแบนแบบเดิม */
.splash-glow {
  position: absolute;
  top: -66%;
  left: 50%;
  width: 300px;
  height: 300px;
  transform: translateX(-50%);
  background: radial-gradient(circle, var(--accent-dim) 0%, transparent 68%);
  pointer-events: none;
}
.splash-brand {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  margin-bottom: 40px;
}
.splash-brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  animation: splash-pulse 1.7s ease-in-out infinite;
}
@keyframes splash-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
}
/* สปินเนอร์แบบ conic-gradient — โค้งไล่สีเข้ม-อ่อนของแบรนด์ แทนวงแหวนเทาๆ ทั่วไป */
.splash-spinner {
  position: relative;
  width: 36px;
  height: 36px;
  margin: 0 auto 22px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent-deep) 0deg, var(--accent) 110deg, transparent 210deg, transparent 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  animation: spin 0.9s linear infinite;
}
.splash-status {
  position: relative;
  font-size: 13px;
  color: var(--text-dim);
}
.splash-dots span {
  display: inline-block;
  animation: splash-dots 1.4s infinite;
  animation-fill-mode: both;
}
.splash-dots span:nth-child(2) { animation-delay: 0.2s; }
.splash-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes splash-dots {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .splash-card { animation: none; }
  .splash-brand-dot { animation: none; }
  .splash-spinner { animation: none; border-top-color: var(--accent); }
  .splash-dots span { animation: none; opacity: 1; }
}

/* ---------- Image upload field (รูปสินค้า พร้อมครอปรูป) ---------- */
.image-upload-field {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.image-upload-preview {
  position: relative;
  width: 76px;
  height: 76px;
  flex-shrink: 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  transition: border-color 0.15s;
}
.image-upload-preview:hover {
  border-color: var(--accent);
}
.image-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.image-upload-preview i {
  font-size: 26px;
}
.image-upload-preview-overlay {
  position: absolute;
  inset: 0;
  background: rgba(28, 35, 38, 0.55);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.15s;
}
.image-upload-preview:hover .image-upload-preview-overlay {
  opacity: 1;
}
.image-upload-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}
.image-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.image-upload-btn:hover {
  background: var(--btn-hover-bg);
  border-color: var(--btn-hover-border);
}
.image-upload-btn:active {
  transform: scale(0.97);
}
.image-upload-btn i {
  font-size: 14px;
}
.image-upload-remove {
  background: none;
  border: none;
  padding: 0;
  color: var(--btn-danger-text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.image-upload-remove:hover {
  text-decoration: underline;
}
.image-upload-hint {
  font-size: 11.5px;
  color: var(--text-faint);
  margin: 0;
}

.field-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--btn-bg);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.field-action-btn:hover {
  background: var(--btn-hover-bg);
  border-color: var(--btn-hover-border);
}
.field-action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--btn-bg);
}
.field-action-btn i.ti-loader-2 {
  animation: spin 0.8s linear infinite;
}

/* ---------- Crop overlay (ครอปรูปสินค้าก่อนอัปโหลด) — ซ้อนบน modal-overlay/lightbox เสมอ ---------- */
.crop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 14, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 24px;
  animation: image-lightbox-fade-in 0.12s ease-out;
}
.crop-card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 20px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.crop-card-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 14px;
}
.crop-image-wrap {
  width: 100%;
  height: min(60vh, 380px);
  background: #1C2326;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.crop-image-wrap img {
  display: block;
  max-width: 100%;
}
.crop-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}


/* ---------- Wifi slip editor — แถวขั้นตอน (openWifiSlipEditor ใน checkin.js) ---------- */
.wifi-step-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.wifi-step-row .wifi-step-text {
  min-height: 44px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.wifi-step-row .wifi-step-text:hover {
  border-color: var(--line-strong);
}
.wifi-step-row .wifi-step-text:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.wifi-step-row .wifi-step-align {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235C6A70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 8px center;
  background-size: 13px;
  color: var(--text);
  transition: border-color 0.15s;
}
.wifi-step-row .wifi-step-align:hover {
  border-color: var(--line-strong);
}
.wifi-step-row .wifi-step-align:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.wifi-step-icon-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--btn-bg);
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.wifi-step-icon-btn:hover:not(:disabled) {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.wifi-step-icon-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.wifi-step-icon-btn-danger:hover:not(:disabled) {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}
