/* =========================================================================
   KE Theme — ke-core.css  v2.1
   แกนกลางที่ใช้ร่วมกันทั้ง admin และ website: token โครงสร้าง, reset, utilities,
   grid, การ์ด, ตาราง, การนำทาง, ปุ่ม, badge, alert, ฟอร์ม, dropdown, dialog,
   drawer, accordion, toast, progress, list, หน้า auth/error, print

   กฎ: ไม่มีค่าสีฝังในไฟล์ ทุกสีอ้าง --cs-* จากไฟล์แบรนด์
   ลำดับการโหลด
     หลังบ้าน:  brands/<brand>.css → ke-core.css → ke-admin.css → theme.js
                (หรือใช้ theme.css ซึ่งคือ core + admin รวมไฟล์เดียว)
     เว็บไซต์:  brands/<brand>.css → ke-core.css → ke-site.css → theme.js → ke-site.js

   ไฟล์ theme.css ถูกสร้างจาก build.sh อย่าแก้ theme.css ตรง ๆ ให้แก้ไฟล์ ke-*.css
   ========================================================================= */

/* ============ 0. Structural tokens ======================================
   :where() ทำให้ specificity เป็นศูนย์ ไฟล์แบรนด์จึง override ได้เสมอ
   แม้จะโหลดก่อนไฟล์นี้ ค่าในนี้เป็นขนาด ระยะ และเวลาเท่านั้น ไม่มีสี */
:where(:root) {
  --cs-radius-sm: max(2px, calc(var(--cs-radius-md) - 2px));
  --cs-radius-lg: calc(var(--cs-radius-md) + 4px);
  --cs-radius-pill: 999px;

  --cs-topbar-h: 64px;
  --cs-hnav-h: 48px;
  --cs-boxed-w: 1320px;
  --cs-content-pad-x: 32px;

  --cs-space-1: 4px;
  --cs-space-2: 8px;
  --cs-space-3: 12px;
  --cs-space-4: 16px;
  --cs-space-5: 24px;
  --cs-space-6: 32px;

  --cs-ease: 0.15s ease;

  /* สีเชิงความหมาย — ถ้าแบรนด์ไม่ได้กำหนด จะถอยไปใช้สีแบรนด์หลัก */
  --cs-primary: var(--cs-navy-900);
  --cs-primary-hover: var(--cs-navy-700);
  --cs-sidebar-bg: var(--cs-navy-900);
  --cs-sidebar-muted: var(--cs-meta-on-navy);
  --cs-sidebar-indicator: var(--cs-lime);
  --cs-topbar-bg: var(--cs-card);
  --cs-toast-bg: var(--cs-ink);
  --cs-toast-fg: var(--cs-card);
}

/* แถบข้างสีอ่อน — สลับ token ไม่ใช่สลับสี จึงไม่ละเมิดกฎไฟล์ */
:root[data-sidebar='light'] {
  --cs-sidebar-bg: var(--cs-card);
  --cs-sidebar-fg: var(--cs-ink);
  --cs-sidebar-muted: var(--cs-slate);
  --cs-sidebar-indicator: var(--cs-primary);
}
:root[data-theme='dark'] {
  color-scheme: dark;
}

/* ============ 1. Reset + base typography ================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}
body {
  font-family: var(--cs-font);
  font-size: 14px;
  font-weight: var(--cs-body-weight, 400);
  line-height: 1.5;
  color: var(--cs-ink);
  background: var(--cs-app-bg);
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3,
h4,
h5,
h6,
p,
ul,
ol,
dl,
dd,
figure,
blockquote {
  margin: 0;
}
ul,
ol {
  padding: 0;
  list-style: none;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
img,
svg,
video {
  max-width: 100%;
  display: block;
}
a {
  color: inherit;
}
[hidden] {
  display: none !important;
}
:focus-visible {
  outline: 2px solid var(--cs-primary);
  outline-offset: 2px;
}

h1,
.h1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
h2,
.h2 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
h3,
.h3 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}
h4,
.h4 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}
h5,
.h5 {
  font-size: 14px;
  font-weight: 600;
}
h6,
.h6 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cs-slate);
}
.lead {
  font-size: 16px;
  color: var(--cs-slate);
}
.prose p + p {
  margin-top: 12px;
}
.link {
  color: var(--cs-primary);
  font-weight: 500;
  text-decoration: none;
}
.link:hover {
  text-decoration: underline;
}
code,
kbd,
.mono {
  font-family: var(--cs-mono);
  font-size: 12.5px;
}
code {
  padding: 1px 5px;
  border-radius: var(--cs-radius-sm);
  background: var(--cs-surface);
  box-shadow: var(--cs-inset-border);
}
kbd {
  padding: 1px 6px;
  border-radius: var(--cs-radius-sm);
  background: var(--cs-card);
  box-shadow: inset 0 -1px 0 var(--cs-border-strong), var(--cs-inset-border);
}
hr,
.divider {
  border: none;
  border-top: 1px solid var(--cs-border);
  margin: 16px 0;
}
/* ข้อความตัวบาง สำหรับแบรนด์ที่กำหนด body เป็นน้ำหนักบาง ใช้กับข้อความขนาดใหญ่เท่านั้น */
.text-light {
  font-weight: 300;
}
/* หัวข้อรองแบบมีบุคลิก เช่น Marcellus ตัวพิมพ์ใหญ่ของ ALLY */
.text-display {
  font-family: var(--cs-font-display, var(--cs-font));
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ============ 2. Utilities ============================================== */
/* ตัวอักษร */
.text-xs { font-size: 11.5px; }
.text-sm { font-size: 12.5px; }
.text-base { font-size: 14px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 20px; }
.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.text-start { text-align: left; }
.text-center { text-align: center; }
.text-end { text-align: right; }
.text-upper { text-transform: uppercase; letter-spacing: 0.04em; }
.text-nowrap { white-space: nowrap; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }

/* สีตัวอักษร */
.text-ink { color: var(--cs-ink); }
.text-slate,
.text-muted { color: var(--cs-slate); }
.text-placeholder { color: var(--cs-placeholder); }
.text-primary { color: var(--cs-primary); }
.text-success { color: var(--cs-success); }
.text-danger { color: var(--cs-danger); }
.text-amber,
.text-warning { color: var(--cs-amber); }
.text-info { color: var(--cs-info); }

/* พื้นหลังและขอบ */
.bg-card { background: var(--cs-card); }
.bg-surface { background: var(--cs-surface); }
.bg-app { background: var(--cs-app-bg); }
.border { box-shadow: var(--cs-inset-border); }
.border-top { border-top: 1px solid var(--cs-border); }
.border-bottom { border-bottom: 1px solid var(--cs-border); }
.rounded { border-radius: var(--cs-radius-md); }
.rounded-lg { border-radius: var(--cs-radius-lg); }
.rounded-pill { border-radius: var(--cs-radius-pill); }
.shadow { box-shadow: var(--cs-shadow-card); }

/* การแสดงผล */
.d-none { display: none; }
.d-block { display: block; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.d-grid { display: grid; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0; min-width: 0; }
.flex-none { flex: none; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.w-100 { width: 100%; }
.h-100 { height: 100%; }
.min-w-0 { min-width: 0; }
.overflow-auto { overflow: auto; }
.position-relative { position: relative; }
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ระยะห่าง — สเกล 0,4,8,12,16,24,32 px */
.gap-0 { gap: 0; }
.gap-1 { gap: var(--cs-space-1); }
.gap-2 { gap: var(--cs-space-2); }
.gap-3 { gap: var(--cs-space-3); }
.gap-4 { gap: var(--cs-space-4); }
.gap-5 { gap: var(--cs-space-5); }
.gap-6 { gap: var(--cs-space-6); }
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--cs-space-1); }
.mt-2 { margin-top: var(--cs-space-2); }
.mt-3 { margin-top: var(--cs-space-3); }
.mt-4 { margin-top: var(--cs-space-4); }
.mt-5 { margin-top: var(--cs-space-5); }
.mt-6 { margin-top: var(--cs-space-6); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--cs-space-1); }
.mb-2 { margin-bottom: var(--cs-space-2); }
.mb-3 { margin-bottom: var(--cs-space-3); }
.mb-4 { margin-bottom: var(--cs-space-4); }
.mb-5 { margin-bottom: var(--cs-space-5); }
.mb-6 { margin-bottom: var(--cs-space-6); }
.ms-auto { margin-left: auto; }
.me-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.p-0 { padding: 0; }
.p-2 { padding: var(--cs-space-2); }
.p-3 { padding: var(--cs-space-3); }
.p-4 { padding: var(--cs-space-4); }
.p-5 { padding: var(--cs-space-5); }
.px-4 { padding-left: var(--cs-space-4); padding-right: var(--cs-space-4); }
.py-2 { padding-top: var(--cs-space-2); padding-bottom: var(--cs-space-2); }
.py-4 { padding-top: var(--cs-space-4); padding-bottom: var(--cs-space-4); }

