.mobile-list-only { display: none; }
.desktop-table-only { display: block; }
.mobile-record-card {
  border: 1px solid var(--border);
  background: #fff;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(15,45,107,.06);
}
.mobile-record-card + .mobile-record-card {
  margin-top: 12px;
}
.mobile-record-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.mobile-record-index {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.mobile-record-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.mobile-record-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.mobile-record-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}
.mobile-record-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.mobile-record-value {
  display: block;
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
}
.mobile-card-actions {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mobile-inline-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mobile-inline-actions form,
.mobile-card-actions form {
  width: 100%;
}
.mobile-slip-preview {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  padding: 10px;
  border: 1px solid var(--border);
  background: #f8fafc;
}
.mobile-slip-preview img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.mobile-empty-state {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
}
/* ============================================================
   DMS — UI Standards CSS
   Colors: Navy #1e3a5f | Orange #f97316 | Slate #f1f5f9
   Font: Prompt (Google Fonts) — fallback Noto Sans Thai
   ============================================================ */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Force all form elements to inherit font */
input, button, select, textarea, optgroup, option {
  font-family: inherit;
  font-size: inherit;
}

/* ============================================================
   DESIGN TOKENS — ธีม "แดชบอร์ดสว่าง" (2026-09-11)
   ============================================================ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --primary-soft: #eff6ff;
  --secondary: #f97316;
  --bg: #eef1f7;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --sidebar-bg: #0d0f1a;
  --sidebar-bg-end: #12141f;
  --sidebar-active: #2563eb;
  --header-bg: #5a200b;        /* แสดเข้มอมดำ */
  --header-bg-end: #351002;

  --navbar-h: 56px;
  --sidebar-w: 212px;
  --topnav-bar-h: 0px;   /* แถบแท็บแนวนอนถูกยกเลิกแล้ว — คงตัวแปรไว้ให้สูตรเก่าไม่พัง */
  --breadcrumb-h: 0px;   /* แถบ breadcrumb สีส้มถูกยกเลิกแล้ว */

  --radius: 14px;
  --radius-sm: 10px;
  --radius-btn: 10px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-md: 0 4px 16px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.12);

  /* ไล่สีการ์ด KPI */
  --grad-blue:   linear-gradient(135deg, #4f8ef7 0%, #2563eb 100%);
  --grad-green:  linear-gradient(135deg, #34d399 0%, #10b981 100%);
  --grad-indigo: linear-gradient(135deg, #8b7cf6 0%, #6366f1 100%);
  --grad-teal:   linear-gradient(135deg, #10b981 0%, #059669 100%);
  --grad-pink:   linear-gradient(135deg, #fb7185 0%, #e11d48 100%);
  --grad-orange: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  --grad-purple: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
  --grad-gold:   linear-gradient(135deg, #fcd34d 0%, #f59e0b 100%);
  --grad-dark:   linear-gradient(135deg, #334155 0%, #0f172a 100%);
}

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: 'Prompt', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5 { font-weight: 600; line-height: 1.35; color: var(--text); }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }
h5 { font-size: 14px; }

.text-muted     { color: var(--text-muted); }
.text-primary   { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-success   { color: var(--success); }
.text-danger    { color: var(--danger); }
.text-warning   { color: var(--warning); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.font-bold     { font-weight: 700; }
.font-semibold { font-weight: 600; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-layout { min-height: 100vh; }

/* ── NAVBAR (แถบบนสุด พื้นขาว) ───────────────────────────── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--navbar-h);
  background: linear-gradient(100deg, var(--header-bg) 0%, var(--header-bg-end) 100%);
  display: flex;
  align-items: center;
  padding: 0 18px 0 14px;
  gap: 14px;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,.06);
  box-shadow: 0 2px 10px rgba(0,0,0,.22);
}

.navbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.navbar-brand:hover { color: #fff; }

.navbar-brand img {
  height: 34px; width: auto;
  border-radius: 9px;
}

.navbar-brand-name {
  display: flex;
  flex-direction: column;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.15;
}
.navbar-brand-sub {
  font-size: 9.5px;
  font-weight: 500;
  color: rgba(255,255,255,.42);
  letter-spacing: .6px;
  text-transform: uppercase;
}

.navbar-sys-title { display: none; }
.navbar-online, .navbar-status { display: none; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.navbar-divider { width: 1px; height: 24px; background: var(--border); }

/* ช่องค้นหาทรงแคปซูล */
.navbar-search { display: none; }
.navbar-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: 14px;
}
.navbar-search-icon {
  position: absolute;
  left: 14px;
  color: rgba(255,255,255,.4);
  pointer-events: none;
}
.navbar-search-input {
  width: 280px;
  height: 38px;
  padding: 0 16px 0 38px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,.08);
  font-family: inherit;
  font-size: 13px;
  color: #fff;
  transition: border-color .18s, background .18s;
}
.navbar-search-input::placeholder { color: rgba(255,255,255,.38); }
.navbar-search-input:focus {
  outline: none;
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.3);
}

.navbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ปุ่มไอคอนกลม (กระดิ่ง ฯลฯ) */
.topnav-icon-btn, .navbar-btn {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.82);
  transition: background .18s, color .18s;
  text-decoration: none;
}
.topnav-icon-btn:hover, .navbar-btn:hover { background: rgba(255,255,255,.12); color: #fff; }

.topnav-badge, .notification-badge {
  position: absolute;
  top: 3px; right: 3px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  background: var(--danger);
  border: 2px solid var(--header-bg);
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* โปรไฟล์ */
.navbar-profile { position: relative; }

.navbar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 4px 4px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background .18s;
}
.navbar-user:hover { background: rgba(255,255,255,.1); color: #fff; }

.navbar-avatar, .user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--grad-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  overflow: hidden;
}
.navbar-avatar img, .user-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.avatar-emoji    { font-size: 30px; line-height: 1; display: flex; }
.avatar-emoji-lg { font-size: 44px; line-height: 1; display: flex; }

.navbar-username { font-weight: 600; color: #fff; }
.navbar-caret    { color: rgba(255,255,255,.55); font-size: 11px; }

/* เมนูดรอปดาวน์โปรไฟล์ */
[x-cloak] { display: none !important; }

.profile-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  z-index: 1000;
  overflow: hidden;
}
.profile-dropdown-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-alt);
}
.profile-dropdown-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--grad-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  flex-shrink: 0;
  overflow: hidden;
}
.profile-dropdown-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  font-size: 13.5px;
  color: var(--text);
  transition: background .15s;
}
.profile-dropdown-item:hover { background: var(--surface-alt); color: var(--text); }
.profile-dropdown-item.danger { color: var(--danger); }
.profile-dropdown-item.danger:hover { background: #fef2f2; color: var(--danger); }

/* ── SIDEBAR (แถบเมนูซ้าย ตรึงถาวร) ───────────────────────── */
.sidebar {
  position: fixed;
  top: var(--navbar-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--navbar-h));
  /* โทนเดียวกับฝั่งข้อความของหน้าล็อกอิน: ดำอมน้ำเงิน + แสงส้มมุมล่าง */
  background:
    radial-gradient(ellipse at 20% 92%, rgba(249,115,22,.20) 0%, transparent 52%),
    radial-gradient(ellipse at 90% 8%, rgba(30,34,53,.95) 0%, transparent 60%),
    var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 90;
  transition: transform .28s ease;
}

/* โลโก้ในแถบข้างถูกย้ายไปไว้บน navbar แล้ว */
.sidebar-brand, .sidebar-brand-content, .sidebar-brand-top,
.sidebar-logo-box, .sidebar-abbr, .sidebar-brand-en,
.sidebar-brand-text, .sidebar-brand-th { display: none; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 0 10px;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 4px; }

.sidebar-group-label {
  padding: 14px 20px 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: rgba(255,255,255,.34);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 3px 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: rgba(255,255,255,.72);
  text-decoration: none;
  transition: background .18s, color .18s;
  position: relative;
}
.sidebar-item:hover { background: rgba(255,255,255,.08); color: #fff; }

.sidebar-item.active {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(37,99,235,.38);
}

.sidebar-item-icon {
  width: 22px;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-item-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-badge {
  min-width: 20px;
  padding: 1px 6px;
  background: var(--danger);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-align: center;
}

.sidebar-group { display: block; }

/* ท้ายแถบข้าง — ภาพประกอบ + คำโปรย */
.sidebar-logout {
  padding: 10px 12px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-tagline {
  text-align: center;
  padding: 4px 8px 6px;
  font-size: 11.5px;
  line-height: 1.55;
  color: rgba(255,255,255,.5);
}
.sidebar-tagline-heart { color: #f87171; }

/* แบนเนอร์โหมดสวมสิทธิ์ — อยู่ในสายเนื้อหา ไม่ตรึงจอ (เคยตรึงแล้วทับหัวหน้า) */
.impersonate-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--warning);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-wrap: wrap;
  line-height: 1.5;
}
.impersonate-banner a { color: #fff; text-decoration: underline; }

@media (max-width: 620px) {
  /* จอแคบ: ให้ข้อความอยู่บรรทัดเดียวและปุ่มลงมาอยู่ใต้ข้อความ ไม่ฉีกเป็นคอลัมน์ */
  .impersonate-banner { flex-direction: column; align-items: stretch; gap: 8px; text-align: center; font-size: 12px; }
  .impersonate-banner .btn { margin-left: 0 !important; width: 100%; justify-content: center; }
}

/* ── พื้นที่เนื้อหา ─────────────────────────────────────── */
.main-content {
  margin-top: var(--navbar-h);
  margin-left: var(--sidebar-w);
  min-height: calc(100vh - var(--navbar-h));
  padding: 20px 22px 32px;
}

/* ============================================================
   BREADCRUMB (แบบแทรกในเนื้อหา)
   ============================================================ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep { color: var(--border); }
.breadcrumb-current { color: var(--text); font-weight: 500; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 21px;
  font-weight: 700;
  color: #16233d;
  display: flex;
  align-items: center;
  gap: 12px;
  line-height: 1.25;
}

.page-title-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.page-title-sub {
  display: block;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 1px;
}

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

/* ชิปแสดงข้อมูลบนหัวหน้า เช่น วันที่ / ชื่อหอพัก */
.page-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid rgba(226,232,240,.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: #16233d;
  display: flex;
  align-items: center;
  gap: 9px;
}

/* ไอคอนสี่เหลี่ยมมนหน้าหัวข้อการ์ด */
.card-title-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.ci-blue   { background: #e0ecff; }
.ci-green  { background: #d9f7ec; }
.ci-orange { background: #fef0d9; }
.ci-pink   { background: #ffe4ec; }
.ci-purple { background: #ece7fe; }
.ci-teal   { background: #d7f5f2; }

/* ลิงก์ "ดูทั้งหมด >" มุมขวาของการ์ด */
.card-link {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  transition: background .18s;
}
.card-link:hover { background: #dbeafe; color: var(--primary-dark); }

/* Card Header Filter Bar */
.card-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.card-filter form { display: contents; }
.card-filter .form-control { height: 34px; font-size: 13px; width: auto; }
.card-filter .btn { height: 34px; padding: 0 12px; font-size: 13px; flex-shrink: 0; }

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-card {
  position: relative;
  overflow: hidden;
  padding: 12px 14px 13px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* แถวบนของการ์ด: ไอคอน + ชื่อรายการ + ปุ่มลูกศร อยู่บรรทัดเดียวกัน */
.kpi-top {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
}

.kpi-blob {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.blob-purple { background: rgba(139,92,246,.25); }
.blob-yellow { background: rgba(251,191,36,.25); }
.blob-green  { background: rgba(34,197,94,.25); }
.blob-red    { background: rgba(239,68,68,.25); }
.blob-blue   { background: rgba(14,165,233,.25); }
.blob-orange { background: rgba(249,115,22,.25); }

/* การ์ดสรุปที่คลิกได้ (หน้าใบแจ้งหนี้ใช้กรองตามสถานะ) */
a.kpi-card { text-decoration: none; transition: transform .18s, box-shadow .18s; }
a.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* การ์ดในหน้าอื่นที่ยังวางไอคอนไว้บรรทัดบนแยก (ไม่ได้ใช้ .kpi-top) */
.kpi-card > .kpi-blob { margin-bottom: 8px; }

.kpi-label { flex: 1; min-width: 0; font-size: 11.5px; font-weight: 500; color: var(--text-muted); line-height: 1.3; }
.kpi-value { font-size: 25px; font-weight: 700; color: var(--text); line-height: 1.15; }
.kpi-sub   { font-size: 11px; color: var(--text-light); margin-top: 2px; line-height: 1.4; }

/* การ์ด KPI แบบไล่สี */
.kpi-card.kc-blue   { background: var(--grad-blue); }
.kpi-card.kc-green  { background: var(--grad-green); }
.kpi-card.kc-indigo { background: var(--grad-indigo); }
.kpi-card.kc-teal   { background: var(--grad-teal); }
.kpi-card.kc-pink   { background: var(--grad-pink); }
.kpi-card.kc-orange { background: var(--grad-orange); }
.kpi-card.kc-purple { background: var(--grad-purple); }
.kpi-card.kc-gold   { background: var(--grad-gold); }
.kpi-card.kc-dark   { background: var(--grad-dark); }

[class*="kc-"] .kpi-label { color: rgba(255,255,255,.85) !important; }
[class*="kc-"] .kpi-value { color: #fff !important; }
[class*="kc-"] .kpi-sub   { color: rgba(255,255,255,.78) !important; }
[class*="kc-"] .kpi-blob  { background: rgba(255,255,255,.22); }

/* ปุ่มลูกศรมุมขวาล่างของการ์ด KPI */
.kpi-action {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,.22);
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background .18s, transform .18s;
}
.kpi-action:hover { background: rgba(255,255,255,.4); color: #fff; transform: translateX(2px); }

/* ป้ายเปอร์เซ็นต์เปลี่ยนแปลงในการ์ด KPI */
.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 600;
}

/* ============================================================
   GRID
   ============================================================ */
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.grid-7 { grid-template-columns: repeat(7, 1fr); }

/* แถวการ์ดสรุป — ทุกหน้าใช้ 6 ใบ และตอนย่อจอจะลดทีละคู่ (6 → 4 → 2) */
.grid-kpi { grid-template-columns: repeat(6, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }
/* แถวแดชบอร์ด: กราฟกว้าง | โดนัท | รายการ */
.grid-dash-3 { grid-template-columns: 1.85fr 1.15fr 1fr; }
.grid-dash-2 { grid-template-columns: 1.55fr 1fr; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 40px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-btn);
  cursor: pointer;
  border: none;
  transition: all .2s;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}

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

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-navy { background: var(--sidebar-bg); color: #fff; }
.btn-navy:hover { background: #1b2c53; color: #fff; }

/* ปุ่มโทนส้ม — ใช้เมื่อต้องการเน้นต่างจากปุ่มหลัก */
.btn-orange { background: var(--secondary); color: #fff; }
.btn-orange:hover { background: #ea6c05; color: #fff; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }

/* Used by superadmin/owners.php for the credential-edit buttons — previously
   had no definition at all, so those buttons rendered unstyled. */
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { background: var(--primary-dark); color: #fff; }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 16px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { width: 40px; padding: 0; justify-content: center; }
.btn-icon.btn-sm { width: 32px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-label.required::after { content: ' *'; color: var(--danger); }

.input-group { position: relative; display: flex; align-items: center; }

.input-prefix {
  position: absolute;
  left: 12px;
  font-size: 16px;
  pointer-events: none;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,.14);
}

.form-control.with-prefix { padding-left: 40px; }
.form-control.with-suffix { padding-right: 40px; }

textarea.form-control { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.form-control::placeholder { color: #94a3b8; }

.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-hint  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-section { margin-bottom: 24px; }
.form-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  padding: 8px 0;
  border-bottom: 2px solid var(--secondary);
  margin-bottom: 16px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-container {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  /* auto, not hidden: a table wider than the card used to be cut off with no
     way to reach the remaining columns. */
  overflow-x: auto;
  overflow-y: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.table-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.table-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.search-input {
  height: 36px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 10px center;
  outline: none;
  min-width: 200px;
}

.search-input:focus { border-color: var(--primary); }

.filter-select {
  height: 36px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 8px center;
  appearance: none;
  outline: none;
  cursor: pointer;
}

.filter-select:focus { border-color: var(--primary); }

table {
  width: 100%;
  border-collapse: collapse;
}

thead tr {
  background: #f8fafc;
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

thead th:hover { color: var(--primary); }

thead th.no-sort { cursor: default; }
thead th.no-sort:hover { color: var(--text-muted); }

.th-num { width: 48px; text-align: center; }

tbody tr {
  height: 52px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

td {
  padding: 0 16px;
  font-size: 14px;
  color: var(--text);
  vertical-align: middle;
}

.td-num { text-align: center; color: var(--text-muted); font-size: 13px; }
.td-actions { display: flex; gap: 4px; align-items: center; }

/* No data */
.table-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.table-empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ============================================================
   BADGES / TAGS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-success  { background: #dcfce7; color: #16a34a; }
.badge-warning  { background: #fef3c7; color: #d97706; }
.badge-danger   { background: #fee2e2; color: #dc2626; }
.badge-info     { background: #dbeafe; color: #1d4ed8; }
.badge-secondary{ background: #f1f5f9; color: #64748b; }
.badge-primary  { background: #dbeafe; color: #1e3a5f; }
.badge-orange   { background: #fff7ed; color: #f97316; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success  { background: #dcfce7; color: #15803d; border-left: 4px solid #16a34a; }
.alert-danger   { background: #fee2e2; color: #dc2626; border-left: 4px solid #dc2626; }
.alert-warning  { background: #fef3c7; color: #d97706; border-left: 4px solid #d97706; }
.alert-info     { background: #dbeafe; color: #1d4ed8; border-left: 4px solid #0284c7; }

.alert-close {
  position: absolute;
  top: 8px; right: 12px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: inherit;
  opacity: .6;
  line-height: 1;
  padding: 0;
}
.alert-close:hover { opacity: 1; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  /* Above .owner-bottom-nav (320) and .sidebar (310) so a dialog is never
     covered by, or clickable through, the mobile chrome. */
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* openModal() sets an inline display:flex; this class is the markup-only way. */
.modal-overlay.is-open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-lg { max-width: 800px; }
.modal-sm { max-width: 400px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 16px; font-weight: 600; }

.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--bg); }

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   SUMMARY CARDS (Table header stats)
   ============================================================ */
.summary-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }

.summary-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 16px;
  border-left: 4px solid transparent;
}

.summary-card-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.summary-card-value { font-size: 24px; font-weight: 700; }
.summary-card-sub   { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.summary-card.s-danger  { border-color: var(--danger); }
.summary-card.s-warning { border-color: var(--warning); }
.summary-card.s-success { border-color: var(--success); }

.summary-card.s-danger  .summary-card-value { color: var(--danger); }
.summary-card.s-warning .summary-card-value { color: var(--warning); }
.summary-card.s-success .summary-card-value { color: var(--success); }

/* ============================================================
   INVOICE SUMMARY CARDS
   ============================================================ */
.invoice-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

.invoice-summary-card {
  position: relative;
  display: block;
  min-height: 116px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid rgba(148,163,184,.16);
  border-left: 4px solid transparent;
  box-shadow: 0 8px 20px rgba(15,45,107,.06);
  text-decoration: none;
  color: inherit;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.invoice-summary-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(15,45,107,.10);
}

.invoice-summary-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: rgba(255,255,255,.7);
}

.invoice-summary-label {
  padding-right: 48px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.invoice-summary-value {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.invoice-summary-sub {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.invoice-summary-card-draft   { background: var(--grad-purple); border-left-color: transparent; }
.invoice-summary-card-pending { background: var(--grad-orange); border-left-color: transparent; }
.invoice-summary-card-partial { background: var(--grad-teal);   border-left-color: transparent; }
.invoice-summary-card-paid    { background: var(--grad-green);  border-left-color: transparent; }
.invoice-summary-card-overdue { background: var(--grad-pink);   border-left-color: transparent; }

.invoice-summary-card-draft .invoice-summary-label,
.invoice-summary-card-draft .invoice-summary-value,
.invoice-summary-card-draft .invoice-summary-icon,
.invoice-summary-card-draft .invoice-summary-sub,
.invoice-summary-card-pending .invoice-summary-label,
.invoice-summary-card-pending .invoice-summary-value,
.invoice-summary-card-pending .invoice-summary-icon,
.invoice-summary-card-pending .invoice-summary-sub,
.invoice-summary-card-partial .invoice-summary-label,
.invoice-summary-card-partial .invoice-summary-value,
.invoice-summary-card-partial .invoice-summary-icon,
.invoice-summary-card-partial .invoice-summary-sub,
.invoice-summary-card-paid .invoice-summary-label,
.invoice-summary-card-paid .invoice-summary-value,
.invoice-summary-card-paid .invoice-summary-icon,
.invoice-summary-card-paid .invoice-summary-sub,
.invoice-summary-card-overdue .invoice-summary-label,
.invoice-summary-card-overdue .invoice-summary-value,
.invoice-summary-card-overdue .invoice-summary-icon,
.invoice-summary-card-overdue .invoice-summary-sub {
  color: rgba(255,255,255,.92);
}

.invoice-summary-card-draft .invoice-summary-icon,
.invoice-summary-card-pending .invoice-summary-icon,
.invoice-summary-card-partial .invoice-summary-icon,
.invoice-summary-card-paid .invoice-summary-icon,
.invoice-summary-card-overdue .invoice-summary-icon {
  background: rgba(255,255,255,.18);
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress { height: 8px; background: var(--border); border-radius: 0; overflow: hidden; }
.progress-bar {
  height: 100%;
  border-radius: 0;
  transition: width .3s;
}
.progress-bar.p-danger  { background: var(--danger); }
.progress-bar.p-warning { background: var(--warning); }
.progress-bar.p-success { background: var(--success); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-layout {
  display: flex;
  min-height: 100vh;
}

.login-left {
  width: 52%;
  background: linear-gradient(145deg, #1a3a8f 0%, #0f2d6b 55%, #071a42 100%);
  color: #fff;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
}
/* dot grid */
.login-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.18) 1.2px, transparent 1.2px);
  background-size: 28px 28px;
  pointer-events: none;
}
/* floating neon blobs */
.login-left::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 80% 10%,  rgba(99,179,255,0.28) 0%, transparent 38%),
    radial-gradient(circle at 10% 85%,  rgba(249,115,22,0.20) 0%, transparent 38%),
    radial-gradient(circle at 60% 60%,  rgba(139,92,246,0.14) 0%, transparent 32%);
  pointer-events: none;
}
/* floating ring top-right */
.login-left-center::before {
  content: '';
  position: absolute;
  top: -80px; right: -80px;
  width: 280px; height: 280px;
  border-radius: 50%;
  border: 40px solid rgba(255,255,255,0.06);
  pointer-events: none;
}
/* floating ring bottom-left */
.login-left-center::after {
  content: '';
  position: absolute;
  bottom: -60px; left: -60px;
  width: 200px; height: 200px;
  border-radius: 50%;
  border: 28px solid rgba(99,179,255,0.10);
  pointer-events: none;
}

.login-left-center {
  width: 100%;
}

/* Brand row: logo + text side by side */
.login-brand-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
}

.login-left-logo-box {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-left-logo {
  display: block;
}

.login-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.login-left-title {
  font-size: 34px;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}

.login-left-subtitle-en {
  font-size: 17px;
  opacity: .70;
  letter-spacing: 0.3px;
  line-height: 1.3;
}

.login-features { list-style: none; }
.login-features li {
  padding: 10px 0;
  opacity: .85;
  font-size: 19px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.login-left-copy {
  font-size: 13px;
  opacity: .5;
  position: absolute;
  bottom: 32px;
  left: 60px;
}

.login-right {
  flex: 1;
  background: linear-gradient(145deg, #eef2ff 0%, #f1f5f9 50%, #e8f4fd 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  position: relative;
  overflow: hidden;
}
/* subtle dot pattern on right panel */
.login-right::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(99,130,255,0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.login-card {
  background: #fff;
  border-radius: 0;
  box-shadow:
    0 4px 6px rgba(0,0,0,.04),
    0 20px 60px rgba(15,45,107,.12),
    0 0 0 1px rgba(15,45,107,.06);
  padding: 0;
  width: 100%;
  max-width: 400px;
  overflow: hidden;
  position: relative;
}

.login-mobile-hero {
  display: none;
  position: relative;
  padding: 22px 22px 18px;
  background:
    linear-gradient(145deg, rgba(26,58,143,0.98) 0%, rgba(15,45,107,0.96) 58%, rgba(7,26,66,0.98) 100%);
  color: #fff;
  overflow: hidden;
}

.login-mobile-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.login-mobile-orb-a {
  width: 160px;
  height: 160px;
  top: -54px;
  right: -58px;
  background: radial-gradient(circle, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0) 68%);
}

.login-mobile-orb-b {
  width: 120px;
  height: 120px;
  left: -42px;
  bottom: -50px;
  background: radial-gradient(circle, rgba(249,115,22,0.28) 0%, rgba(249,115,22,0) 70%);
}

.login-mobile-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-mobile-logo-box {
  width: 62px;
  height: 62px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px rgba(0,0,0,0.16);
}

.login-mobile-logo {
  width: 42px;
  height: 42px;
}

.login-mobile-brand-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.login-mobile-eyebrow {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: rgba(255,255,255,0.72);
}

.login-mobile-heading {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.22;
}

.login-mobile-copy {
  font-size: 12px;
  line-height: 1.55;
  color: rgba(255,255,255,0.78);
}

.login-mobile-pills {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.login-mobile-pills span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.92);
  font-size: 12px;
  font-weight: 600;
}

/* Gradient top bar */
.login-card::before {
  content: '';
  display: block;
  height: 4px;
  background: linear-gradient(90deg, #0f2d6b, #3b82f6, #f97316);
}

.login-card-header {
  text-align: center;
  padding: 24px 32px 18px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 0;
}

.login-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: linear-gradient(135deg, #eef2ff, #dbeafe);
  border: 1px solid #bfdbfe;
  border-radius: 0;
  font-size: 13px;
  font-weight: 600;
  color: #1d4ed8;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.login-card-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.login-card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Form area */
.login-card form {
  padding: 20px 32px 0;
}

/* Override form-label inside card */
.login-card .form-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

/* Inputs inside login card */
.login-card .form-control {
  height: 42px;
  font-size: 14px;
}

/* Narrow input wrapper */
.login-card .input-group {
  max-width: 260px;
  margin: 0 auto;
}

/* Styled submit button */
.btn-login-submit {
  display: block;
  margin: 4px auto 0;
  padding: 0 48px;
  height: 44px;
  border: none;
  border-radius: 0;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  box-shadow: 0 4px 16px rgba(249,115,22,.38);
  transition: transform .15s, box-shadow .15s;
}
.btn-login-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(249,115,22,.48);
}
.btn-login-submit:active {
  transform: translateY(0);
}

.login-trust-row {
  display: none;
}

.login-trust-item {
  display: inline-flex;
}

.login-card-footer {
  padding: 14px 20px 20px;
  text-align: center;
  font-size: 13px;
  color: #94a3b8;
  margin-top: 16px;
  border-top: 1px solid #f1f5f9;
  white-space: nowrap;
}

/* ============================================================
   TABS
   ============================================================ */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; }
.tab {
  padding: 8px 16px;
  border-radius: var(--radius-btn);
  font-size: 14px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: all .2s;
  white-space: nowrap;
  text-decoration: none;
}
.tab:hover { border-color: var(--primary); color: var(--primary); }
.tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ============================================================
   TENANT DASHBOARD (Mobile-first)
   ============================================================ */
.tenant-layout { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--bg); }

.tenant-header {
  background: var(--primary);
  padding: 16px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tenant-header-logo {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tenant-body { padding: 16px; padding-bottom: 80px; }

.tenant-greeting {
  background: linear-gradient(135deg, var(--primary), #2d5a8e);
  border-radius: var(--radius);
  padding: 20px;
  color: #fff;
  margin-bottom: 16px;
}

.tenant-greeting-name { font-size: 18px; font-weight: 600; }
.tenant-greeting-room { font-size: 14px; opacity: .8; margin-top: 4px; }

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .2s;
  padding: 4px;
}

.bottom-nav-item .icon { font-size: 20px; }

.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item:hover  { color: var(--primary); }

.tenant-app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 80px;
}

.tenant-topbar {
  position: sticky;
  top: 0;
  z-index: 110;
  background: var(--secondary);
  color: #fff;
  min-height: 58px;
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(15,45,107,.18);
}

.tenant-topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.tenant-topbar-subtitle {
  margin-top: 2px;
  font-size: 12px;
  color: rgba(255,255,255,.82);
}

.tenant-body {
  padding: 16px 12px 88px;
  max-width: 480px;
  margin: 0 auto;
}

.tenant-panel {
  background: #fff;
  border: 1px solid rgba(148,163,184,.18);
  box-shadow: 0 10px 24px rgba(15,45,107,.06);
  padding: 16px;
  margin-bottom: 12px;
}

.tenant-panel-hero {
  background: linear-gradient(135deg, var(--primary), #2d5a8e);
  color: #fff;
}

.tenant-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tenant-empty-state {
  text-align: center;
  color: #94a3b8;
  padding: 24px 16px;
  font-size: 13px;
}

.tenant-note-box {
  padding: 12px;
  text-align: center;
  font-size: 13px;
  margin-bottom: 8px;
}

.tenant-note-box.is-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.tenant-note-box.is-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #b45309;
}

.tenant-action-panel {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.tenant-upload-panel {
  margin-top: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 12px;
}

.tenant-list-item {
  border-bottom: 1px solid #f1f5f9;
  padding: 10px 0;
}

.tenant-list-item:last-child {
  border-bottom: none;
}

.tenant-announce-item {
  border-left: 3px solid var(--primary);
  padding: 8px 12px;
  background: #f8fafc;
}

.tenant-announce-item.is-pinned {
  border-left-color: var(--secondary);
}

.tenant-status-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.tenant-status-main {
  flex: 1;
}

.tenant-meta-text {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 3px;
}

.tenant-highlight-danger {
  color: #dc2626;
}

.tenant-highlight-success {
  color: #16a34a;
}

@media (max-width: 768px) {
  .tenant-topbar {
    padding: 12px;
  }

  .tenant-body {
    padding: 14px 12px 88px;
  }

  .tenant-panel {
    padding: 14px;
  }

  .bottom-nav {
    max-width: 480px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    box-shadow: 0 -8px 24px rgba(15,45,107,.10);
    z-index: 320;
  }

  .bottom-nav-item {
    min-height: 64px;
    font-size: 11px;
    font-weight: 600;
  }

  .bottom-nav-item.active {
    background: linear-gradient(180deg, rgba(26,58,143,.08) 0%, rgba(26,58,143,0) 100%);
  }
}

@media (max-width: 480px) {
  .tenant-topbar {
    padding: 12px 10px;
  }

  .tenant-topbar-title {
    font-size: 14px;
  }

  .tenant-body {
    padding: 12px 10px 86px;
  }

  .tenant-panel {
    padding: 12px;
  }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.d-flex    { display: flex; }
.d-block   { display: block; }
.d-none    { display: none; }
.d-grid    { display: grid; }
.align-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-4  { gap: 4px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.p-0  { padding: 0; }
.p-8  { padding: 8px; }
.p-12 { padding: 12px; }
.p-16 { padding: 16px; }
.p-20 { padding: 20px; }

.mb-0  { margin-bottom: 0; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-auto { margin-top: auto; }

.w-full { width: 100%; }
.h-full { height: 100%; }
.rounded { border-radius: var(--radius-sm); }
.rounded-full { border-radius: 999px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.no-wrap { white-space: nowrap; }

.overflow-hidden { overflow: hidden; }

/* Spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

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

/* การ์ดสรุปบนจอแคบ — บังคับ 2 ใบต่อแถว จึงต้องย่อตัวอักษรให้อยู่ในกรอบ */
@media (max-width: 620px) {
  .kpi-card { padding: 10px 11px; overflow: hidden; }
  .kpi-top { gap: 7px; margin-bottom: 5px; }
  .kpi-blob { width: 28px; height: 28px; border-radius: 8px; }
  .kpi-blob .dms-icon { width: 18px; height: 18px; }
  .kpi-label { font-size: 10.5px; line-height: 1.25; }
  .kpi-value { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .kpi-sub { font-size: 9.5px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .kpi-action { width: 20px; height: 20px; font-size: 11px; }
}

/* ── ไอคอน 3D (assets/icons) ───────────────────────────────────────── */
.dms-icon {
  display: inline-block;
  object-fit: contain;
  vertical-align: middle;
  flex-shrink: 0;
}
/* ไอคอนบนพื้นสีเข้ม/ไล่สี ให้มีเงาอ่อน ๆ เพื่อไม่จมไปกับพื้น */
.sidebar-item .dms-icon,
.kpi-blob .dms-icon { filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }

.page-title-icon .dms-icon,
.card-title-icon .dms-icon,
.task-icon .dms-icon,
.mini-stat-icon .dms-icon { width: 76%; height: 76%; }

.sidebar-tagline-art { display: flex; justify-content: center; margin-bottom: 6px; }
/* รูปหอพักท้ายแถบข้าง — ให้กว้างเกือบเต็มแถบ */
.sidebar-tagline-art img {
  width: min(100%, 156px);
  height: auto;
  object-fit: contain;
  opacity: .6;                 /* โปร่งใส 40% ตามที่เจ้านายสั่ง */
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.3));
}
/* จอเตี้ย — ย่อรูปลงเพื่อไม่ให้เบียดรายการเมนู */
@media (max-height: 760px) {
  .sidebar-tagline-art img { width: min(100%, 104px); }
  .sidebar-tagline { font-size: 11px; padding: 2px 8px 4px; }
}
@media (max-height: 620px) {
  .sidebar-tagline-art { display: none; }
}

/* ── โหมดกระชับของหน้าแดชบอร์ด — ให้ทุกการ์ดพอดีหน้าจอเดียวตามแบบ ── */
.dash-compact .card { padding: 10px 12px; }
.dash-compact .card-header { margin-bottom: 8px; }
.dash-compact .card-title { font-size: 14px; }
.dash-compact .card-title-icon { width: 28px; height: 28px; border-radius: 8px; }
.dash-compact .donut-wrap { max-width: 118px; }
.dash-compact .legend-list { gap: 3px; margin-top: 8px !important; }
.dash-compact .legend-row { font-size: 11.5px; }
.dash-compact .donut-center-value { font-size: 17px; }
.dash-compact .donut-center-label { font-size: 10.5px; }
.dash-compact .task-row { padding: 4px 0; }
.dash-compact .task-icon { width: 28px; height: 28px; border-radius: 8px; }
.dash-compact .task-title { font-size: 12.5px; }
.dash-compact .ann-row { padding: 5px 0; }
.dash-compact .ann-title { font-size: 12.5px; }
.dash-compact .mini-table th { padding: 5px 7px; }
.dash-compact .mini-table td { padding: 4px 7px; font-size: 11.5px; }
.dash-compact .dash-summary-box { padding: 7px 10px; margin-bottom: 6px; }
.dash-compact .dash-summary-value { font-size: 15px; }
.dash-compact .dash-summary-label { font-size: 11px; }
.dash-compact .dash-chart-row { grid-template-columns: 1fr 168px; gap: 12px; }
.dash-compact .event-strip { grid-auto-columns: minmax(126px, 1fr); gap: 10px; }
.dash-compact .event-card { padding: 7px 9px; }
.dash-compact .event-day { font-size: 17px; }
.dash-compact .mini-stat { padding: 8px 10px; }
.dash-compact .mini-stat-head { margin-bottom: 4px; }
.dash-compact .mini-stat-icon { width: 24px; height: 24px; border-radius: 7px; }
.dash-compact .mini-stat-value { font-size: 14px; }
.dash-compact .cal-nav { font-size: 12.5px; }
.dash-compact .grid { gap: 11px; }
.dash-compact > .grid { margin-bottom: 11px !important; }
.dash-compact .page-header { margin-bottom: 12px; }
.dash-compact .ann-desc { font-size: 11px; }
.dash-compact .event-name { font-size: 11.5px; }

/* ── ความสูงของแต่ละแถวในแดชบอร์ด ────────────────────────────────────
   ล็อกให้ทั้งหน้าพอดีหนึ่งหน้าจอเหมือนแบบที่วางไว้ การ์ดที่เป็นรายการยาว
   จะเลื่อนดูในตัวเองแทนที่จะดันหน้าให้ยืด                                */
.dash-compact .dash-row > .card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.dash-compact .dash-row > .card > .card-header { flex-shrink: 0; }
.dash-compact .dash-row-a > .card { height: 252px; }
.dash-compact .dash-row-b > .card { height: 210px; }
.dash-compact .dash-row-c > .card { height: 130px; }

/* กล่องเนื้อหาที่เลื่อนได้ภายในการ์ด */
.card-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
}
.card-scroll::-webkit-scrollbar { width: 5px; height: 5px; }
.card-scroll::-webkit-scrollbar-thumb { background: #d5dae4; border-radius: 4px; }
.card-scroll::-webkit-scrollbar-track { background: transparent; }

/* จอเตี้ยกว่า 820px ปล่อยให้ความสูงเป็นไปตามเนื้อหา จะได้ไม่บีบจนอ่านไม่ออก */
@media (max-height: 820px), (max-width: 1100px) {
  .dash-compact .dash-row-a > .card,
  .dash-compact .dash-row-b > .card,
  .dash-compact .dash-row-c > .card { height: auto; }
}

/* รายการกิจกรรมในหน้าปฏิทิน */
.event-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.event-item-date {
  width: 52px;
  text-align: center;
  flex-shrink: 0;
}
.event-item-day { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.1; }
.event-item-dow { font-size: 11px; color: var(--text-muted); }
.event-item-body { flex: 1; min-width: 0; }
.event-item-title { font-size: 14px; font-weight: 600; color: var(--text); }
.event-item-note { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.event-item-actions { display: flex; gap: 5px; flex-shrink: 0; }

@media (max-width: 520px) {
  .event-item { flex-wrap: wrap; }
  .event-item-actions { width: 100%; justify-content: flex-end; }
}

/* ============================================================
   SIDEBAR — เมนูย่อย / ยุบแถบข้าง / กล่องแพ็กเกจ
   ============================================================ */
.sidebar-item-toggle {
  width: calc(100% - 24px);
  font-family: inherit;
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
}

.sidebar-caret {
  font-size: 11px;
  color: rgba(255,255,255,.5);
  transition: transform .2s;
}
.sidebar-caret.is-open { transform: rotate(180deg); }
.sidebar-item.active .sidebar-caret { color: rgba(255,255,255,.9); }

.sidebar-submenu {
  margin: 2px 12px 6px 34px;
  padding-left: 10px;
  border-left: 1px solid rgba(255,255,255,.12);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-subitem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: rgba(255,255,255,.62);
  text-decoration: none;
  transition: background .16s, color .16s;
}
.sidebar-subitem:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-subitem.active { background: rgba(59,130,246,.22); color: #fff; font-weight: 600; }

.sidebar-package {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.06);
  font-size: 11.5px;
  text-decoration: none;
}
.sidebar-package-label { color: rgba(255,255,255,.6); }
.sidebar-package-days  { font-weight: 700; }

/* ยุบแถบข้างบนจอกว้าง */
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main-content { margin-left: 0; }

/* ============================================================
   DASHBOARD — ส่วนประกอบเฉพาะหน้าแดชบอร์ด
   ============================================================ */

/* ปุ่มสลับชุดข้อมูลบนกราฟ */
.dash-toggle { display: inline-flex; gap: 6px; }
.dash-toggle button {
  height: 30px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .18s;
}
.dash-toggle button:hover { border-color: var(--primary-light); color: var(--primary); }
.dash-toggle button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* กราฟ + กล่องสรุปด้านขวา */
.dash-chart-row { display: grid; grid-template-columns: 1fr 190px; gap: 16px; align-items: start; }
.dash-chart-box { min-width: 0; }

.dash-summary-box {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}
.dash-summary-box:last-child { margin-bottom: 0; }
.dash-summary-label { font-size: 11.5px; color: var(--text-muted); }
.dash-summary-value { font-size: 18px; font-weight: 700; color: var(--text); line-height: 1.3; }

.trend-up   { color: var(--success); font-size: 11.5px; font-weight: 600; }
.trend-down { color: var(--danger);  font-size: 11.5px; font-weight: 600; }

/* โดนัทพร้อมตัวเลขตรงกลาง */
.donut-wrap { position: relative; width: 100%; max-width: 190px; margin: 0 auto; }
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.donut-center-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.1; }
.donut-center-label { font-size: 11.5px; color: var(--text-muted); }

/* โดนัท + คำอธิบายสี วางคู่กันซ้าย-ขวา (ตามแบบ) */
.donut-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  min-height: 0;
}
.donut-row .donut-wrap { margin: 0; }
@media (max-width: 1240px) {
  .donut-row { grid-template-columns: 1fr; justify-items: center; }
  .donut-row .legend-list { width: 100%; }
}

/* แถวคำอธิบายสีของโดนัท */
.legend-list { display: flex; flex-direction: column; gap: 11px; }
.legend-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text);
}
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-name { flex: 1; color: var(--text-muted); }
.legend-value { font-weight: 700; }
.legend-pct { width: 48px; text-align: right; font-size: 12px; color: var(--text-light); }

/* รายการงานที่ต้องจัดการ / ประกาศ */
.task-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 0;
  border-bottom: 1px solid #f1f3f7;
  text-decoration: none;
  color: var(--text);
}
.task-row:last-child { border-bottom: none; }
.task-row:hover .task-title { color: var(--primary); }

.task-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.task-title { flex: 1; font-size: 13px; font-weight: 500; }
.task-count { font-size: 13px; font-weight: 700; white-space: nowrap; }
.task-unit  { font-size: 11.5px; color: var(--text-light); font-weight: 400; margin-left: 3px; }

.ann-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f3f7;
}
.ann-row:last-child { border-bottom: none; }
.ann-body { flex: 1; min-width: 0; }
.ann-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1px;
}
.ann-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ann-date { font-size: 11px; color: var(--text-light); white-space: nowrap; }

/* ปฏิทินกิจกรรม */
.cal-nav { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; }
.cal-nav a {
  width: 24px; height: 24px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt);
  color: var(--text-muted);
}
.cal-nav a:hover { background: var(--primary-soft); color: var(--primary); }

.event-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(140px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.event-card {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  min-width: 0;
}
.event-card.is-today { background: var(--primary-soft); border-color: #bfdbfe; }
.event-card-head { display: flex; align-items: baseline; gap: 7px; margin-bottom: 6px; }
.event-day  { font-size: 19px; font-weight: 700; color: var(--text); line-height: 1; }
.event-dow  { font-size: 11.5px; color: var(--text-muted); }
.event-name { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text); }
.event-dot  { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.event-empty { font-size: 12px; color: var(--text-light); }

/* การ์ดภาพรวมการเงินใบเล็ก */
.mini-stat {
  padding: 12px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
}
.mini-stat-head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.mini-stat-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.mini-stat-label { font-size: 11.5px; color: var(--text-muted); }
.mini-stat-value { font-size: 17px; font-weight: 700; color: var(--text); line-height: 1.25; }

/* ตารางย่อในการ์ดแดชบอร์ด */
.mini-table { width: 100%; border-collapse: collapse; }
.mini-table th {
  padding: 7px 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.mini-table td {
  padding: 9px 8px;
  font-size: 12.5px;
  border-bottom: 1px solid #f1f3f7;
  white-space: nowrap;
}
.mini-table tr:last-child td { border-bottom: none; }
.mini-table .num { font-weight: 700; }

/* จุดบอกสถานะห้อง (ใช้ร่วมกับ legend) */
.sw-occupied    { background: #3b82f6; }
.sw-vacant      { background: #10b981; }
.sw-notice      { background: #f59e0b; }
.sw-maintenance { background: #64748b; }

@media (max-width: 1400px) {
  .grid-kpi, .grid-7 { grid-template-columns: repeat(4, 1fr); }
  .grid-dash-3 { grid-template-columns: 1.6fr 1fr; }
  .grid-dash-3 > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 1100px) {
  .grid-dash-3, .grid-dash-2 { grid-template-columns: 1fr; }
  .grid-dash-3 > :last-child { grid-column: auto; }
  .dash-chart-row { grid-template-columns: 1fr; }
  .dash-summary-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .dash-summary-box { margin-bottom: 0; }
}
@media (max-width: 900px) {
  .grid-kpi, .grid-7 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .dash-summary-row { grid-template-columns: 1fr; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Hamburger button — always visible (triggers mobile sidebar) */
/* Secondary menu button in the navbar. It opens the same drawer as the
   hamburger, so on desktop it was just a duplicate icon sitting next to it —
   keep it for narrow screens only. */
.navbar-more-btn { display: none; }
@media (max-width: 768px) {
  .navbar-more-btn { display: inline-flex; }
}

.navbar-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
  margin-right: 4px;
}
.navbar-hamburger span {
  display: block;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all .25s;
}
.navbar-hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.navbar-hamburger.open span:nth-child(2) { opacity: 0; }
.navbar-hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* Mobile brand in navbar — hidden on desktop */
.navbar-mobile-brand {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}

/* Sidebar overlay — hidden on desktop */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 325;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* Owner bottom nav — hidden on desktop, shown on mobile */
.owner-bottom-nav { display: none; }

/* ============================================================
   RESPONSIVE LAYOUT GRIDS — replaces inline style grids
   ============================================================ */
/* Main 2-column page layout: content + sidebar-card */
.page-two-col {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}
/* Wider left variant (used by settings security tab) */
.page-two-col-wide {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 24px;
  align-items: start;
}
/* Dashboard 2fr/1fr (superadmin) */
.sa-dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}
/* Form field rows inside cards */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 1024px) {
  /* จอแคบ — แถบข้างเปลี่ยนเป็นลิ้นชักที่เลื่อนเข้ามาทับเนื้อหา */
  .sidebar { transform: translateX(-100%); z-index: 330; box-shadow: 8px 0 32px rgba(0,0,0,.25); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
}

@media (max-width: 768px) {
  /* Navbar */
  .navbar {
    height: 58px;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
  }
  .navbar-search-wrap { display: none; }
  .navbar-username { display: none; }
  .navbar-caret { display: none; }
  .navbar-right { gap: 6px; padding-right: 10px; }

  /* Sidebar — mobile drawer (already transform: translateX(-100%) on desktop too) */
  .sidebar {
    width: min(86vw, 320px);
  }
  .sidebar { top: 58px; height: calc(100vh - 58px); }

  .main-content {
    margin-left: 0;
    margin-top: 58px;
    min-height: calc(100vh - 58px);
    padding: 14px 12px 86px;
    max-width: 100%;
    margin-right: auto;
  }

  .page-header {
    margin-bottom: 16px;
    align-items: flex-start;
    gap: 10px;
  }
  .page-title {
    font-size: 20px;
    gap: 8px;
    line-height: 1.25;
  }
  .page-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
    margin-top: 4px;
  }
  .page-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .breadcrumb {
    margin-bottom: 12px;
    font-size: 12px;
  }

  /* Grids */
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1 { grid-template-columns: 1fr; }

  /* Login */
  .login-left { display: none; }
  .login-layout {
    display: block;
    min-height: 100vh;
    background:
      radial-gradient(circle at top right, rgba(249,115,22,0.20) 0%, rgba(249,115,22,0) 30%),
      radial-gradient(circle at left 20%, rgba(26,58,143,0.12) 0%, rgba(26,58,143,0) 38%),
      linear-gradient(180deg, #edf4ff 0%, #f8fbff 42%, #eef2f7 100%);
  }
  .login-right {
    min-height: 100vh;
    padding: 16px;
    align-items: center;
  }
  .login-right::before {
    background-image: radial-gradient(rgba(26,58,143,0.08) 1px, transparent 1px);
    background-size: 18px 18px;
  }
  .login-card {
    max-width: 100%;
    margin: 0;
    box-shadow:
      0 10px 24px rgba(15,45,107,.10),
      0 18px 44px rgba(15,45,107,.08),
      0 0 0 1px rgba(15,45,107,.05);
  }
  .login-mobile-hero {
    display: block;
    padding: 14px 16px 12px;
  }
  .login-mobile-brand {
    gap: 10px;
    align-items: flex-start;
  }
  .login-mobile-logo-box {
    width: 48px;
    height: 48px;
  }
  .login-mobile-logo {
    width: 32px;
    height: 32px;
  }
  .login-mobile-eyebrow {
    font-size: 11px;
    letter-spacing: 0.12em;
  }
  .login-mobile-heading {
    font-size: 17px;
    line-height: 1.22;
  }
  .login-mobile-copy {
    font-size: 11px;
    line-height: 1.4;
    max-width: 220px;
  }
  .login-mobile-pills {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }
  .login-mobile-pills span {
    min-height: 42px;
    justify-content: flex-start;
    text-align: left;
    padding: 8px 10px;
    font-size: 11px;
    line-height: 1.3;
    background: rgba(255,255,255,0.08);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
  }
  .login-mobile-pills span:nth-child(3) {
    grid-column: 1 / -1;
  }
  .login-card-header {
    padding: 16px 16px 10px;
    text-align: left;
  }
  .login-card-title {
    font-size: 21px;
    letter-spacing: -0.02em;
    line-height: 1.38;
    padding-top: 2px;
  }
  .login-card-subtitle {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.5;
  }
  .login-card form {
    padding: 16px 18px 0;
  }
  .login-card .form-group {
    margin-bottom: 14px;
  }
  .login-card .form-label {
    font-size: 12px;
  }
  .login-card .input-group {
    max-width: none;
  }
  .login-card .form-control {
    height: 44px;
    font-size: 14px;
  }
  .btn-login-submit {
    height: 46px;
    font-size: 15px;
    box-shadow: 0 10px 24px rgba(249,115,22,.28);
  }
  .login-trust-row {
    margin-top: 12px;
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
  }
  .login-trust-item {
    min-height: 26px;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
  }
  .login-card-footer {
    padding: 14px 18px 16px;
    font-size: 12px;
  }
  .login-card-footer span {
    display: block;
    width: 100%;
    text-align: center;
    white-space: nowrap;
  }
  .summary-cards { grid-template-columns: 1fr; }
  .invoice-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .invoice-summary-card {
    min-height: 104px;
    padding: 14px;
  }
  .invoice-summary-icon {
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    font-size: 16px;
  }
  .invoice-summary-label {
    padding-right: 40px;
    font-size: 11px;
  }
  .invoice-summary-value {
    margin-top: 8px;
    font-size: 24px;
  }
  .invoice-summary-sub {
    font-size: 11px;
  }
  .invoice-summary-grid .invoice-summary-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 16px;
  }
  .table-filters { justify-content: flex-start; }

  /* Page header */
  .page-title { font-size: 18px; }
  .page-header { margin-bottom: 14px; }

  /* KPI cards */
  .kpi-card {
    padding: 14px;
    box-shadow: 0 4px 16px rgba(15,45,107,.08);
    min-height: 132px;
    display: flex;
    flex-direction: column;
  }
  .kpi-label {
    font-size: 11px;
    line-height: 1.45;
    margin-bottom: 6px;
    padding-right: 52px;
    max-width: none;
  }
  .kpi-value {
    font-size: clamp(22px, 5vw, 28px);
    line-height: 1;
    max-width: none;
    padding-right: 52px;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .kpi-sub {
    font-size: 11px;
    max-width: none;
    line-height: 1.45;
    margin-top: auto;
  }
  .kpi-blob {
    width: 44px;
    height: 44px;
    font-size: 20px;
    top: 12px;
    right: 12px;
  }
  .kpi-action {
    display: none;
  }

  /* Cards */
  .card {
    padding: 14px;
    box-shadow: 0 10px 24px rgba(15,45,107,.06);
  }
  .card-header {
    margin-bottom: 12px;
    gap: 10px;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .card-title {
    font-size: 15px;
    line-height: 1.3;
  }
  .card-filter {
    width: 100%;
    margin-left: 0;
    justify-content: stretch;
    gap: 8px;
  }
  .card-filter .form-control,
  .card-filter .btn {
    width: 100% !important;
    min-width: 0 !important;
  }
  .card-filter > * {
    flex: 1 1 100%;
  }
  .card-filter form {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .btn {
    min-height: 40px;
  }

  .form-row,
  .form-row-2,
  .form-row-3 {
    grid-template-columns: 1fr;
  }

  .table-responsive,
  .table-container {
    border: 1px solid var(--border);
    background: #fff;
  }
  .card-body-flush {
    padding: 0;
  }
  .mobile-stat-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .mobile-stat-item,
  .mobile-stat-item-last {
    background: #fff;
    border: 1px solid rgba(148,163,184,.2);
    padding: 12px;
    box-shadow: 0 4px 12px rgba(15,45,107,.06);
    margin-bottom: 0 !important;
  }
  .mobile-total-card {
    background: linear-gradient(135deg, #f8fbff 0%, #eef4ff 100%) !important;
    border: 1px solid rgba(37,99,235,.12);
    box-shadow: 0 4px 12px rgba(15,45,107,.07);
    padding: 14px !important;
  }
  .mobile-filter-bar {
    display: flex;
    flex-direction: column;
    gap: 10px !important;
    margin-bottom: 16px !important;
  }
  .mobile-filter-bar > div,
  .mobile-filter-bar > button,
  .mobile-filter-bar > a {
    width: 100%;
  }
  .mobile-filter-bar .form-control,
  .mobile-filter-bar .btn {
    width: 100% !important;
    min-width: 0 !important;
  }
  .mobile-list-only {
    display: block;
  }
  .desktop-table-only {
    display: none;
  }
  .mobile-table-actions {
    justify-content: center;
    flex-wrap: wrap;
  }
  .mobile-table-actions .btn {
    min-width: 40px;
  }
  .admin-package-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  .admin-package-card {
    overflow: hidden;
  }
  .admin-package-card-head,
  .admin-package-card-body,
  .admin-package-card-actions {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
  .admin-package-card-actions {
    flex-direction: column;
  }
  .admin-package-card-actions .btn,
  .admin-package-card-actions form {
    width: 100%;
  }
  .admin-package-card-actions form .btn {
    width: 100%;
    justify-content: center;
  }
  .modal-card-shell {
    border-radius: 0 !important;
  }
  .mobile-record-grid {
    grid-template-columns: 1fr;
  }
  .mobile-inline-actions {
    grid-template-columns: 1fr;
  }

  /* Tables → compact cards on mobile */
  .table-container,
  .table-responsive {
    overflow: visible;
    border: none;
    background: transparent;
  }
  .mobile-card-table,
  .mobile-card-table tbody,
  .mobile-card-table tfoot {
    display: block;
    width: 100%;
  }
  .mobile-card-table {
    min-width: 0 !important;
    background: transparent;
    border-collapse: separate;
  }
  .mobile-card-table thead {
    display: none;
  }
  .mobile-card-table tbody tr {
    display: block;
    margin-bottom: 10px;
    padding: 12px;
    background: #fff;
    border: 1px solid rgba(148,163,184,.18);
    box-shadow: 0 4px 12px rgba(15,45,107,.06);
  }
  /* tfoot: compact summary bar — not a full card */
  .mobile-card-table tfoot tr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f1f5f9;
    border: 1px solid rgba(148,163,184,.18);
    margin-bottom: 8px;
    font-weight: 700;
  }
  .mobile-card-table tfoot td {
    display: block !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
  }
  .mobile-card-table tfoot td::before {
    display: none !important;
  }
  /* td: flex with ::before as label and .td-val as value */
  .mobile-card-table td,
  .mobile-card-table th {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100% !important;
    min-width: 0 !important;
    padding: 4px 0 !important;
    border: none !important;
    text-align: left !important;
    background: transparent !important;
    height: auto !important;
    white-space: normal !important;
  }
  .mobile-card-table td::before,
  .mobile-card-table th::before {
    content: attr(data-label);
    flex: 0 0 96px;
    min-width: 96px;
    max-width: 96px;
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-muted);
    font-weight: 400;
    padding-top: 2px;
  }
  /* .td-val wraps all cell content — single flex item in the value column */
  .mobile-card-table td > .td-val,
  .mobile-card-table th > .td-val {
    flex: 1;
    min-width: 0;
    word-break: break-word;
  }
  .mobile-card-table tr.mobile-card-row-empty td {
    display: block;
    padding: 0 !important;
    text-align: center !important;
  }
  .mobile-card-table tr.mobile-card-row-empty td::before,
  .mobile-card-table td[colspan]::before {
    display: none;
  }
  .mobile-card-table td[colspan] {
    display: block;
    text-align: center !important;
  }
  .mobile-card-table td .btn,
  .mobile-card-table td button,
  .mobile-card-table td a.btn {
    max-width: 100%;
  }
  .mobile-card-table .td-val img {
    max-width: 64px;
    height: auto;
  }
  .mobile-card-table .td-val > div,
  .mobile-card-table .td-val > form {
    min-width: 0;
  }

  .owner-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255,255,255,.98);
    border-top: 1px solid var(--border);
    z-index: 320;
    box-shadow: 0 -8px 24px rgba(15,45,107,.10);
    backdrop-filter: blur(10px);
  }
  .owner-bottom-nav .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    min-height: 64px;
  }
  .owner-bottom-nav .bottom-nav-item .icon {
    font-size: 18px;
    line-height: 1;
  }
  .owner-bottom-nav .bottom-nav-item.active {
    color: var(--primary);
    background: linear-gradient(180deg, rgba(26,58,143,.08) 0%, rgba(26,58,143,0) 100%);
  }
  .superadmin-bottom-nav .bottom-nav-item.active {
    color: #dc2626;
    background: linear-gradient(180deg, rgba(220,38,38,.10) 0%, rgba(220,38,38,0) 100%);
  }


@media (max-width: 480px) {
  .login-right {
    padding: 12px;
  }
  .login-mobile-hero {
    padding: 12px 12px 10px;
  }
  .login-mobile-brand {
    align-items: flex-start;
  }
  .login-mobile-heading {
    font-size: 16px;
  }
  .login-mobile-copy {
    font-size: 11px;
    max-width: 200px;
  }
  .login-mobile-pills {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .login-mobile-pills span {
    min-height: 40px;
    padding: 7px 8px;
    font-size: 11px;
  }
  .login-mobile-pills span:nth-child(3) {
    grid-column: 1 / -1;
  }
  .login-card-header {
    padding: 16px 14px 10px;
  }
  .login-card form {
    padding: 14px 14px 0;
  }
  .login-card-footer {
    padding: 12px 14px 14px;
  }
  .login-trust-row {
    gap: 6px;
    justify-content: center;
  }
  .login-trust-item {
    font-size: 11px;
    padding: 4px 8px;
  }
}
  /* Responsive layout grids → single column on mobile */
  .page-two-col,
  .page-two-col-wide,
  .sa-dashboard-grid {
    grid-template-columns: 1fr;
  }
  .form-row-2 { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }

  /* settings-tab-bar: horizontal scroll on mobile */
  .settings-tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    padding-bottom: 4px;
    margin-bottom: 24px !important;
    gap: 0;
  }
  .settings-tab-bar > a {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 10px 14px !important;
    font-size: 13px !important;
  }
  /* Responsive filter-bar (reports.php) */
  .filter-bar {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .filter-bar .form-group {
    min-width: 0 !important;
    flex: none !important;
    width: 100% !important;
  }
  .filter-bar .form-control,
  .filter-bar .btn {
    width: 100% !important;
  }

}

@media (max-width: 480px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .grid-5, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .grid-kpi { grid-template-columns: repeat(2, 1fr) !important; }
  .invoice-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .mobile-card-table tbody tr,
  .mobile-card-table tfoot tr {
    padding: 10px;
  }
  .mobile-card-table td,
  .mobile-card-table th {
    grid-template-columns: minmax(80px, 94px) 1fr;
    gap: 6px;
    font-size: 12px;
  }
  .mobile-card-table td::before,
  .mobile-card-table th::before {
    font-size: 11px;
  }
  .form-row-3 { grid-template-columns: 1fr; }
  .navbar-search { display: none; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-title { font-size: 16px; }
  .kpi-card {
    padding: 12px;
    min-height: 124px;
  }
  .kpi-label {
    font-size: 11px;
    padding-right: 46px;
  }
  .kpi-value {
    font-size: 20px;
    padding-right: 46px;
  }
  .kpi-sub {
    font-size: 11px;
  }
  .kpi-blob {
    width: 40px;
    height: 40px;
    font-size: 18px;
    top: 10px;
    right: 10px;
  }
  .main-content { padding: 10px; padding-bottom: 72px; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .navbar, .sidebar, .page-actions, .btn, .table-toolbar,
  .topnav-bar, .breadcrumb-bar, .owner-bottom-nav, .sidebar-overlay,
  .view-popup-overlay, .modal-overlay, .navbar-hamburger, .navbar-more-btn
    { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  body { font-size: 12px; }
}

/* ============================================================
   PAGE SUBTITLE
   ============================================================ */
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ============================================================
   CARD BODY (explicit padding variant)
   ============================================================ */
.card-body {
  padding: 20px;
}

/* ============================================================
   TABLE RESPONSIVE WRAPPER
   ============================================================ */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Alias: some pages use <table class="table"> */
table.table {
  width: 100%;
  border-collapse: collapse;
}

/* ============================================================
   TABLE SORTING
   ============================================================ */
thead th.sortable {
  cursor: pointer;
  user-select: none;
}

thead th.sortable:hover { color: var(--primary); }

.sort-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  opacity: .4;
  vertical-align: middle;
}

thead th.sort-asc  .sort-icon { opacity: 1; color: var(--secondary); }
thead th.sort-desc .sort-icon { opacity: 1; color: var(--secondary); }

/* ============================================================
   FROZEN ROW NUMBER COLUMN
   ============================================================ */
.th-num {
  position: sticky;
  left: 0;
  background: #f8fafc;
  z-index: 3;
}

.td-num {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
}

tbody tr:hover .td-num {
  background: #f8fafc;
}

/* ============================================================
   EXTRA COMPONENTS
   ============================================================ */
.info-row {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.info-row:last-child { border-bottom: none; }
.info-label { width: 140px; color: var(--text-muted); font-size: 13px; flex-shrink: 0; }
.info-value { flex: 1; font-size: 14px; color: var(--text); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-muted);
}

/* File upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upload-zone:hover { border-color: var(--primary); background: rgba(30,58,95,.02); }
.upload-zone.drag-over { border-color: var(--secondary); background: rgba(249,115,22,.04); }
.upload-zone-icon { font-size: 32px; margin-bottom: 8px; }
.upload-zone-text { font-size: 14px; color: var(--text-muted); }

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e8edf4 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease infinite;
  border-radius: 4px;
}
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================================
   LOGO — Gold Shine Effect
   ============================================================ */
.navbar-brand .logo-icon img,
.login-left-logo img,
.login-card-logo img {
  display: block;
}

/* ============================================================
   VIEW POPUP — iframe modal for 👁️ view buttons
   ============================================================ */
.view-popup-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 600;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.view-popup-overlay.active { display: flex; }
.view-popup-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 100%;
  max-width: 920px;
  height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.view-popup-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.view-popup-head-title { flex: 1; font-size: 15px; font-weight: 600; }
.view-popup-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: none; border: none;
  font-size: 18px; line-height: 1;
  cursor: pointer; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.view-popup-close:hover { background: var(--border); color: var(--text); }
.view-popup-frame { flex: 1; overflow: hidden; min-height: 0; }
.view-popup-frame iframe { width: 100%; height: 100%; border: none; display: block; }

/* Embed content — page loaded inside popup iframe (no sidebar/navbar) */
.embed-content { padding: 20px; background: var(--bg); min-height: 100vh; }


