/* ===== BASE ===== */
* { box-sizing: border-box; }

body {
  font-family: 'Sarabun', sans-serif;
  background: #f0f2f5;
  color: #333;
}

/* ===== NAVBAR ===== */
.navbar-brand {
  font-size: 1.2rem;
  font-weight: 700;
}

/* ===== CARDS ===== */
.stat-card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .card-body { padding: 1.5rem; }
.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
}
.stat-card .stat-label {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-top: 4px;
}
.stat-card .stat-icon {
  font-size: 2rem;
  opacity: 0.3;
}

/* ===== LOAN CARDS ===== */
.loan-card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
}
.loan-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}
.loan-card .card-header {
  border-radius: 12px 12px 0 0 !important;
  border-bottom: none;
  padding: 1rem 1.25rem 0.5rem;
  background: transparent;
}

/* ===== STATUS BADGES ===== */
.badge-status {
  font-size: 0.8rem;
  padding: 0.4em 0.9em;
  border-radius: 20px;
  font-weight: 600;
}
.badge-active { background: #e8f5e9; color: #2e7d32; }
.badge-paid { background: #e3f2fd; color: #1565c0; }
.badge-overdue { background: #ffebee; color: #c62828; }
.badge-partial { background: #fff3e0; color: #e65100; }

.btn-toggle-status {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 20px;
  padding: 0.35em 1em;
}

/* ===== PROGRESS ===== */
.progress {
  height: 8px;
  border-radius: 4px;
}

/* ===== TABLES ===== */
.table-responsive {
  overflow: visible;
}
.table-hover tbody tr:hover {
  background: #f8f9ff;
}
.table th {
  font-weight: 600;
  font-size: 0.875rem;
  color: #666;
  border-bottom: 2px solid #e9ecef;
}

/* ===== FORMS ===== */
.form-section {
  background: #fff;
  border-radius: 12px;
  padding: 0;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border-left: 4px solid #dee2e6;
  overflow: hidden;
}
.form-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: #495057;
  margin: 0;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f8f9fa;
}
.form-section-body {
  padding: 1.25rem;
}
/* Settings cards: no .form-section-body, need inner padding */
.form-section > div[id$="-list"],
.form-section > form,
.form-section > hr {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}
.form-section > form { padding-bottom: 1.25rem; }
.form-section > hr { margin: 0.5rem 1.25rem; }
.form-section > div[id$="-list"] { padding-top: 0.5rem; }

/* Section colors */
.form-section.section-location  { border-left-color: #dc3545; }
.form-section.section-location .form-section-title { background: #fff5f5; color: #c0392b; }

.form-section.section-borrower  { border-left-color: #0d6efd; }
.form-section.section-borrower .form-section-title { background: #f0f4ff; color: #1a56db; }

.form-section.section-lender    { border-left-color: #198754; }
.form-section.section-lender .form-section-title { background: #f0faf4; color: #157347; }

.form-section.section-loan      { border-left-color: #f59e0b; }
.form-section.section-loan .form-section-title { background: #fffbeb; color: #b45309; }

.form-section.section-payment   { border-left-color: #0dcaf0; }
.form-section.section-payment .form-section-title { background: #f0fcff; color: #0a8fa8; }

.form-section.section-guarantor { border-left-color: #8b5cf6; }
.form-section.section-guarantor .form-section-title { background: #f5f3ff; color: #6d28d9; }

.form-section.section-notes     { border-left-color: #f97316; }
.form-section.section-notes .form-section-title { background: #fff7ed; color: #c2410c; }

/* Picker dropdown */
.form-section .picker-row {
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  padding: 0.6rem 1.25rem;
}
.form-section .picker-row select {
  background: #fff;
  font-size: 0.875rem;
}

/* Calculation preview */
.calc-preview {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #fff;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
}
.calc-preview .calc-label { font-size: 0.8rem; opacity: 0.7; }
.calc-preview .calc-value { font-size: 1.35rem; font-weight: 700; }
.calc-preview .calc-value.text-warning { color: #fbbf24 !important; }
.calc-preview .calc-value.text-danger { color: #f87171 !important; }

.form-label { font-weight: 600; font-size: 0.85rem; color: #555; }
.form-control, .form-select {
  border-radius: 8px;
  border-color: #dee2e6;
  font-size: 0.925rem;
}
.form-control:focus, .form-select:focus {
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}

/* ===== DETAIL PAGE ===== */
.detail-card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  margin-bottom: 1.5rem;
}
.detail-card .card-header {
  background: #fff;
  border-bottom: 2px solid #f0f2f5;
  font-weight: 700;
  border-radius: 12px 12px 0 0 !important;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
}
.info-row {
  display: flex;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f0f2f5;
  font-size: 0.925rem;
}
.info-row:last-child { border-bottom: none; }
.info-label {
  min-width: 180px;
  color: #888;
  font-size: 0.875rem;
}
.info-value { font-weight: 500; }

/* ===== ALERTS ===== */
.alert-overdue {
  background: #ffebee;
  border-left: 4px solid #ef5350;
  color: #b71c1c;
}

/* ===== BUTTONS ===== */
.btn-action {
  border-radius: 8px;
  font-weight: 500;
  padding: 0.5rem 1.25rem;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #adb5bd;
}
.empty-state i {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

/* ===== SEARCH BAR ===== */
.search-bar {
  background: #fff;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 1.5rem;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #212529;
  margin: 0;
}

/* ===== BREADCRUMB ===== */
.breadcrumb { margin-bottom: 0.5rem; }
.breadcrumb-item a { text-decoration: none; color: #6c757d; }
.breadcrumb-item a:hover { color: #0d6efd; }

/* ===== MODAL ===== */
.modal-header { border-bottom: 2px solid #f0f2f5; }
.modal-footer { border-top: 2px solid #f0f2f5; }
.modal-content { border-radius: 12px; border: none; }

/* ===== INTEREST METER ===== */
.interest-meter {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* ===== TIMELINE ===== */
.payment-timeline .payment-item {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f0f2f5;
}
.payment-timeline .payment-item:last-child { border-bottom: none; }
.payment-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .info-label { min-width: 130px; }
  .stat-card .stat-value { font-size: 1.4rem; }

  /* === ฟอร์มกู้ยืม - Mobile responsive === */

  /* ลด padding ให้พอดีจอมือถือ */
  .form-section-body { padding: 0.75rem; }
  .form-section .picker-row { padding: 0.5rem 0.75rem; }

  /* Section title: ข้อความ + checkbox ซ้อนแนวตั้งบนจอเล็ก */
  .form-section-title {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.4rem;
    padding: 0.65rem 0.75rem;
    font-size: 0.9rem;
  }
  .form-section-title .form-check { margin-left: auto; }

  /* Input field ใหญ่ขึ้นสำหรับสัมผัส */
  .form-control, .form-select {
    font-size: 16px !important;  /* ป้องกัน iOS zoom เมื่อ focus */
    padding: 0.5rem 0.65rem;
    min-height: 44px;            /* ขนาดขั้นต่ำสำหรับสัมผัส */
  }

  /* Label เล็กลงเล็กน้อย */
  .form-label {
    font-size: 0.8rem;
    margin-bottom: 0.2rem;
  }

  /* Row gap เล็กลงบนมือถือ */
  .form-section-body .row.g-3 { --bs-gutter-y: 0.5rem; --bs-gutter-x: 0.5rem; }

  /* Calculation preview บนมือถือ */
  .calc-preview { padding: 0.75rem; margin-top: 0.75rem; }
  .calc-preview .calc-value { font-size: 1.1rem; }
  .calc-preview .calc-label { font-size: 0.7rem; }
  .calc-preview .row .col-3 { flex: 0 0 33.333%; max-width: 33.333%; }

  /* ปุ่ม Submit เต็มความกว้าง */
  #loan-form > .d-flex.gap-3 {
    flex-direction: column;
    gap: 0.5rem !important;
  }
  #loan-form > .d-flex.gap-3 .btn {
    width: 100%;
    padding: 0.65rem;
    font-size: 1rem;
  }

  /* Breadcrumb เล็กลง */
  .breadcrumb { font-size: 0.8rem; }
  .page-title { font-size: 1.3rem; }
}

/* ===== ID CARD PREVIEW ===== */
.idcard-preview { min-height: 0; }
.idcard-thumb {
  height: 48px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #dee2e6;
  object-fit: cover;
  transition: transform 0.15s;
}
.idcard-thumb:hover {
  transform: scale(1.5);
  z-index: 10;
  position: relative;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.idcard-file-link {
  font-size: 0.75rem;
  text-decoration: none;
}
.idcard-item {
  position: relative;
}

/* ===== DROPDOWN SUBMENU ===== */
.dropdown-submenu {
  position: relative;
}
.dropdown-submenu > .dropdown-item {
  cursor: default;
}
.dropdown-submenu-menu {
  display: none;
  position: absolute;
  right: 100%;
  left: auto;
  top: 0;
  min-width: 160px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border-radius: 6px;
  z-index: 1060;
}
.dropdown-submenu:hover > .dropdown-submenu-menu {
  display: block;
}

/* ====================================================
   PRINT STYLES - เอกสารกฎหมายมาตรฐาน (Thai Legal Form)
   ==================================================== */
@media print {
  body > *:not(#contract-print-area) { display: none !important; }
  #lock-screen, #session-timer, #docx-pdf-render, #pdf-loading-overlay { display: none !important; }
  #contract-print-area {
    display: block !important;
    position: static !important;
    width: 100% !important;
  }
  .contract-page { padding: 0 !important; }
}

#contract-print-area {
  display: none;
}

#docx-pdf-render {
  display: none;
}
#pdf-loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.9);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  font-family: 'Sarabun', sans-serif;
  font-size: 1.1rem;
  color: #333;
}


/* ===== Page layout ===== */
.contract-page {
  font-family: 'TH Sarabun New', 'Sarabun', serif;
  font-size: 16pt;
  line-height: 1.5;
  color: #000;
  background: #fff;
  padding: 2.54cm 2.54cm 2.54cm 3.18cm; /* Word Normal margins */
  max-width: 21cm;
  margin: 0 auto;
}

/* ===== Title ===== */
.contract-title {
  text-align: center;
  font-size: 20pt;
  font-weight: bold;
  margin-bottom: 6pt;
}

/* ===== Header info (location + date) ===== */
.contract-location {
  text-align: right;
  margin-bottom: 0;
}

.contract-date {
  text-align: right;
  margin-bottom: 12pt;
}

/* ===== Body text ===== */
.contract-body {
  text-align: justify;
  margin-bottom: 6pt;
}

/* ===== Article/clause (inline format) ===== */
.contract-article {
  font-weight: bold;
  text-align: center;
  margin-top: 12pt;
  margin-bottom: 3pt;
}

.contract-article-body {
  text-align: justify;
  margin-bottom: 6pt;
}

/* ===== Indent ===== */
.contract-indent {
  text-indent: 1.27cm; /* Word standard 0.5 inch */
}

.contract-bullet {
  margin-left: 1.27cm;
}

/* ===== Fill-in value style ===== */
.v {
  border-bottom: 1px dotted #000;
  padding: 0 2px;
}

/* ===== Dotted leader for signatures ===== */
.dots::before {
  content: '....................................................';
  letter-spacing: 2px;
}
.dots-short::before {
  content: '................................';
  letter-spacing: 2px;
}

/* ===== Signature area ===== */
.contract-signatures {
  margin-top: 1.5cm;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1cm 0;
  page-break-inside: avoid;
}

.signature-block {
  text-align: center;
  padding: 0 0.5cm;
}

.signature-line {
  border-bottom: 1px dotted #000;
  margin: 1cm 0.5cm 3pt;
}

.signature-name {
  font-size: 15pt;
}

.signature-role {
  font-size: 14pt;
}

/* ===== Table in documents ===== */
.contract-page table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15pt;
  margin: 12pt 0;
}
.contract-page table td,
.contract-page table th {
  padding: 4pt 8pt;
  border: 1px solid #000;
  vertical-align: top;
}
.contract-page table .label-col {
  width: 40%;
  background: #f2f2f2;
  font-weight: bold;
}

/* ===== Legacy compat (old templates) ===== */
.contract-preview-wrapper {
  background: #f5f5f5;
  padding: 2rem;
  min-height: 400px;
  border-radius: 8px;
}
.contract-preview-inner {
  background: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 2.54cm;
  font-family: 'TH Sarabun New', 'Sarabun', serif;
  font-size: 13pt;
  line-height: 1.5;
  color: #000;
}

/* ===== LOGIN SCREEN ===== */
#login-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: linear-gradient(135deg, #1e3a5f 0%, #2d5986 50%, #1a365d 100%);
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
#login-screen.active {
  display: flex;
}
.login-error {
  color: #dc3545;
  font-size: 0.85rem;
  min-height: 1.25rem;
  margin-bottom: 0.5rem;
}
.lock-box {
  background: rgba(255,255,255,0.95);
  border-radius: 20px;
  padding: 3rem 2.5rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  min-width: 320px;
  max-width: 400px;
}
.lock-icon {
  font-size: 3rem;
  color: #1e3a5f;
  margin-bottom: 1rem;
}
.lock-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1e3a5f;
  margin-bottom: 0.25rem;
}
.lock-subtitle {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 1.5rem;
}
.lock-input-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}
.lock-input {
  width: 80px;
  height: 80px;
  text-align: center;
  font-size: 2.5rem;
  font-weight: 700;
  border: 3px solid #dee2e6;
  border-radius: 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-text-security: disc;
}
.lock-input:focus {
  border-color: #1e3a5f;
  box-shadow: 0 0 0 4px rgba(30,58,95,0.2);
}
.lock-input.shake {
  animation: shake 0.5s;
  border-color: #dc3545;
}
.lock-input.success {
  border-color: #198754;
  box-shadow: 0 0 0 4px rgba(25,135,84,0.2);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}
.lock-error {
  color: #dc3545;
  font-size: 0.85rem;
  min-height: 1.25rem;
}
.lock-setup small {
  color: #888;
}

/* Session Timer */
#session-timer {
  position: fixed;
  top: 8px;
  right: 16px;
  z-index: 1100;
  background: rgba(30,58,95,0.9);
  color: #fff;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s;
}
#session-timer:hover {
  background: rgba(30,58,95,1);
}
#session-timer.warning {
  background: rgba(220,53,69,0.9);
}

/* ===== LENDER VIEW SECRET COLUMNS ===== */
.lv-secret { filter: blur(6px); user-select: none; transition: filter 0.3s; }
.lv-secret.revealed { filter: none; user-select: auto; }
.lv-pin-overlay {
  display: inline-flex; align-items: center; gap: 6px;
}
.lv-pin-overlay input {
  width: 120px; letter-spacing: 8px; text-align: center; font-size: 1.1rem;
}

/* ===== SETTINGS PAGE - Tab Layout ===== */
.settings-layout {
  display: flex;
  gap: 1.25rem;
  min-height: 600px;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
  flex-shrink: 0;
  background: #fff;
  border-radius: 12px;
  padding: 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  height: fit-content;
  position: sticky;
  top: 80px;
}
.settings-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
}
.settings-nav-btn:hover {
  background: #f0f2f5;
  color: #333;
}
.settings-nav-btn.active {
  background: #e8f0fe;
  color: #1a56db;
  font-weight: 600;
}
.settings-nav-btn i { width: 18px; text-align: center; font-size: 0.9rem; }
.settings-nav-label { flex-grow: 1; }
.settings-nav-count {
  background: #e9ecef;
  color: #666;
  font-size: 0.7rem;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.settings-nav-btn.active .settings-nav-count {
  background: #c6d9f7;
  color: #1a56db;
}
.settings-content { flex-grow: 1; min-width: 0; }
.settings-panel { display: none; }
.settings-panel.active { display: block; }

.settings-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #fff;
  border-radius: 12px;
  padding: 1rem 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 1rem;
}
.settings-panel-header h5 { font-weight: 700; }
.settings-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f0f2f5;
  border-radius: 8px;
  padding: 0.4rem 0.85rem;
  min-width: 220px;
}
.settings-search i { color: #888; font-size: 0.8rem; }
.settings-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.85rem;
  width: 100%;
  font-family: inherit;
}
.settings-panel-body {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* รายการข้อมูล */
.settings-item-list {
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}
.settings-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid #f0f2f5;
  border-radius: 8px;
  transition: background 0.15s;
}
.settings-item:hover { background: #f8f9ff; }
.settings-item:last-child { border-bottom: none; }
.settings-item-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  min-width: 0;
}
.settings-item-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}
.settings-item-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.settings-item-detail {
  font-size: 0.78rem;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.settings-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.settings-item-actions .btn { padding: 0.2rem 0.45rem; font-size: 0.75rem; }

/* ฟอร์มเพิ่ม/แก้ไข */
.settings-form-card {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 10px;
  padding: 1.25rem;
  position: sticky;
  top: 80px;
}
.settings-form-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e9ecef;
}

/* Empty state */
.settings-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: #adb5bd;
}
.settings-empty i { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; opacity: 0.5; }
.settings-empty p { margin: 0; font-size: 0.9rem; }

/* Sub-sections ใน tab เอกสาร/ระบบ */
.settings-sub-section {
  padding: 1.25rem 0;
  border-bottom: 1px solid #f0f2f5;
}
.settings-sub-section:first-child { padding-top: 0; }
.settings-sub-section:last-child { border-bottom: none; padding-bottom: 0; }
.settings-sub-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #444;
  margin-bottom: 0.85rem;
}

/* Responsive - mobile: tab อยู่ด้านบน */
@media (max-width: 991px) {
  .settings-layout { flex-direction: column; }
  .settings-nav {
    flex-direction: row;
    overflow-x: auto;
    min-width: unset;
    position: static;
    gap: 2px;
    padding: 0.5rem;
  }
  .settings-nav-btn {
    white-space: nowrap;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }
  .settings-nav-label { display: none; }
  .settings-nav-btn i { width: auto; }
  .settings-nav-count { display: none; }
  .settings-panel-header { flex-direction: column; align-items: stretch; }
  .settings-search { min-width: unset; }
  .settings-form-card { position: static; }
}

/* ===== MOBILE PREVIEW MODE ===== */
/* โหมดจำลองหน้าจอมือถือบน desktop */
body.mobile-preview-active #app {
  max-width: 390px;
  margin: 0 auto;
  box-shadow: 0 0 40px rgba(0,0,0,0.2);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}
body.mobile-preview-active {
  background: #1a1a2e;
}
/* บังคับ responsive เหมือนจอเล็ก */
body.mobile-preview-active .navbar { flex-wrap: wrap; }
body.mobile-preview-active .navbar > .container-fluid { flex-wrap: wrap; }
body.mobile-preview-active .navbar-collapse {
  display: none !important;
  flex-basis: 100%;
  width: 100%;
}
body.mobile-preview-active .navbar-collapse.show {
  display: block !important;
}
body.mobile-preview-active .navbar-toggler { display: block !important; }
body.mobile-preview-active .navbar-nav {
  flex-direction: column;
  width: 100%;
}
body.mobile-preview-active .navbar-nav .nav-link {
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.mobile-preview-active .navbar-nav.ms-auto {
  margin-left: 0 !important;
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 0.5rem;
  margin-top: 0.5rem;
}
body.mobile-preview-active .navbar-nav .btn-light {
  display: block;
  text-align: left;
  margin: 0 !important;
  border-radius: 4px;
}

/* Nav action items - Desktop: ซ่อนข้อความ แสดงแค่ icon */
.nav-action-label { display: none; }

/* Nav action items - Mobile: แสดงข้อความ + เรียงเป็นแถวแนวนอน */
@media (max-width: 991px) {
  .nav-action-label { display: inline; }
  .nav-bottom-section .nav-action-item {
    display: inline-flex;
  }
  /* จัดปุ่ม action เป็นแถวเดียว */
  .nav-bottom-section {
    flex-wrap: wrap;
  }
  .nav-bottom-section .nav-action-item {
    flex: none;
  }
  .nav-bottom-section .nav-action-item .nav-link {
    font-size: 0.8rem !important;
    opacity: 0.85;
  }
}
/* mobile-preview mode */
body.mobile-preview-active .nav-action-label { display: inline; }
body.mobile-preview-active .nav-bottom-section .nav-action-item .nav-link {
  font-size: 0.8rem !important;
  opacity: 0.85;
}
body.mobile-preview-active .container-fluid { padding-left: 0.5rem; padding-right: 0.5rem; }
/* ป้องกัน content ล้น */
body.mobile-preview-active #main-content {
  overflow-x: hidden;
  word-wrap: break-word;
}
/* ตารางเลื่อนได้ในกรอบ */
body.mobile-preview-active .table-responsive {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  max-width: calc(390px - 1rem);
}
body.mobile-preview-active table { font-size: 0.75rem; }
/* card / form ไม่ให้ล้น */
body.mobile-preview-active .card,
body.mobile-preview-active .form-section,
body.mobile-preview-active form {
  overflow-x: hidden;
}
/* row ไม่ให้ล้น */
body.mobile-preview-active .row {
  margin-left: 0;
  margin-right: 0;
}
body.mobile-preview-active .page-header {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

/* บังคับ col-md ให้เป็น 100% ในโหมด preview */
body.mobile-preview-active [class*="col-md-"] {
  flex: 0 0 100% !important;
  max-width: 100% !important;
}
/* col-md-6 ให้เป็น 50% (2 คอลัมน์) */
body.mobile-preview-active .col-md-6 {
  flex: 0 0 50% !important;
  max-width: 50% !important;
}

/* เอา mobile styles มาใช้ในโหมด preview */
body.mobile-preview-active .form-section-body { padding: 0.75rem; }
body.mobile-preview-active .form-section .picker-row { padding: 0.5rem 0.75rem; }
body.mobile-preview-active .form-section-title {
  flex-direction: column;
  align-items: flex-start !important;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem;
  font-size: 0.9rem;
}
body.mobile-preview-active .form-control,
body.mobile-preview-active .form-select {
  font-size: 16px !important;
  padding: 0.5rem 0.65rem;
  min-height: 44px;
}
body.mobile-preview-active .form-label {
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
}
body.mobile-preview-active .form-section-body .row.g-3 {
  --bs-gutter-y: 0.5rem;
  --bs-gutter-x: 0.5rem;
}
body.mobile-preview-active .calc-preview { padding: 0.75rem; }
body.mobile-preview-active .calc-preview .calc-value { font-size: 1.1rem; }
body.mobile-preview-active .calc-preview .calc-label { font-size: 0.7rem; }
body.mobile-preview-active #loan-form > .d-flex.gap-3 {
  flex-direction: column;
  gap: 0.5rem !important;
}
body.mobile-preview-active #loan-form > .d-flex.gap-3 .btn {
  width: 100%;
  padding: 0.65rem;
  font-size: 1rem;
}
body.mobile-preview-active .breadcrumb { font-size: 0.8rem; }
body.mobile-preview-active .page-title { font-size: 1.3rem; }

/* ===== MOBILE LOAN CARDS (ซ่อนปกติ, แสดงเฉพาะมือถือ) ===== */
.dash-mobile-cards { display: none; }
.dash-desktop-table { display: block; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { background: #f0f2f5; }

/* Dashboard filters */
.dash-filters {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.dash-filter-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 140px;
}
.dash-filter-label {
  font-size: 0.8rem;
  color: #888;
  white-space: nowrap;
}
.dash-filter-row .form-select,
.dash-filter-row .form-control {
  flex: 1;
}
@media (max-width: 576px) {
  .dash-filters {
    flex-direction: column;
    gap: 0.4rem;
  }
  .dash-filter-row {
    width: 100%;
  }
}

/* Mobile loan card style */
.mobile-loan-card {
  background: #fff;
  border-bottom: 1px solid #f0f2f5;
  padding: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}
.mobile-loan-card:active { background: #f8f9fa; }
.mobile-loan-card:last-child { border-bottom: none; }

.mlc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}
.mlc-header-left { flex: 1; min-width: 0; }
.mlc-date-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  font-size: 0.72rem;
  color: #888;
  margin-top: 0.2rem;
}
.mlc-date-inline i { margin-right: 0.2rem; }
.mlc-contract {
  font-size: 0.78rem;
  color: #555;
  font-weight: 600;
  background: #f0f2f5;
  border: 1px solid #dde1e6;
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  letter-spacing: 0.02em;
}
.mlc-renewed-link {
  color: #17a2b8;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.72rem;
}
.mlc-renewed-link:hover { text-decoration: underline; }
.mlc-header .btn { font-size: 0.7rem; padding: 0.2rem 0.5rem; }

.mlc-people {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.15rem;
}
.mlc-person { white-space: nowrap; }

.mlc-money {
  display: flex;
  gap: 0.5rem;
  background: #f8f9fa;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.5rem;
}
.mlc-money-item { flex: 1; text-align: center; }
.mlc-money-label { font-size: 0.65rem; color: #999; text-transform: uppercase; }
.mlc-money-value { font-size: 0.85rem; font-weight: 700; }

.mlc-date-section {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-radius: 10px;
  margin: 0.5rem 0.75rem;
  padding: 0.6rem 0.75rem;
}
.mlc-date-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.mlc-date-row + .mlc-date-row {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(0,0,0,0.06);
}
.mlc-date-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: #555;
}
.mlc-date-item i {
  color: #667eea;
  font-size: 0.7rem;
}
.mlc-days {
  background: #e8f0fe;
  color: #1a56db;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.72rem;
  white-space: nowrap;
}
.mlc-remain-badge {
  background: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.72rem;
  border: 1.5px solid #e9ecef;
  white-space: nowrap;
}

.mlc-actions {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid #f0f2f5;
  font-size: 0.85rem;
}
.mlc-actions .btn { font-size: 0.7rem; padding: 0.2rem 0.4rem; }
.mlc-action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.mlc-action-label {
  font-size: 0.6rem;
  color: #999;
  white-space: nowrap;
  line-height: 1;
}

/* ===== Loan Detail Hero (redesign) ===== */
.ld-hero {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.ld-hero-top { margin-bottom: 0.75rem; }
.ld-hero-contract {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.ld-contract-badge {
  font-size: 0.82rem;
  font-weight: 700;
  color: #444;
  background: #eef1f5;
  border: 1px solid #dde1e6;
  border-radius: 5px;
  padding: 0.2rem 0.6rem;
  letter-spacing: 0.02em;
}
.ld-renewed-from {
  font-size: 0.75rem;
  color: #17a2b8;
  margin-top: 0.2rem;
}
.ld-hero-people {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f0f2f5;
}
.ld-person { white-space: nowrap; }
.ld-hero-summary {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  text-align: center;
}
.ld-sum-item { flex: 1; min-width: 0; }
.ld-sum-label { font-size: 0.7rem; color: #888; margin-bottom: 0.15rem; }
.ld-sum-value { font-size: 1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ld-sum-sub { font-size: 0.65rem; color: #aaa; }
.ld-hero-balance {
  background: #fff8f0;
  border: 1px solid #ffe0b2;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
}
.ld-hero-balance.paid {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.ld-balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
}
.ld-balance-amount { font-size: 1.1rem; color: #dc3545; font-weight: 700; }
.ld-hero-balance.paid .ld-balance-amount { color: #198754; }
.ld-balance-sub { font-size: 0.68rem; color: #999; margin-top: 0.3rem; }
.ld-hero-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.ld-hero-actions .btn { font-size: 0.78rem; }

@media (min-width: 768px) {
  .ld-sum-value { font-size: 1.25rem; }
  .ld-hero { padding: 1.5rem; }
}

/* ===== Loan Detail Sections ===== */
.ld-section {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 1rem;
  overflow: hidden;
}
.ld-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
  user-select: none;
}
.ld-section-header:hover { background: #fafbfc; }
.ld-chevron { font-size: 0.7rem; color: #aaa; transition: transform 0.2s; }
.ld-section.collapsed .ld-chevron { transform: rotate(-90deg); }
.ld-section.collapsed .ld-section-body { display: none; }
.ld-section-body { padding: 0.75rem 1rem; }
.ld-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
}
.ld-info-item { display: flex; flex-direction: column; }
.ld-info-label { font-size: 0.7rem; color: #999; }
.ld-info-value { font-size: 0.85rem; font-weight: 500; }
.ld-person-card {
  padding: 0.6rem 0;
  border-bottom: 1px solid #f5f5f5;
}
.ld-person-card:last-child { border-bottom: none; }
.ld-person-header {
  display: flex;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #666;
  margin-bottom: 0.25rem;
}
.ld-person-name { font-size: 0.95rem; font-weight: 600; }
.ld-person-detail { font-size: 0.8rem; color: #777; }

@media (max-width: 576px) {
  .ld-info-grid { grid-template-columns: 1fr 1fr; gap: 0.4rem 0.75rem; }
}

/* ===== Trash cards ===== */
.trash-list { max-width: 600px; }
.trash-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
}
.trash-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.trash-card-people {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}
.trash-card-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #f0f2f5;
}
.trash-card-actions {
  display: flex;
  gap: 0.4rem;
}

/* Print dropdown ในการ์ดมือถือ — บังคับอยู่ในจอ */
.mlc-print-dropdown {
  position: fixed !important;
  right: 0.5rem !important;
  left: auto !important;
  bottom: auto !important;
  transform: none !important;
  max-width: calc(100vw - 1rem);
  z-index: 1060;
}

/* Lender view mobile cards (ซ่อนปกติ) */
.lv-mobile-cards { display: none; }
.lv-desktop-table { display: block; }
.lv-mobile-cards .mobile-loan-card {
  background: #fff;
  border-radius: 10px;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  padding: 0.85rem;
}

/* แสดง card view บนมือถือจริง */
@media (max-width: 768px) {
  .dash-mobile-cards { display: block; }
  .dash-desktop-table { display: none; }
  .lv-mobile-cards { display: block; }
  .lv-desktop-table { display: none; }
}

/* แสดง card view ในโหมด preview */
body.mobile-preview-active .dash-mobile-cards { display: block; }
body.mobile-preview-active .dash-desktop-table { display: none; }
body.mobile-preview-active .lv-mobile-cards { display: block; }
body.mobile-preview-active .lv-desktop-table { display: none; }

/* ปุ่ม preview active state */
#btn-mobile-preview.active {
  background: rgba(255,255,255,0.2) !important;
  border-radius: 6px;
}

/* === Settings layout ในโหมด mobile preview === */
body.mobile-preview-active .settings-layout { flex-direction: column; }
body.mobile-preview-active .settings-nav {
  flex-direction: row;
  overflow-x: auto;
  min-width: unset;
  position: static;
  gap: 2px;
  padding: 0.5rem;
}
body.mobile-preview-active .settings-nav-btn {
  white-space: nowrap;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
}
body.mobile-preview-active .settings-nav-label { display: none; }
body.mobile-preview-active .settings-nav-btn i { width: auto; }
body.mobile-preview-active .settings-nav-count { display: none; }
body.mobile-preview-active .settings-panel-header { flex-direction: column; align-items: stretch; }
body.mobile-preview-active .settings-search { min-width: unset; }
body.mobile-preview-active .settings-form-card { position: static; }

/* === ทุกหน้า: col-lg, col-xl ให้เป็น 100% ในโหมด preview === */
body.mobile-preview-active [class*="col-lg-"],
body.mobile-preview-active [class*="col-xl-"] {
  flex: 0 0 100% !important;
  max-width: 100% !important;
}

/* === Dashboard / stat cards ในโหมด preview === */
body.mobile-preview-active .stat-card .stat-value { font-size: 1.2rem; }
body.mobile-preview-active .stat-card .card-body { padding: 1rem; }
body.mobile-preview-active .stat-card .stat-icon { font-size: 1.5rem; }

/* === ปุ่ม action ในโหมด preview === */
body.mobile-preview-active .btn-action { font-size: 0.85rem; padding: 0.4rem 0.75rem; }

/* === Loan cards ในโหมด preview === */
body.mobile-preview-active .loan-card .card-header { padding: 0.75rem; }
body.mobile-preview-active .loan-card .card-body { padding: 0.75rem; }

/* ===== MEMBERS PAGE ===== */

/* Desktop: แสดง table, ซ่อน cards */
.members-desktop-table { display: block; }
.members-mobile-cards { display: none; }

/* Mobile: ซ่อน table, แสดง cards */
@media (max-width: 768px) {
  .members-desktop-table { display: none !important; }
  .members-mobile-cards { display: block !important; }
}
body.mobile-preview-active .members-desktop-table { display: none !important; }
body.mobile-preview-active .members-mobile-cards { display: block !important; }

/* Member stat cards - สรุปจำนวนสมาชิก */
.members-stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.members-stat-card {
  border-radius: 12px;
  padding: 1rem 1.25rem;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.members-stat-card .stat-num {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
}
.members-stat-card .stat-txt {
  font-size: 0.75rem;
  opacity: 0.9;
}
.members-stat-card .stat-ico {
  font-size: 1.6rem;
  opacity: 0.6;
}

/* Member card - การ์ดแต่ละคน */
.member-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  margin-bottom: 0.75rem;
  overflow: hidden;
  border: 1px solid #f0f2f5;
}
.member-card-header {
  display: flex;
  align-items: center;
  padding: 1rem 1rem 0.5rem;
  gap: 0.75rem;
}
.member-card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.member-card-info {
  flex: 1;
  min-width: 0;
}
.member-card-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1a1a2e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-card-user {
  font-size: 0.8rem;
  color: #6c757d;
}
.member-card-btns {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}
.member-card-btns .btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}
.member-card-body {
  padding: 0.5rem 1rem 1rem;
}
.member-card-role {
  padding: 0 1rem;
  margin-bottom: 0.5rem;
}
.member-card-perms {
  padding: 0.75rem 1rem;
  background: #f8f9fa;
  border-top: 1px solid #f0f2f5;
}
.member-card-perms-label {
  font-size: 0.7rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.35rem;
  font-weight: 600;
}
.member-card-perms .badge {
  font-size: 0.7rem !important;
  font-weight: 500;
  padding: 0.3em 0.6em;
  border-radius: 6px;
}

/* ===== ACCOUNTING PAGE - Mobile ===== */

/* Desktop: แสดง table, ซ่อน cards */
.acc-desktop-table { display: block; }
.acc-mobile-cards { display: none; }

@media (max-width: 768px) {
  .acc-desktop-table { display: none !important; }
  .acc-mobile-cards { display: block !important; }
}
body.mobile-preview-active .acc-desktop-table { display: none !important; }
body.mobile-preview-active .acc-mobile-cards { display: block !important; }
body.desktop-preview-active .acc-desktop-table { display: block !important; }
body.desktop-preview-active .acc-mobile-cards { display: none !important; }

/* Accounting card */
.acc-mobile-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  margin-bottom: 0.75rem;
  overflow: hidden;
  border: 1px solid #f0f2f5;
}
.acc-mobile-card.acc-card-unchecked {
  opacity: 0.5;
}
.acc-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f0f2f5;
}
.acc-card-body {
  padding: 0.5rem 1rem 0.75rem;
}
.acc-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  font-size: 0.82rem;
  border-bottom: 1px solid #f8f9fa;
}
.acc-card-row:last-child {
  border-bottom: none;
}
.acc-card-label {
  color: #6c757d;
  font-size: 0.78rem;
}

/* Accounting summary card */
.acc-mobile-summary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 12px;
  padding: 1rem;
  color: #fff;
  margin-top: 0.5rem;
}
.acc-summary-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}
.acc-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  font-size: 0.85rem;
}
.acc-summary-row .text-info { color: #a5d8ff !important; }
.acc-summary-row .text-primary { color: #bac8ff !important; }
.acc-summary-row .text-danger { color: #ffc9c9 !important; }

/* ===== ADMIN PAGE ===== */

/* Desktop: แสดง table, ซ่อน mobile cards */
.admin-desktop-table { display: block; }
.admin-mobile-cards { display: none; }

@media (max-width: 768px) {
  .admin-desktop-table { display: none !important; }
  .admin-mobile-cards { display: block !important; }
}
body.mobile-preview-active .admin-desktop-table { display: none !important; }
body.mobile-preview-active .admin-mobile-cards { display: block !important; }

.admin-mobile-cards .card-header-mobile {
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.75rem 0;
  margin-bottom: 0.5rem;
}
.member-card-body-row {
  padding: 0 1rem 0.5rem;
}

/* Network cards */
.network-card {
  border: 1px solid #f0f2f5;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.network-card-owner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #f8f9fa;
  border-bottom: 1px solid #f0f2f5;
}
.network-card-helper {
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border-bottom: 1px solid #f8f9fa;
  display: flex;
  align-items: center;
}
.network-card-helper:last-child {
  border-bottom: none;
}

/* Members page empty state */
.members-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: #6c757d;
}
.members-empty i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}
.members-empty p {
  font-size: 0.9rem;
  margin: 0;
}

/* ===== DESKTOP PREVIEW MODE (มือถือจริง กดดู desktop) ===== */
/* บังคับ override responsive ให้แสดงแบบ desktop */
body.desktop-preview-active {
  min-width: 1024px;
  overflow-x: auto;
}
body.desktop-preview-active .navbar-collapse {
  display: flex !important;
  flex-basis: auto;
}
body.desktop-preview-active .navbar-toggler {
  display: none !important;
}
body.desktop-preview-active .navbar-nav {
  flex-direction: row;
}
body.desktop-preview-active .navbar-nav .nav-link {
  padding: 0.5rem 0.75rem;
}
body.desktop-preview-active .navbar-nav.ms-auto {
  margin-left: auto !important;
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
/* ยกเลิก mobile card views */
body.desktop-preview-active .members-desktop-table { display: block !important; }
body.desktop-preview-active .members-mobile-cards { display: none !important; }
body.desktop-preview-active .admin-desktop-table { display: block !important; }
body.desktop-preview-active .admin-mobile-cards { display: none !important; }
/* stat cards กลับเป็น desktop */
body.desktop-preview-active .stat-card .stat-value { font-size: 2rem; }
body.desktop-preview-active .stat-card .card-body { padding: 1.5rem; }
body.desktop-preview-active .page-header { flex-direction: row; align-items: center; }
body.desktop-preview-active .nav-action-label { display: none; }