/* กลุ่มจัดวางที่ใช้บ่อย */
.stack { display: flex; flex-direction: column; gap: var(--cs-space-3); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cs-space-2); }
.spacer { flex: 1 1 auto; }

/* ซ่อนตามขนาดจอ */
@media (max-width: 767px) {
  .hide-sm { display: none !important; }
}
@media (max-width: 1099px) {
  .hide-md { display: none !important; }
}
@media (min-width: 768px) {
  .show-sm { display: none !important; }
}

/* ============ 3. Grid ===================================================
   .grid + .cols-N ครอบการ์ดหลายใบ  ยุบเหลือ 2 คอลัมน์ที่ 1200px และ 1 คอลัมน์ที่ 768px
   .grid.cols-12 + .span-N สำหรับสัดส่วนไม่เท่ากัน เช่น 8/4 */
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr);
}
.grid + .grid,
.grid + .card,
.card + .grid {
  margin-top: 16px;
}
.grid > .card,
.grid > .card + .card,
.grid-2 > .card + .card {
  margin-top: 0;
}
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-9 { grid-column: span 9; }
.span-12,
.span-full { grid-column: 1 / -1; }
@media (max-width: 1200px) {
  .cols-3,
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-12 > [class*='span-'] { grid-column: 1 / -1; }
  .cols-12 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .cols-2,
  .cols-3,
  .cols-4 { grid-template-columns: minmax(0, 1fr); }
}

/* ตารางสองคอลัมน์รุ่นเดิม คงไว้เพื่อความเข้ากันได้ */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.grid-2 > .card {
  margin-top: 0;
}
@media (max-width: 1200px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* ============ 6. Cards + KPI ============================================ */
.card {
  background: var(--cs-card);
  border-radius: var(--cs-radius-md);
  box-shadow: var(--cs-inset-border);
  padding: 18px 20px;
  min-width: 0;
}
.card + .card {
  margin-top: 16px;
}
/* เนื้อหาชนขอบได้ เช่น การ์ดที่มีตารางเต็มความกว้าง */
.card-flush {
  padding: 0;
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-flush > .card-header {
  padding: 16px 20px 0;
}
/* หัวการ์ดมีเส้นคั่น ใช้เมื่อมี .card-body แยก */
.card-header.divided {
  align-items: center;
  margin: -18px -20px 18px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--cs-border);
}
.card-flush > .card-header.divided {
  margin: 0;
  padding: 14px 20px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
}
.card-subtitle {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--cs-slate);
}
.card-meta {
  font-size: 12px;
  color: var(--cs-slate);
}
.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.card-body {
  padding: 18px 20px;
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 18px -20px -18px;
  padding: 12px 20px;
  border-top: 1px solid var(--cs-border);
}
.card-flush > .card-footer {
  margin: 0;
}
.card-img {
  display: block;
  width: calc(100% + 40px);
  max-width: none;
  margin: -18px -20px 16px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--cs-radius-md) var(--cs-radius-md) 0 0;
  background: var(--cs-surface);
}
.card-soft {
  background: var(--cs-surface);
  box-shadow: none;
}
.card-hover {
  transition: box-shadow var(--cs-ease), transform var(--cs-ease);
}
.card-hover:hover {
  box-shadow: var(--cs-shadow-card), var(--cs-inset-border);
  transform: translateY(-1px);
}
a.card {
  display: block;
  text-decoration: none;
}
/* การ์ดที่เลือกได้ ใส่ radio/checkbox ไว้ข้างใน เช่น เลือกแพ็กเกจ */
.choice-card {
  position: relative;
  display: block;
  cursor: pointer;
  transition: box-shadow var(--cs-ease);
}
.choice-card:hover {
  box-shadow: inset 0 0 0 1px var(--cs-border-strong);
}
.choice-card:has(input:checked) {
  box-shadow: inset 0 0 0 2px var(--cs-primary);
}
.choice-card > input[type='radio'],
.choice-card > input[type='checkbox'] {
  position: absolute;
  top: 16px;
  right: 16px;
  accent-color: var(--cs-primary);
}

/* KPI tiles */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.kpi-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.kpi-grid > .card {
  margin-top: 0;
}
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 576px) {
  .kpi-grid.kpi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 575px) {
  .kpi-grid,
  .kpi-grid-3 { grid-template-columns: minmax(0, 1fr); }
}
.kpi {
  position: relative;
  padding: 16px 18px;
}
.kpi-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cs-slate);
}
.kpi-value {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.kpi-value-sm {
  font-size: 18px;
}
.kpi-sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--cs-slate);
}
/* ไอคอนมุมขวาบนของ KPI */
.kpi-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--cs-radius-md);
  background: color-mix(in srgb, var(--cs-primary) 8%, transparent);
  color: var(--cs-primary);
  font-size: 20px;
}
.kpi-icon + .kpi-label,
.kpi-icon ~ .kpi-value {
  padding-right: 48px;
}
.trend-up,
.trend-down {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.trend-up { color: var(--cs-success); }
.trend-down { color: var(--cs-danger); }
.trend-up::before { content: '▲'; font-size: 0.7em; }
.trend-down::before { content: '▼'; font-size: 0.7em; }

/* ============ 8. Tables ================================================= */
.table-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap.is-loading {
  opacity: 0.6;
  pointer-events: none;
}
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}
/* ตารางเล็กในการ์ดหรือหน้ารายละเอียด ไม่บังคับความกว้างขั้นต่ำ */
.table-auto {
  min-width: 0;
}
.table th,
.table td {
  padding: 11px 16px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--cs-border);
}
.table th:first-child,
.table td:first-child {
  padding-left: 20px;
}
.table th:last-child,
.table td:last-child {
  padding-right: 20px;
}
.table thead th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cs-slate);
  background: var(--cs-card);
  white-space: nowrap;
}
.table tbody tr:last-child td {
  border-bottom: none;
}
.table tfoot td {
  font-weight: 600;
  border-top: 1px solid var(--cs-border-strong);
  border-bottom: none;
}
.table tbody tr:hover td {
  background: var(--cs-surface);
}
.table tbody tr.clickable {
  cursor: pointer;
}
.table tbody tr.selected td {
  background: color-mix(in srgb, var(--cs-primary) 5%, transparent);
}
.table td.table-empty {
  padding: 36px 20px;
}
.table tbody tr:hover td.table-empty {
  background: transparent;
}
.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.table .col-check {
  width: 44px;
  padding-right: 0;
}
.table .col-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--cs-primary);
  vertical-align: middle;
}
.table .col-actions {
  width: 1%;
  text-align: right;
  white-space: nowrap;
}
.table-sm th,
.table-sm td {
  padding-top: 7px;
  padding-bottom: 7px;
}
.table-striped tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--cs-surface) 60%, transparent);
}
.table-bordered th,
.table-bordered td {
  border: 1px solid var(--cs-border);
}
.table-bordered th:first-child,
.table-bordered td:first-child {
  padding-left: 16px;
}
/* หัวตารางค้างขณะเลื่อน — ตั้ง max-height ให้ .table-wrap */
.table-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: inset 0 -1px 0 var(--cs-border);
}
/* หัวคอลัมน์ที่เรียงได้ ใส่ .asc หรือ .desc ที่คอลัมน์ที่กำลังเรียง */
.table th.sortable {
  cursor: pointer;
  user-select: none;
}
.table th.sortable::after {
  content: '↕';
  margin-left: 6px;
  opacity: 0.35;
}
.table th.sortable.asc::after {
  content: '↑';
  opacity: 1;
}
.table th.sortable.desc::after {
  content: '↓';
  opacity: 1;
}
.table th.sortable:hover {
  color: var(--cs-ink);
}
/* เรียงฝั่ง server: ใส่ลิงก์ใน th ได้เลย */
.table th.sortable > a {
  color: inherit;
  text-decoration: none;
}

/* ช่องที่มีรูปคนหรือโลโก้คู่กับชื่อ */
.member-cell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.member-name {
  font-weight: 500;
}
.member-sub {
  display: block;
  font-size: 12px;
  color: var(--cs-slate);
}
.row-actions {
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
}
/* แถบการกระทำหมู่ แสดงเมื่อมีการเลือกแถว */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--cs-primary) 6%, var(--cs-card));
  border-bottom: 1px solid var(--cs-border);
  font-weight: 500;
}

/* ============ 9. Navigation ============================================= */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--cs-border);
}
.toolbar-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--cs-slate);
}
.toolbar-field .input {
  min-width: 160px;
}
.toolbar-end {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.input-search {
  width: 280px;
  max-width: 100%;
}

.segmented {
  display: inline-flex;
  background: var(--cs-surface);
  border-radius: var(--cs-radius-md);
  padding: 3px;
  gap: 2px;
}
.segmented-item {
  border: none;
  background: transparent;
  border-radius: var(--cs-radius-sm);
  padding: 6px 12px;
  font-weight: 500;
  color: var(--cs-slate);
  height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.segmented-item.active {
  background: var(--cs-card);
  color: var(--cs-ink);
  box-shadow: var(--cs-inset-border);
  font-weight: 600;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-top: 1px solid var(--cs-border);
  font-size: 12.5px;
  color: var(--cs-slate);
}
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pagination-page {
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
}
/* เลขหน้าแบบเรียงตัว */
.page-list {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: none;
  border-radius: var(--cs-radius-sm);
  background: transparent;
  color: var(--cs-ink);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.page-link:hover {
  background: var(--cs-surface);
}
.page-link.active {
  background: var(--cs-primary);
  color: var(--cs-on-primary);
  font-weight: 600;
}
.page-link.disabled,
.page-link:disabled {
  color: var(--cs-placeholder);
  pointer-events: none;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--cs-border);
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  padding: 8px 14px 10px;
  font-weight: 500;
  color: var(--cs-slate);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  white-space: nowrap;
}
.tab:hover {
  color: var(--cs-ink);
}
.tab.active {
  color: var(--cs-primary);
  font-weight: 600;
  border-bottom-color: var(--cs-primary);
}
.tab .badge {
  height: 18px;
  padding: 0 6px;
  font-size: 11px;
}
.tabs-pills {
  border-bottom: none;
  gap: 6px;
}
.tabs-pills .tab {
  padding: 6px 12px;
  margin: 0;
  border: none;
  border-radius: var(--cs-radius-md);
}
.tabs-pills .tab.active {
  background: color-mix(in srgb, var(--cs-primary) 8%, transparent);
}
.tabs-vertical {
  flex-direction: column;
  border-bottom: none;
  border-right: 1px solid var(--cs-border);
  margin: 0;
}
.tabs-vertical .tab {
  justify-content: flex-start;
  border-bottom: none;
  border-right: 2px solid transparent;
  margin: 0 -1px 0 0;
  padding: 9px 16px;
}
.tabs-vertical .tab.active {
  border-right-color: var(--cs-primary);
}
.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

/* ขั้นตอน (wizard) */
.steps {
  display: flex;
  gap: 8px;
  counter-reset: step;
}
.step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--cs-slate);
  font-weight: 500;
  counter-increment: step;
}
.step::after {
  content: '';
  flex: 1;
  height: 1px;
  min-width: 16px;
  background: var(--cs-border-strong);
}
.step:last-child {
  flex: none;
}
.step:last-child::after {
  display: none;
}
.step-dot {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--cs-border-strong);
  font-size: 12.5px;
  font-weight: 600;
}
.step-dot:empty::before {
  content: counter(step);
}
.step-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.step.active {
  color: var(--cs-ink);
}
.step.active .step-dot {
  background: var(--cs-primary);
  color: var(--cs-on-primary);
  box-shadow: none;
}
.step.done .step-dot {
  background: color-mix(in srgb, var(--cs-success) 12%, transparent);
  color: var(--cs-success);
  box-shadow: none;
}
.step.done .step-dot:empty::before {
  content: '✓';
}
.step.done::after {
  background: var(--cs-success);
}
@media (max-width: 767px) {
  .steps .step-label { display: none; }
  .steps .step.active .step-label { display: inline; }
  .steps .step.active { flex: none; max-width: 60%; }
}

/* ============ 10. Buttons =============================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--cs-radius-md);
  border: 1px solid transparent;
  background: transparent;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s, box-shadow 0.12s, opacity 0.12s, color 0.12s;
}
.btn > i {
  font-size: 16px;
  line-height: 1;
}
.btn:disabled,
.btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}
.btn-sm > i {
  font-size: 14px;
}
.btn-lg {
  height: 44px;
  padding: 0 20px;
  font-size: 15px;
}
.btn-block {
  width: 100%;
}
/* ปุ่มไอคอนสี่เหลี่ยม ใช้ร่วมกับสีปุ่มใดก็ได้ */
.btn-icon {
  width: 36px;
  padding: 0;
}
.btn-sm.btn-icon {
  width: 30px;
}
.btn-lg.btn-icon {
  width: 44px;
}
.btn-primary {
  background: var(--cs-primary);
  color: var(--cs-on-primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--cs-primary-hover);
}
.btn-secondary {
  background: var(--cs-card);
  color: var(--cs-ink);
  box-shadow: var(--cs-inset-border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--cs-surface);
}
.btn-danger {
  background: var(--cs-card);
  color: var(--cs-danger);
  border-color: var(--cs-danger);
}
.btn-danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--cs-danger) 8%, var(--cs-card));
}
/* ลบแบบทึบ ใช้ในกล่องยืนยันเท่านั้น */
.btn-danger-solid {
  background: var(--cs-danger);
  color: var(--cs-card);
}
.btn-danger-solid:hover:not(:disabled) {
  background: color-mix(in srgb, var(--cs-danger) 88%, var(--cs-ink));
}
.btn-success {
  background: var(--cs-success);
  color: var(--cs-card);
}
.btn-success:hover:not(:disabled) {
  background: color-mix(in srgb, var(--cs-success) 88%, var(--cs-ink));
}
/* ปุ่มสีเน้นของแบรนด์ ใช้กับ call to action ที่ต้องเด่นที่สุด ไม่เกินหนึ่งปุ่มต่อหน้า */
.btn-lime,
.btn-accent {
  background: var(--cs-lime);
  color: var(--cs-on-lime);
}
.btn-lime:hover:not(:disabled),
.btn-accent:hover:not(:disabled) {
  background: var(--cs-lime-600);
}
.btn-outline {
  background: transparent;
  color: var(--cs-primary);
  border-color: currentColor;
}
.btn-outline:hover:not(:disabled) {
  background: color-mix(in srgb, var(--cs-primary) 6%, transparent);
}
.btn-soft {
  background: color-mix(in srgb, var(--cs-primary) 8%, transparent);
  color: var(--cs-primary);
}
.btn-soft:hover:not(:disabled) {
  background: color-mix(in srgb, var(--cs-primary) 14%, transparent);
}
.btn-ghost {
  background: transparent;
  color: var(--cs-ink);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--cs-surface);
}
.btn-link {
  height: auto;
  padding: 0;
  background: transparent;
  color: var(--cs-primary);
  font-weight: 500;
}
.btn-link:hover:not(:disabled) {
  text-decoration: underline;
}
/* สถานะกำลังทำงาน — ใส่ .is-loading แล้วข้อความจะถูกแทนด้วยวงหมุน */
.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-color: color-mix(in srgb, var(--cs-slate) 40%, transparent);
  border-top-color: var(--cs-slate);
  animation: cs-spin 0.7s linear infinite;
}
.btn-primary.is-loading::after,
.btn-success.is-loading::after,
.btn-danger-solid.is-loading::after {
  border-color: color-mix(in srgb, var(--cs-on-primary) 35%, transparent);
  border-top-color: var(--cs-on-primary);
}
.btn-group {
  display: inline-flex;
}
.btn-group > .btn {
  border-radius: 0;
}
.btn-group > .btn:first-child {
  border-top-left-radius: var(--cs-radius-md);
  border-bottom-left-radius: var(--cs-radius-md);
}
.btn-group > .btn:last-child {
  border-top-right-radius: var(--cs-radius-md);
  border-bottom-right-radius: var(--cs-radius-md);
}
.btn-group > .btn + .btn {
  margin-left: -1px;
}
.btn-group > .btn.active {
  background: var(--cs-surface);
  color: var(--cs-primary);
  position: relative;
  z-index: 1;
}
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: none;
  border-radius: var(--cs-radius-md);
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--cs-slate);
  text-decoration: none;
}
.icon-btn:hover {
  background: var(--cs-surface);
  color: var(--cs-ink);
}
/* ชุดไอคอน Lucide ใช้ selector [class^="icon-"] ซึ่งจะไปโดน .icon-btn ด้วย
   บรรทัดนี้คืนฟอนต์ปกติให้ตัวปุ่ม ส่วน <i class="icon-…"> ข้างในยังเป็นไอคอนตามเดิม */
:is(.icon-btn, .icon-btn-sm):not(i) {
  font-family: var(--cs-font) !important;
}
.icon-btn-sm {
  width: 28px;
  height: 28px;
  font-size: 16px;
}

/* ============ 11. Badges, dots, avatars ================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}
.badge-neutral {
  background: var(--cs-surface);
  color: var(--cs-slate);
  box-shadow: var(--cs-inset-border);
}
.badge-lime {
  background: var(--cs-lime);
  color: var(--cs-on-lime);
}
.badge-primary {
  background: color-mix(in srgb, var(--cs-primary) 10%, transparent);
  color: var(--cs-primary);
}
.badge-navy {
  background: var(--cs-primary);
  color: var(--cs-on-primary);
}
.badge-success {
  background: color-mix(in srgb, var(--cs-success) 12%, transparent);
  color: var(--cs-success);
}
.badge-info {
  background: color-mix(in srgb, var(--cs-info) 12%, transparent);
  color: var(--cs-info);
}
.badge-amber,
.badge-warning {
  background: color-mix(in srgb, var(--cs-amber) 14%, transparent);
  color: var(--cs-amber);
}
.badge-danger {
  background: color-mix(in srgb, var(--cs-danger) 11%, transparent);
  color: var(--cs-danger);
}
.badge-muted {
  background: var(--cs-surface);
  color: var(--cs-placeholder);
}
.badge-outline {
  background: transparent;
  box-shadow: inset 0 0 0 1px currentColor;
}
/* จุดสีหน้าข้อความในป้าย */
.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-sq {
  border-radius: var(--cs-radius-sm);
}
/* จุดสถานะเดี่ยว */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cs-placeholder);
  flex: none;
}
.dot-success { background: var(--cs-success); }
.dot-danger { background: var(--cs-danger); }
.dot-amber,
.dot-warning { background: var(--cs-amber); }
.dot-info { background: var(--cs-info); }
.dot-primary { background: var(--cs-primary); }

.avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--cs-surface);
}
.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--cs-primary);
  background: color-mix(in srgb, var(--cs-primary) 8%, var(--cs-card));
  font-weight: 600;
  font-size: 13px;
  box-shadow: var(--cs-inset-border);
}
.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl { width: 72px; height: 72px; font-size: 22px; }
.avatar-square { border-radius: var(--cs-radius-md); }
.avatar-group {
  display: inline-flex;
}
.avatar-group > .avatar {
  box-shadow: 0 0 0 2px var(--cs-card);
}
.avatar-group > .avatar + .avatar {
  margin-left: -8px;
}
.avatar-status {
  position: relative;
  display: inline-flex;
  flex: none;
}
.avatar-status > .dot {
  position: absolute;
  right: 0;
  bottom: 0;
  box-shadow: 0 0 0 2px var(--cs-card);
}

/* ============ 12. Alerts ================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--cs-radius-md);
  background: color-mix(in srgb, var(--alert-c, var(--cs-info)) 8%, var(--cs-card));
  color: var(--cs-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--alert-c, var(--cs-info)) 25%, transparent);
}
.alert + .alert {
  margin-top: 10px;
}
.alert-icon {
  flex: none;
  font-size: 18px;
  line-height: 1.25;
  color: var(--alert-c, var(--cs-info));
}
.alert-body {
  flex: 1;
  min-width: 0;
}
.alert-title {
  font-weight: 600;
  color: var(--alert-c, var(--cs-info));
}
.alert-close {
  flex: none;
  border: none;
  background: transparent;
  color: var(--cs-slate);
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
}
.alert-info { --alert-c: var(--cs-info); }
.alert-success { --alert-c: var(--cs-success); }
.alert-warning { --alert-c: var(--cs-amber); }
.alert-danger { --alert-c: var(--cs-danger); }
.alert-neutral { --alert-c: var(--cs-slate); }
/* รุ่นเดิม คงไว้เพื่อความเข้ากันได้ */
.inline-error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--cs-radius-md);
  background: color-mix(in srgb, var(--cs-danger) 8%, var(--cs-card));
  color: var(--cs-danger);
  font-size: 13px;
}
.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: var(--cs-radius-md);
  background: color-mix(in srgb, var(--cs-danger) 8%, var(--cs-card));
  color: var(--cs-danger);
  box-shadow: inset 0 0 0 1px currentColor;
}

/* ============ 13. Forms ================================================= */
.input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--cs-border-strong);
  border-radius: var(--cs-radius-md);
  background: var(--cs-card);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input::placeholder {
  color: var(--cs-placeholder);
}
.input:hover:not(:focus):not(:disabled) {
  border-color: color-mix(in srgb, var(--cs-border-strong) 60%, var(--cs-slate));
}
.input:focus {
  border-color: var(--cs-primary-hover);
  box-shadow: var(--cs-focus-ring);
}
.input:disabled,
.input[readonly] {
  background: var(--cs-surface);
  color: var(--cs-slate);
}
.input-sm {
  height: 30px;
  font-size: 12.5px;
}
.input-lg {
  height: 44px;
  font-size: 15px;
  padding: 0 14px;
}
/* ลูกศรของ select วาดด้วย SVG inline ไม่ต้องพึ่งไฟล์ภาพ (สีเทากลาง ใช้ได้ทั้งสองโหมด) */
select.input {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
select.input[multiple] {
  height: auto;
  padding: 6px;
  background-image: none;
}
.textarea,
textarea.input {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}
input[type='file'].input {
  padding: 0;
  line-height: 34px;
}
input[type='file'].input::file-selector-button {
  height: 100%;
  margin-right: 10px;
  padding: 0 12px;
  border: none;
  border-right: 1px solid var(--cs-border);
  background: var(--cs-surface);
  color: var(--cs-ink);
  font: inherit;
  font-weight: 500;
}
input[type='color'].input {
  width: 48px;
  padding: 3px;
}
/* ช่องกรอกรหัสสั้น เช่น PIN หรือ OTP */
.code-input {
  letter-spacing: 0.35em;
  font-size: 18px;
  max-width: 200px;
}
.otp {
  display: flex;
  gap: 8px;
}
.otp .input {
  flex: 1 1 0;
  min-width: 0;
  max-width: 48px;
  width: 44px;
  height: 48px;
  padding: 0;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
}

/* ช่องกรอกมีข้อความหรือปุ่มต่อท้าย */
.input-group {
  display: flex;
  align-items: stretch;
  width: 100%;
}
.input-group > .input {
  flex: 1;
  min-width: 0;
  border-radius: 0;
}
.input-group > .input:focus {
  position: relative;
  z-index: 1;
}
.input-group > .input-addon {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--cs-border-strong);
  background: var(--cs-surface);
  color: var(--cs-slate);
  white-space: nowrap;
}
.input-group > .btn {
  height: auto;
  border-radius: 0;
}
.input-group > * + * {
  margin-left: -1px;
}
.input-group > :first-child {
  border-top-left-radius: var(--cs-radius-md);
  border-bottom-left-radius: var(--cs-radius-md);
}
.input-group > :last-child {
  border-top-right-radius: var(--cs-radius-md);
  border-bottom-right-radius: var(--cs-radius-md);
}
/* ช่องกรอกมีไอคอนด้านหน้า (หรือด้านหลังด้วย .input-icon-end) */
.input-icon {
  position: relative;
  display: block;
}
.input-icon > i {
  position: absolute;
  top: 50%;
  left: 11px;
  transform: translateY(-50%);
  color: var(--cs-placeholder);
  font-size: 16px;
  pointer-events: none;
}
.input-icon > .input {
  padding-left: 34px;
}
.input-icon-end > i {
  left: auto;
  right: 11px;
}
.input-icon-end > .input {
  padding-left: 10px;
  padding-right: 34px;
}
.input-icon > .input:not(:last-child) {
  padding-right: 44px;
}
.input-icon > button {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  height: 28px;
  padding: 0 8px;
  border: none;
  border-radius: var(--cs-radius-sm);
  background: transparent;
  color: var(--cs-slate);
}
.input-icon > button:hover {
  background: var(--cs-surface);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field-full {
  grid-column: 1 / -1;
}
.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--cs-slate);
}
.field-required {
  color: var(--cs-danger);
}
.field-hint {
  font-size: 12px;
  color: var(--cs-placeholder);
}
.field-error {
  font-size: 12px;
  color: var(--cs-danger);
}
.field-error:empty {
  display: none;
}
.field.has-error .input,
.input.is-invalid,
.input.input-validation-error {
  border-color: var(--cs-danger);
}
.field.has-error .input:focus,
.input.is-invalid:focus,
.input.input-validation-error:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cs-danger) 15%, transparent);
}
.field.is-valid .input,
.input.is-valid {
  border-color: var(--cs-success);
}
.field-success {
  font-size: 12px;
  color: var(--cs-success);
}
/* ASP.NET validation — ใส่ class ให้ตรงกับที่ jquery-validation-unobtrusive สร้าง */
.field-validation-error {
  font-size: 12px;
  color: var(--cs-danger);
}
.field-validation-valid {
  display: none;
}
.validation-summary-errors {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: var(--cs-radius-md);
  background: color-mix(in srgb, var(--cs-danger) 8%, var(--cs-card));
  color: var(--cs-danger);
}
.validation-summary-errors ul {
  list-style: disc;
  padding-left: 18px;
}
.validation-summary-valid {
  display: none;
}

/* checkbox / radio — ใช้ตัว native แล้วเปลี่ยนสีด้วย accent-color อ่านง่ายและเข้าถึงได้ครบ */
.check,
.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.check input,
.checkbox-field input {
  flex: none;
  margin: 3px 0 0;
  width: 16px;
  height: 16px;
  accent-color: var(--cs-primary);
  cursor: pointer;
}
.check-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}
.checkbox-field .field-hint,
.check .field-hint {
  display: block;
}
.checkbox-label,
.check-label {
  font-weight: 500;
}
.check input:disabled + * {
  color: var(--cs-placeholder);
}
/* สวิตช์เปิดปิด: <label class="switch"><input type="checkbox"><span class="switch-track"></span> ข้อความ</label> */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-track {
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--cs-border-strong);
  transition: background var(--cs-ease);
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cs-card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform var(--cs-ease);
}
.switch input:checked + .switch-track {
  background: var(--cs-primary);
}
.switch input:checked + .switch-track::after {
  transform: translateX(16px);
}
.switch input:focus-visible + .switch-track {
  box-shadow: var(--cs-focus-ring);
}
.switch input:disabled + .switch-track {
  opacity: 0.5;
}
/* แถบเลื่อนค่า */
.range {
  width: 100%;
  accent-color: var(--cs-primary);
}
/* พื้นที่ลากไฟล์มาวาง ใส่ <input type="file"> ไว้ข้างใน */
.file-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 16px;
  border: 1.5px dashed var(--cs-border-strong);
  border-radius: var(--cs-radius-md);
  background: var(--cs-app-bg);
  color: var(--cs-slate);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--cs-ease), background var(--cs-ease);
}
.file-drop:hover,
.file-drop.is-dragover {
  border-color: var(--cs-primary);
  background: color-mix(in srgb, var(--cs-primary) 4%, var(--cs-card));
}
.file-drop > i {
  font-size: 28px;
  color: var(--cs-placeholder);
}
.file-drop input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.file-drop-title {
  font-weight: 600;
  color: var(--cs-ink);
}
/* ให้คะแนนดาว ใช้ radio เรียงจากมากไปน้อย แล้วกลับทิศด้วย row-reverse */
.rating {
  display: inline-flex;
  flex-direction: row-reverse;
  gap: 2px;
}
.rating input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.rating label {
  font-size: 22px;
  line-height: 1;
  color: var(--cs-border-strong);
  cursor: pointer;
}
.rating label::before {
  content: '★';
}
.rating input:checked ~ label,
.rating label:hover,
.rating label:hover ~ label {
  color: var(--cs-amber);
}
.rating-static {
  color: var(--cs-amber);
  letter-spacing: 1px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 767px) {
  .form-grid,
  .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
}
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 420px;
}
/* ฟอร์มแนวนอน: ป้ายซ้าย ช่องกรอกขวา */
.form-horizontal {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-horizontal .field {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: start;
  gap: 4px 16px;
}
.form-horizontal .field > .field-label {
  padding-top: 8px;
}
.form-horizontal .field > :not(.field-label) {
  grid-column: 2;
}
@media (max-width: 767px) {
  .form-horizontal .field { grid-template-columns: minmax(0, 1fr); }
  .form-horizontal .field > :not(.field-label) { grid-column: 1; }
}
.form-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--cs-border);
}
.form-section-title {
  font-size: 14px;
  font-weight: 600;
}
.form-section-desc {
  margin: 4px 0 12px;
  font-size: 12.5px;
  color: var(--cs-slate);
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--cs-border);
}
/* แถบบันทึกค้างล่างจอ สำหรับฟอร์มยาว */
.form-actions-sticky {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 20px calc(var(--cs-content-pad-x) * -1) -48px;
  padding: 12px var(--cs-content-pad-x);
  background: color-mix(in srgb, var(--cs-card) 92%, transparent);
  backdrop-filter: blur(6px);
}

/* ตัวเลือกแบบชิป เช่น วันในสัปดาห์ ใช้ checkbox ซ่อนไว้ข้างใน */
.chip-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--cs-radius-md);
  box-shadow: var(--cs-inset-border);
  background: var(--cs-card);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
}
.chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.chip.on,
.chip:has(input:checked) {
  background: var(--cs-primary);
  color: var(--cs-on-primary);
  box-shadow: none;
}
.chip-remove {
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}

/* ============ 14. Dropdown ==============================================
   สองแบบ: <details class="dropdown"> ไม่ต้องมี JS
           <div class="dropdown"> + data-toggle="dropdown" ใช้ theme.js */
.dropdown {
  position: relative;
  display: inline-flex;
}
details.dropdown > summary {
  list-style: none;
}
details.dropdown > summary::-webkit-details-marker {
  display: none;
}
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  min-width: 200px;
  padding: 6px;
  border-radius: var(--cs-radius-md);
  background: var(--cs-card);
  box-shadow: var(--cs-shadow-card), var(--cs-inset-border);
  animation: cs-drop-in 0.12s ease-out;
}
.dropdown.open > .dropdown-menu,
details.dropdown[open] > .dropdown-menu {
  display: block;
}
.dropdown-menu-end {
  left: auto;
  right: 0;
}
.dropdown-menu-up {
  top: auto;
  bottom: calc(100% + 6px);
}
.dropdown-menu-lg {
  width: 340px;
  padding: 0;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--cs-radius-sm);
  background: transparent;
  color: var(--cs-ink);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}
.dropdown-item > i {
  font-size: 16px;
  color: var(--cs-slate);
}
.dropdown-item:hover,
.dropdown-item.active {
  background: var(--cs-surface);
}
.dropdown-item.danger,
.dropdown-item.danger > i {
  color: var(--cs-danger);
}
.dropdown-divider {
  height: 1px;
  margin: 6px -6px;
  background: var(--cs-border);
}
.dropdown-header {
  padding: 8px 10px 4px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cs-slate);
}
/* หัวและท้ายของเมนูใหญ่ เช่น การแจ้งเตือน */
.dropdown-head,
.dropdown-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}
.dropdown-head {
  border-bottom: 1px solid var(--cs-border);
  font-weight: 600;
}
.dropdown-foot {
  justify-content: center;
  border-top: 1px solid var(--cs-border);
}
.dropdown-scroll {
  max-height: 320px;
  overflow-y: auto;
}
/* รายการแจ้งเตือน */
.notice {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--cs-ink);
}
.notice + .notice {
  border-top: 1px solid var(--cs-border);
}
.notice:hover {
  background: var(--cs-surface);
}
.notice-title {
  font-weight: 600;
}
.notice-text {
  font-size: 12.5px;
  color: var(--cs-slate);
}
.notice-time {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--cs-placeholder);
}
.notice.unread .notice-title::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--cs-primary);
  vertical-align: middle;
}
@keyframes cs-drop-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ============ 15. Drawer + dialog ======================================= */
.drawer-root,
.dialog-root {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.drawer-backdrop,
.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: var(--cs-backdrop);
  animation: cs-fade-in 0.15s ease-out;
}
.drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 100vw);
  max-width: 100vw;
  background: var(--cs-card);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  animation: cs-slide-in 0.18s ease-out;
}
.drawer-sm { width: min(360px, 100vw); }
.drawer-lg { width: min(720px, 100vw); }
.drawer-left {
  right: auto;
  left: 0;
  box-shadow: 8px 0 30px rgba(0, 0, 0, 0.18);
  animation-name: cs-slide-in-left;
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--cs-border);
}
.drawer-title {
  font-size: 16px;
  font-weight: 600;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.drawer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--cs-border);
}
.drawer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--cs-border);
}

.dialog {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: var(--cs-shadow-card), var(--cs-inset-border);
  animation: cs-fade-in 0.15s ease-out;
}
.dialog.card + .card {
  margin-top: 0;
}
.dialog-sm { width: min(360px, calc(100vw - 32px)); }
.dialog-lg { width: min(640px, calc(100vw - 32px)); top: 45%; }
.dialog-xl { width: min(960px, calc(100vw - 32px)); top: 50%; }
.dialog-title {
  font-size: 16px;
  font-weight: 600;
}
.dialog-message {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--cs-slate);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
/* dialog แบบมีหัว เนื้อหา ท้าย แยกกัน — ใช้คู่กับ .card-flush */
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--cs-border);
}
.dialog-body {
  padding: 20px;
}
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--cs-border);
}
/* กล่องยืนยันแบบมีไอคอนกลาง */
.dialog-center {
  text-align: center;
}
.dialog-center .dialog-actions {
  justify-content: center;
}
.dialog-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin: 4px auto 14px;
  border-radius: 50%;
  font-size: 26px;
  background: color-mix(in srgb, var(--dialog-c, var(--cs-info)) 12%, transparent);
  color: var(--dialog-c, var(--cs-info));
}
.dialog-icon-danger { --dialog-c: var(--cs-danger); }
.dialog-icon-success { --dialog-c: var(--cs-success); }
.dialog-icon-warning { --dialog-c: var(--cs-amber); }
body.has-overlay {
  overflow: hidden;
}

@keyframes cs-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes cs-slide-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes cs-slide-in-left {
  from { transform: translateX(-24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ============ 16. Accordion ============================================= */
.accordion {
  border-radius: var(--cs-radius-md);
  background: var(--cs-card);
  box-shadow: var(--cs-inset-border);
}
.accordion-item + .accordion-item {
  border-top: 1px solid var(--cs-border);
}
.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.accordion-header::-webkit-details-marker {
  display: none;
}
.accordion-header::after {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--cs-slate);
  border-bottom: 1.5px solid var(--cs-slate);
  transform: rotate(45deg);
  transition: transform var(--cs-ease);
}
.accordion-item[open] > .accordion-header {
  color: var(--cs-primary);
}
.accordion-item[open] > .accordion-header::after {
  transform: rotate(-135deg);
}
.accordion-body {
  padding: 0 18px 16px;
  color: var(--cs-slate);
}
.accordion-flush {
  background: transparent;
  box-shadow: none;
}
.accordion-flush .accordion-header,
.accordion-flush .accordion-body {
  padding-left: 0;
  padding-right: 0;
}

/* ============ 17. Toast + tooltip ======================================= */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  max-width: min(380px, calc(100vw - 40px));
}
.toast-stack-top {
  top: 20px;
  bottom: auto;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 14px;
  border-radius: var(--cs-radius-md);
  background: var(--cs-toast-bg);
  color: var(--cs-toast-fg);
  box-shadow: var(--cs-shadow-card);
  animation: cs-fade-in 0.15s ease-out;
}
.toast-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cs-lime);
}
.toast-error .toast-dot {
  background: var(--cs-danger-on-dark);
}
.toast-info .toast-dot {
  background: var(--cs-meta-on-navy);
}
.toast-warning .toast-dot {
  background: var(--cs-amber-on-dark, var(--cs-amber));
}
.toast-msg {
  flex: 1;
}
.toast-title {
  display: block;
  font-weight: 600;
}
.toast-close {
  border: none;
  background: transparent;
  color: color-mix(in srgb, var(--cs-toast-fg) 65%, transparent);
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
}
.toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
}

/* tooltip ด้วย CSS ล้วน: <button data-tooltip="ข้อความ"> */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  z-index: 110;
  padding: 5px 8px;
  border-radius: var(--cs-radius-sm);
  background: var(--cs-toast-bg);
  color: var(--cs-toast-fg);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 2px);
  transition: opacity 0.12s, transform 0.12s;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}
[data-tooltip-pos='bottom']::after {
  top: calc(100% + 6px);
  bottom: auto;
}
[data-tooltip-pos='right']::after {
  top: 50%;
  bottom: auto;
  left: calc(100% + 6px);
  transform: translate(0, -50%);
}
[data-tooltip-pos='right']:hover::after {
  transform: translate(0, -50%);
}

/* ============ 18. Progress, spinner, empty, skeleton ==================== */
.progress {
  display: flex;
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--cs-surface);
  box-shadow: var(--cs-inset-border);
}
.progress-sm { height: 4px; }
.progress-lg { height: 14px; }
.progress-bar {
  height: 100%;
  background: var(--progress-c, var(--cs-primary));
  border-radius: inherit;
  transition: width 0.3s ease;
}
.progress-bar + .progress-bar {
  border-radius: 0;
}
.progress-success { --progress-c: var(--cs-success); }
.progress-danger { --progress-c: var(--cs-danger); }
.progress-amber,
.progress-warning { --progress-c: var(--cs-amber); }
.progress-info { --progress-c: var(--cs-info); }
.progress-accent { --progress-c: var(--cs-lime); }
.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12.5px;
}
.progress-label span:last-child {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 16px;
  color: var(--cs-slate);
}
.spinner {
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--cs-border);
  border-top-color: var(--cs-primary);
  animation: cs-spin 0.8s linear infinite;
}
.spinner-sm { width: 14px; height: 14px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes cs-spin {
  to { transform: rotate(360deg); }
}
/* หน้าโหลดทั้งจอ */
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cs-app-bg);
  transition: opacity 0.3s;
}
.page-loader.is-done {
  opacity: 0;
  pointer-events: none;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 36px 16px;
  color: var(--cs-slate);
  text-align: center;
}
.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--cs-surface);
  color: var(--cs-placeholder);
  font-size: 26px;
}
.empty-title {
  font-weight: 600;
  color: var(--cs-ink);
}
.skeleton {
  display: inline-block;
  height: 14px;
  width: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--cs-surface) 25%, var(--cs-skeleton-hi) 50%, var(--cs-surface) 75%);
  background-size: 200% 100%;
  animation: cs-shimmer 1.2s infinite;
}
.skeleton-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}
@keyframes cs-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
.stack-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stack-skeleton .skeleton {
  height: 12px;
}
.skeleton-row .skeleton {
  height: 12px;
  width: 70%;
}

/* ============ 19. Lists ================================================= */
.list-group {
  border-radius: var(--cs-radius-md);
  background: var(--cs-card);
  box-shadow: var(--cs-inset-border);
}
.list-group-flush {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}
.list-group-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--cs-ink);
  text-decoration: none;
}
.list-group-flush .list-group-item {
  padding-left: 0;
  padding-right: 0;
}
.list-group-item + .list-group-item {
  border-top: 1px solid var(--cs-border);
}
a.list-group-item:hover,
button.list-group-item:hover {
  background: var(--cs-surface);
}
button.list-group-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
}
.list-group-item.active {
  background: color-mix(in srgb, var(--cs-primary) 6%, transparent);
  color: var(--cs-primary);
  font-weight: 600;
}
.list-title {
  font-weight: 600;
}
.list-meta {
  font-size: 12.5px;
  color: var(--cs-slate);
}

/* รายการคู่ label/value แบบสองคอลัมน์ ใช้กับหน้ารายละเอียด */
.meta-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  font-size: 13px;
}
.meta-list dt {
  color: var(--cs-slate);
}
.meta-list-wide {
  grid-template-columns: 140px 1fr;
  gap: 10px 14px;
  font-size: 14px;
}
@media (max-width: 575px) {
  .meta-list-wide { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .meta-list-wide dd { margin-bottom: 8px; }
}

/* timeline / activity feed */
.timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-left: 22px;
}
.timeline::before {
  content: '';
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 5px;
  width: 2px;
  background: var(--cs-border);
}
.timeline-item {
  position: relative;
}
.timeline-dot {
  position: absolute;
  top: 5px;
  left: -22px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cs-card);
  box-shadow: inset 0 0 0 2px var(--timeline-c, var(--cs-primary));
}
.timeline-item.done .timeline-dot {
  background: var(--timeline-c, var(--cs-primary));
}
.timeline-success { --timeline-c: var(--cs-success); }
.timeline-danger { --timeline-c: var(--cs-danger); }
.timeline-amber { --timeline-c: var(--cs-amber); }
.timeline-muted { --timeline-c: var(--cs-placeholder); }
.timeline-time {
  font-size: 12px;
  color: var(--cs-slate);
}
.timeline-title {
  font-weight: 600;
}
.timeline-text {
  margin-top: 2px;
  color: var(--cs-slate);
}

/* ============ 21. Auth + error pages ==================================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--cs-login-bg, var(--cs-navy-900)); /* สีทึบสีเดียว — ใส่ gradient/ภาพเองได้ผ่าน --cs-login-bg */
}
.login-card {
  width: min(400px, 100%);
  background: var(--cs-card);
  border-radius: var(--cs-radius-lg);
  padding: 28px 28px 24px;
  box-shadow: var(--cs-shadow-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-brand {
  background: var(--cs-navy-900);
  border-radius: var(--cs-radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--cs-sidebar-fg);
}
.login-logo {
  width: 170px;
}
.login-brand-sub {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cs-meta-on-navy);
}
.login-title {
  font-size: 18px;
  font-weight: 700;
  margin-top: 4px;
}
.login-note {
  font-size: 12px;
  color: var(--cs-placeholder);
  text-align: center;
}

/* หน้าแบ่งสองฝั่ง: ฟอร์มซ้าย ภาพแบรนด์ขวา */
.auth-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  min-height: 100vh;
  background: var(--cs-card);
}
.auth-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(400px, 100%);
  margin: 0 auto;
  padding: 40px 24px;
  gap: 16px;
}
.auth-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}
.auth-logo img {
  height: 32px;
  width: auto;
}
.auth-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.auth-subtitle {
  margin-top: -8px;
  color: var(--cs-slate);
}
.auth-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 48px;
  overflow: hidden;
  background: var(--cs-login-bg, var(--cs-navy-900)); /* สีทึบสีเดียว — ใส่ gradient/ภาพเองได้ผ่าน --cs-login-bg */
  color: var(--cs-sidebar-fg);
}
.auth-panel-quote {
  max-width: 440px;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.4;
}
.auth-panel-meta {
  margin-top: 12px;
  color: var(--cs-meta-on-navy);
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--cs-placeholder);
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--cs-border);
}
.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.auth-foot {
  margin-top: 8px;
  font-size: 13px;
  color: var(--cs-slate);
  text-align: center;
}
@media (max-width: 900px) {
  .auth-split { grid-template-columns: minmax(0, 1fr); }
  .auth-panel { display: none; }
}

/* หน้าข้อผิดพลาด 404 / 500 / ปิดปรับปรุง */
.error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: var(--cs-app-bg);
}
.error-code {
  font-size: clamp(72px, 14vw, 128px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--cs-primary);
}
.error-title {
  font-size: 22px;
  font-weight: 700;
}
.error-text {
  max-width: 440px;
  color: var(--cs-slate);
}
.error-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ============ 21b. Shared bits (v2.1) — breadcrumb, badges, skip link ====== */
/* breadcrumb — ใช้ทั้งหลังบ้านและเว็บไซต์ <ol class="breadcrumb"> */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--cs-slate);
}
.breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb li + li::before {
  content: '/';
  color: var(--cs-placeholder);
}
.breadcrumb a {
  text-decoration: none;
}
.breadcrumb a:hover {
  color: var(--cs-primary);
}
.breadcrumb [aria-current] {
  color: var(--cs-ink);
  font-weight: 500;
}
/* ป้ายสินค้าลดราคา — core ไม่มี badge สีทึบแบบ danger */
.badge-sale {
  background: var(--cs-danger);
  color: var(--cs-card);
}
.badge-new {
  background: var(--cs-lime);
  color: var(--cs-on-lime);
}
/* จำนวนบนไอคอน (ตะกร้า การแจ้งเตือน แถบล่าง) */
.count-badge {
  position: absolute;
  top: 4px;
  right: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--cs-radius-pill);
  background: var(--cs-danger);
  color: var(--cs-card);
  font-family: var(--cs-font);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--cs-card);
  pointer-events: none;
}
.count-badge:empty,
.count-badge[data-count='0'] {
  display: none;
}
/* ลิงก์ข้ามไปเนื้อหา สำหรับผู้ใช้คีย์บอร์ดและ screen reader */
.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: var(--cs-radius-md);
  background: var(--cs-primary);
  color: var(--cs-on-primary);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform var(--cs-ease);
}
.skip-link:focus {
  transform: none;
}

/* ปุ่มไอคอนที่มีจุดแจ้งเตือน */
.has-dot {
  position: relative;
}
.has-dot::after {
  content: '';
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cs-danger);
  box-shadow: 0 0 0 2px var(--cs-topbar-bg, var(--cs-card));
}
/* ไอคอนสลับโหมดสี แสดงเฉพาะอันที่ตรงกับโหมดปัจจุบัน */
:root:not([data-theme='dark']) .when-dark,
:root[data-theme='dark'] .when-light {
  display: none !important;
}

/* ============ 21c. Brand logo (v2.1) ====================================
   โลโก้แบรนด์แบบรูปภาพ ใส่ทั้งสองสีแล้วธีมเลือกให้เองตามพื้นหลังและโหมดสี
     <span class="brand-logo">
       <img class="brand-logo-dark" src="…/ke-ally-logo.svg" alt="KE ALLY">
       <img class="brand-logo-light" src="…/ke-ally-logo-white.svg" alt="" aria-hidden="true">
     </span>
   ขนาดตั้งด้วย --brand-logo-h ตามตำแหน่งที่วาง (sidebar, login, header …) */
.brand-logo {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}
.brand-logo img {
  display: block;
  height: var(--brand-logo-h, 40px);
  width: auto;
  max-width: none;
}
.brand-logo-light {
  display: none !important;
}
/* พื้นเข้ม: โหมดมืด และพื้นสีแบรนด์ */
:root[data-theme='dark'] .brand-logo-dark,
:is(.sidebar, .login-brand, .auth-panel) .brand-logo-dark {
  display: none !important;
}
:root[data-theme='dark'] .brand-logo-light,
:is(.sidebar, .login-brand, .auth-panel) .brand-logo-light {
  display: block !important;
}
/* แถบข้างสีอ่อนในโหมดสว่าง กลับไปใช้โลโก้สีเข้ม */
:root[data-sidebar='light']:not([data-theme='dark']) .sidebar .brand-logo-dark {
  display: block !important;
}
:root[data-sidebar='light']:not([data-theme='dark']) .sidebar .brand-logo-light {
  display: none !important;
}
.login-brand { --brand-logo-h: 72px; }
/* เครื่องหมายสี่เหลี่ยม (ถ้ามี) ใช้แทนโลโก้เต็มในที่แคบ เช่น แถบข้างที่ย่อเหลือไอคอน
   <span class="brand-logo"> …โลโก้สองสี… <span class="brand-mark"> …mark สองสี… </span></span> */
.brand-mark {
  display: none;
}
.auth-logo { --brand-logo-h: 56px; }

/* ============ 22. Print ================================================= */
@media print {
  .sidebar,
  .topbar,
  .footer,
  .page-actions,
  .toast-stack,
  .no-print {
    display: none !important;
  }
  .app-main,
  .app-shell > .content {
    margin: 0 !important;
  }
  .content {
    padding: 0;
  }
  body {
    background: none;
  }
  .card {
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

