:root {
  --bg-page: #f4f6f9;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  /* Column 1: Blue (รอจัดของ) */
  --blue-text: #1d4ed8;
  --blue-bg: #eff6ff;
  --blue-border: #bfdbfe;
  --blue-dot: #3b82f6;

  /* Column 2: Purple (รอส่งมอบ) */
  --purple-text: #6d28d9;
  --purple-bg: #f5f3ff;
  --purple-border: #ddd6fe;
  --purple-dot: #8b5cf6;

  /* Column 3: Emerald (กำลังยืม) */
  --emerald-text: #047857;
  --emerald-bg: #ecfdf5;
  --emerald-border: #a7f3d0;
  --emerald-dot: #10b981;

  /* Column 4: Rose (เกินกำหนด / คืนไม่ครบ) */
  --rose-text: #be123c;
  --rose-bg: #fff1f2;
  --rose-border: #fecdd3;
  --rose-dot: #f43f5e;

  /* Amber */
  --amber-text: #b45309;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --danger: #e11d48;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 8px 20px rgba(15, 23, 42, 0.09);
  --shadow-lg: 0 24px 48px rgba(15, 23, 42, 0.18);
}

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

html, body {
  height: 100vh;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Sarabun', 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================================
   APPLLAMA BENCHMARK DESIGN STANDARDS (Mobile HIG & Native Polish)
   ============================================================================ */

/* 1. Appllama Law 4: Tabular numerals for anything that counts, times, or serials */
.tabular-nums,
.stat-pill,
.badge,
.print-loan-badge,
.brand-count-val,
.brand-stat-num,
.loan-card-counter,
.tag-badge,
.serial-badge,
.delivery-meta-value,
.loan-date-box,
.loan-code,
.gp-doc-no,
.kanban-col-count,
.summary-count,
.brand-count-badge {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* 2. Appllama Motion Laws: Subtle Tactile Press Feedback (Scale 0.97 on press-in) */
.btn:active,
.btn-primary:active,
.btn-outline:active,
.btn-dark:active,
.fab-delivery-btn:active,
.btn-navbar-action:active,
.btn-navbar-icon-only:active,
.btn-close-modal:active,
.btn-input-clear:active {
  transform: scale(0.97);
  transition: transform 0.12s cubic-bezier(0.23, 1, 0.32, 1);
}

.clickable-card {
  transition: transform 0.16s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.16s ease;
}

.clickable-card:active {
  transform: scale(0.985);
}

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

/* ============================================================================
   HEADER & KPI PILLS
   ============================================================================ */
.app-shell {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ============================================================================
   UNIFIED ULTRA-MINIMAL APP HEADER (PERMANENTLY LOCKED TO TOP)
   ============================================================================ */
.app-header {
  position: static !important;
  flex-shrink: 0;
  width: 100%;
  height: 52px;
  min-height: 52px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
  padding: 0 20px;
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
}

/* Zone 1: Left (Brand & View Switcher) */
.brand-group {
  display: flex;
  align-items: center;
  gap: 7px;
  user-select: none;
  flex-shrink: 0;
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.28);
}

.brand-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  letter-spacing: -0.3px;
}

.version-pill {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 99px;
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #dbeafe;
  letter-spacing: 0;
}

.header-divider {
  width: 1px;
  height: 18px;
  background: #e2e8f0;
}

/* Segmented View Switcher (Mac / Linear Style) */
.view-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: #f1f5f9;
  padding: 2.5px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.view-btn {
  border: none;
  background: transparent;
  color: #64748b;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.view-btn:hover {
  color: #0f172a;
}

.view-btn.active {
  background: #ffffff;
  color: #0f172a;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}

.view-btn span {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10.5px;
  color: #64748b;
}

.view-btn.active span {
  color: #2563eb;
  font-weight: 700;
}

/* Zone 2: Center (Fluid Search & Sort Group) */
.header-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 180px;
  margin: 0 8px;
}

.search-wrap {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  pointer-events: none;
  color: #94a3b8;
}

.search-wrap input {
  width: 100%;
  height: 32px;
  padding: 0 62px 0 30px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-family: inherit;
  font-size: 12.5px;
  color: #0f172a;
  box-sizing: border-box;
  transition: all 0.18s ease;
}

.search-wrap input:focus {
  outline: none;
  border-color: #2563eb;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn-search-barcode-scan {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
  z-index: 4;
}

.btn-search-barcode-scan:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-search-barcode-scan:active {
  transform: translateY(-50%) scale(0.92);
}

.btn-search-barcode-scan svg {
  stroke: currentColor;
}

.search-kbd-hint {
  position: absolute;
  right: 34px;
  top: 50%;
  transform: translateY(-50%);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.2;
  pointer-events: none;
}

/* Disable WebKit browser native search cancel button globally to prevent duplicate 'X' */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none !important;
  display: none !important;
}

.search-wrap .btn-input-clear,
.search-wrap .clear-search {
  position: absolute;
  right: 34px !important;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(148, 163, 184, 0.25);
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
  line-height: 1;
  z-index: 5;
}

.search-wrap .btn-input-clear:hover,
.search-wrap .clear-search:hover {
  background: #ef4444;
  color: #ffffff;
  transform: translateY(-50%) scale(1.15);
}

.search-wrap .btn-input-clear.hidden,
.search-wrap .clear-search.hidden {
  display: none !important;
}

/* Zone 3: Right (KPIs, Sort & Primary CTA) */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-kpis {
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  height: 24px;
  transition: transform 0.1s ease;
  user-select: none;
}

.kpi-pill strong {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 700;
}

.kpi-blue { background: #eff6ff; color: #1d4ed8; border: 1px solid #dbeafe; }
.kpi-purple { background: #faf5ff; color: #7e22ce; border: 1px solid #f3e8ff; }
.kpi-emerald { background: #ecfdf5; color: #047857; border: 1px solid #d1fae5; }
.kpi-rose { background: #fef2f2; color: #b91c1c; border: 1px solid #fee2e2; }

.sort-btn-compact,
.sort-btn {
  height: 32px;
  padding: 0 10px;
  font-size: 11.5px;
  border-radius: 7px;
  color: #475569;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.sort-btn-compact:hover,
.sort-btn:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}

.sort-icon-svg {
  color: #64748b;
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.sort-btn-compact:hover .sort-icon-svg {
  color: #1e293b;
}

.sort-code {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 700;
  color: #334155;
  letter-spacing: -0.2px;
}

.btn-create-loan {
  height: 32px;
  padding: 0 13px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 7px;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: #2563eb;
  color: #ffffff;
  border: none;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.28);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-create-loan .btn-create-icon {
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.btn-create-loan:hover {
  background: #1d4ed8;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.38);
}

/* Speed-Dial FAB is hidden on desktop by default */
.fab-speed-dial-wrap {
  display: none !important;
}

/* Page Body - Full-Height App Container */
.page-body {
  flex: 1 1 0%;
  min-height: 0;
  padding: 10px 20px 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Tablet & Medium Screens (641px - 1024px): Clean 2-Row Layout */
@media (max-width: 1024px) {
  .app-header {
    height: auto;
    min-height: 52px;
    padding: 8px 16px;
  }
  .page-body {
    padding: 8px 16px 12px;
  }
  .header-inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "brand tabs right"
      "center center center";
    row-gap: 8px;
    column-gap: 12px;
    align-items: center;
  }
  .brand-group {
    grid-area: brand;
  }
  .header-divider {
    display: none;
  }
  .view-switcher {
    grid-area: tabs;
    justify-self: start;
  }
  .header-right {
    grid-area: right;
    justify-self: end;
    margin-left: 0;
  }
  .header-center {
    grid-area: center;
    width: 100%;
    max-width: 100%;
    margin: 0;
  }
}

/* Mobile Screens (<= 640px): Balanced 3-Row Layout (Brand/Profile, Tabs, Search) */
@media (max-width: 640px) {
  .app-header {
    height: auto;
    min-height: 52px;
    padding: 8px 12px;
  }
  .page-body {
    padding: 8px 10px 12px;
  }
  .header-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand right"
      "tabs tabs"
      "center center";
    row-gap: 7px;
    column-gap: 8px;
    align-items: center;
  }
  .brand-group {
    grid-area: brand;
  }
  .header-divider {
    display: none;
  }
  .header-right {
    grid-area: right;
    justify-self: end;
    margin-left: 0;
    display: flex !important;
  }
  .header-right .btn-create-loan {
    display: none !important;
  }
  .view-switcher {
    grid-area: tabs;
    width: 100%;
    display: flex;
    justify-content: stretch;
  }
  .view-switcher .view-btn {
    flex: 1;
    justify-content: center;
    padding: 5px 6px;
    font-size: 11.5px;
    text-align: center;
  }
  .header-center {
    grid-area: center;
    width: 100%;
    max-width: 100%;
    margin: 0;
  }

  .search-kbd-hint {
    display: none !important;
  }

  /* Mobile Speed-Dial FAB Wrap */
  .fab-speed-dial-wrap {
    display: block !important;
    position: fixed !important;
    right: 20px;
    bottom: 24px;
    z-index: 990;
    pointer-events: auto;
  }

  /* Backdrop for closing when tapping outside */
  .fab-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  .fab-speed-dial-wrap.is-open .fab-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Main Circular FAB Button (+) */
  .fab-main-btn {
    position: relative;
    z-index: 10;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45), 0 3px 8px rgba(15, 23, 42, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .fab-main-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .fab-speed-dial-wrap.is-open .fab-main-btn {
    background: #0f172a;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.35);
  }

  .fab-speed-dial-wrap.is-open .fab-main-icon {
    transform: rotate(45deg);
  }

  .fab-main-btn:active {
    transform: scale(0.92);
  }

  /* Speed Dial Actions Menu */
  .fab-menu {
    position: absolute;
    bottom: 66px;
    right: 2px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(14px) scale(0.92);
    transform-origin: bottom right;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .fab-speed-dial-wrap.is-open .fab-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }

  /* Action items: Label Pill + Round Icon */
  .fab-action-item {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease;
  }

  .fab-action-item:active {
    transform: scale(0.96);
  }

  .fab-action-label {
    background: #ffffff;
    color: #0f172a;
    font-size: 13.5px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 99px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.14), 0 0 0 1px rgba(226, 232, 240, 0.9);
    white-space: nowrap;
    letter-spacing: -0.2px;
  }

  .fab-action-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(226, 232, 240, 0.9);
    border: 1px solid rgba(226, 232, 240, 0.8);
    flex-shrink: 0;
  }

  #fabActionCreateLoan .fab-action-icon {
    background: #eff6ff;
    border-color: #bfdbfe;
  }

  #fabActionAddDemo .fab-action-icon {
    background: #f0fdf4;
    border-color: #bbf7d0;
  }
}

/* Highlight Banner */
.highlight-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--blue-bg);
  border: 1px solid var(--blue-border);
  color: var(--blue-text);
  font-size: 13px;
}

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

/* ============================================================================
   KANBAN BOARD (4 MAIN COLUMNS + SUB-STATUS STACKS LIKE activeASSET v1)
   ============================================================================ */
/* ============================================================================
   3D KANBAN WITH THREE.JS
   ============================================================================ */
/* ============================================================================
   MODERN 2D KANBAN BOARD (VELZON / JIRA / LINEAR STYLE)
   ============================================================================ */
.kanban-view-container {
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.kanban-scroll-wrap {
  flex: 1;
  height: 100%;
  min-height: 0;
  position: relative;
  overflow: auto;
  padding-bottom: 24px;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(310px, 1fr));
  gap: 20px;
  min-width: 1260px;
  align-items: stretch;
  min-height: 100%;
  position: relative;
}

.kanban-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px;
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-page);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.col-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.col-icon-box {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.col-title {
  font-size: 14.5px;
  font-weight: 700;
}

.col-subtext {
  font-size: 11px;
  color: var(--text-muted);
}

.col-count-badge {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 99px;
}

/* Column Color Themes */
.theme-blue .col-icon-box, .theme-blue .col-count-badge, .theme-blue .sub-count {
  background: var(--blue-bg);
  color: var(--blue-text);
}
.theme-blue .col-title, .theme-blue .sub-label { color: var(--blue-text); }

.theme-purple .col-icon-box, .theme-purple .col-count-badge, .theme-purple .sub-count {
  background: var(--purple-bg);
  color: var(--purple-text);
}
.theme-purple .col-title, .theme-purple .sub-label { color: var(--purple-text); }

.theme-emerald .col-icon-box, .theme-emerald .col-count-badge, .theme-emerald .sub-count {
  background: var(--emerald-bg);
  color: var(--emerald-text);
}
.theme-emerald .col-title, .theme-emerald .sub-label { color: var(--emerald-text); }

.theme-rose .col-icon-box, .theme-rose .col-count-badge, .theme-rose .sub-count {
  background: var(--rose-bg);
  color: var(--rose-text);
}
.theme-rose .col-title, .theme-rose .sub-label { color: var(--rose-text); }

/* Sub-Status Stack (Collapsible like v1 SubStatusStack) */
.sub-stack {
  background: rgba(241, 245, 249, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.sub-stack-header {
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-family: inherit;
}

.sub-stack-header:hover {
  background: rgba(226, 232, 240, 0.45);
}

.sub-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sub-chevron {
  font-size: 11px;
  color: var(--text-muted);
}

.sub-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.sub-count {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
}

.sub-stack-cards {
  padding: 0 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-col-box {
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.5);
}

/* ============================================================================
   KANBAN LOAN CARD (CLEAN, MINIMAL, RICH TRACKING + 1-CLICK ACTIONS)
   ============================================================================ */
.loan-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 11px;
  padding: 12px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.card-top-row,
.card-models-wrap,
.card-footer {
  position: relative;
  z-index: 1;
}

/* Card Background Watermark (ลายน้ำสถานะปกติบนการ์ด) */
.card-watermark {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1.5px;
  pointer-events: none;
  user-select: none;
  line-height: 1;
  z-index: 0;
  opacity: 0.12;
  text-transform: uppercase;
}

.card-watermark.wm-requested { color: #3b82f6; }
.card-watermark.wm-dispatching { color: #3b82f6; }
.card-watermark.wm-dispatched { color: #7c3aed; }
.card-watermark.wm-delivered { color: #10b981; }
.card-watermark.wm-overdue { color: #e11d48; }
.card-watermark.wm-partial { color: #f59e0b; }
.card-watermark.wm-returned { color: #64748b; }

.loan-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-strong);
}

.loan-card.card-highlight {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.loan-card.card-overdue {
  border-left: 3.5px solid var(--rose-dot);
}

.card-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-top-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.card-company-headline {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.card-sub-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.doc-no {
  font-family: 'Inter', monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Mini Calendar Widget on Kanban Card */
.mini-cal-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cal-overdue-tag {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--rose-text);
  background: var(--rose-bg);
  border: 1px solid var(--rose-border);
  padding: 2px 6px;
  border-radius: 99px;
}

.mini-cal {
  width: 40px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: #fff;
  text-align: center;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  flex-shrink: 0;
}

.mini-cal-month {
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 2px;
  background: #475569;
  color: #fff;
}

.mini-cal-day {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  padding: 2px 0 3px;
  color: var(--text-main);
}

.mini-cal.cal-overdue {
  border-color: #fda4af;
}
.mini-cal.cal-overdue .mini-cal-month {
  background: var(--rose-dot);
  color: #fff;
}
.mini-cal.cal-overdue .mini-cal-day {
  color: var(--rose-text);
  background: #fff1f2;
}

.mini-cal.cal-soon {
  border-color: #fcd34d;
}
.mini-cal.cal-soon .mini-cal-month {
  background: #f59e0b;
  color: #fff;
}
.mini-cal.cal-soon .mini-cal-day {
  color: var(--amber-text);
  background: #fffbeb;
}

.due-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}

.due-pill.overdue {
  background: var(--rose-bg);
  color: var(--rose-text);
  border: 1px solid var(--rose-border);
}

.due-pill.soon {
  background: var(--amber-bg);
  color: var(--amber-text);
  border: 1px solid var(--amber-border);
}

.due-pill.normal {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

/* Brand & Model Chips on Kanban Card (Minimal: No Tag ID, No extra details) */
.card-models-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0 2px;
}

.card-model-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 7px;
}

.card-model-pill strong {
  font-weight: 700;
}

.model-qty {
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  padding: 0 6px;
  border-radius: 99px;
}

.mini-tag-code {
  font-family: 'Inter', monospace;
  font-size: 11px;
  font-weight: 700;
  background: #1e293b;
  color: #fff;
  padding: 0 5px;
  border-radius: 4px;
}

.src-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 4px;
}
.src-Demo { background: var(--purple-bg); color: var(--purple-text); }
.src-Supplier { background: #fff7ed; color: #c2410c; }
.src-คลังขาย { background: #f0f9ff; color: #0369a1; }

.card-acc-summary {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-issue-alert {
  font-size: 11.5px;
  color: var(--rose-text);
  background: var(--rose-bg);
  padding: 4px 7px;
  border-radius: 6px;
  font-weight: 600;
}

/* Card Footer */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid #f8fafc;
  font-size: 11.5px;
  color: var(--text-muted);
  gap: 6px;
}

.card-footer-doc-pill {
  margin-left: auto !important;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-card-edit-minimal {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  border: 1px solid #e2e8f0;
  background: rgba(248, 250, 252, 0.85);
  border-radius: 5px;
  padding: 2.5px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-card-edit-minimal:hover {
  background: #ffffff;
  color: #2563eb;
  border-color: #93c5fd;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08);
}

.btn-card-cancel-minimal {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  color: #ef4444;
  border: 1px solid #fee2e2;
  background: rgba(254, 242, 242, 0.6);
  border-radius: 5px;
  padding: 2.5px 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-card-cancel-minimal:hover {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fca5a5;
  box-shadow: 0 1px 2px rgba(239, 68, 68, 0.12);
}

.btn-cancel-loan-action {
  color: #ef4444 !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  padding: 4px 8px !important;
  border-radius: 6px !important;
  transition: all 0.15s ease !important;
}

.btn-cancel-loan-action:hover {
  background: #fef2f2 !important;
  color: #b91c1c !important;
}

.card-tap-hint {
  font-size: 11px;
  color: #94a3b8;
}

/* ============================================================================
   EXCEL-LIKE TABLE INSIDE "+ ออกใบยืม" MODAL & LIST VIEWS
   ============================================================================ */
.list-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: auto;
  box-shadow: var(--shadow-card);
  flex: 1;
  height: 100%;
  min-height: 0;
}

.list-card thead th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #f8fafc;
}

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

.source-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
}

.chip {
  border: 1px solid var(--border-color);
  background: #fff;
  padding: 4px 10px;
  border-radius: 99px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.chip.active {
  background: var(--text-main);
  color: #fff;
  border-color: var(--text-main);
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.sheet-table th {
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-strong);
  border-right: 1px solid var(--border-color);
}

.sheet-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid #eef2f6;
  vertical-align: middle;
  font-size: 13px;
}

.excel-table-wrap {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 16px;
  box-shadow: 0 4px 24px -4px rgba(15, 23, 42, 0.04), 
              0 1px 2px rgba(0, 0, 0, 0.02);
  overflow: visible;
  transition: all 0.2s ease;
}

.excel-loan-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: transparent;
}

.excel-loan-table thead th {
  background: #f8fafc;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f8fafc;
}

.excel-loan-table thead th:first-child {
  border-top-left-radius: 15px;
}

.excel-loan-table thead th:last-child {
  border-top-right-radius: 15px;
  border-right: none;
}

.excel-loan-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f8fafc;
  vertical-align: middle;
  font-size: 13px;
  background: transparent;
  transition: background-color 0.15s ease;
}

.excel-loan-table tbody td:last-child {
  border-right: none;
}

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

.excel-loan-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 15px;
}

.excel-loan-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: 15px;
}

.excel-loan-table tbody tr:hover td {
  background: #fafafa;
}

.excel-loan-table tbody tr:focus-within td {
  background: #f8fafc !important;
}

/* Interactive Accessory Tag Editor inside Excel-like Row */
.tag-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-height: 30px;
}

.acc-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 122, 255, 0.09);
  border: 1px solid rgba(0, 122, 255, 0.22);
  color: #007aff;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
  box-shadow: 0 1px 2px rgba(0, 122, 255, 0.04);
  transition: all 0.15s ease;
}

.acc-tag button {
  border: none;
  background: rgba(0, 122, 255, 0.15);
  color: #007aff;
  font-size: 11px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: all 0.15s ease;
}

.acc-tag button:hover {
  background: #ef4444;
  color: #ffffff;
}

.tag-add-input {
  border: 1px dashed rgba(148, 163, 184, 0.7);
  background: rgba(255, 255, 255, 0.75);
  border-radius: 8px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  width: 130px;
  transition: all 0.2s ease;
}

.tag-add-input:focus {
  outline: none;
  background: #ffffff;
  border-style: solid;
  border-color: #007aff;
  width: 170px;
  box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.15);
}

/* Excel-like In-line Edit Cell & Table Enhancements */
.excel-loan-table tbody tr {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.excel-loan-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.55);
}

.excel-loan-table tbody tr.row-empty td {
  background: rgba(250, 251, 252, 0.25);
}

.excel-loan-table tbody tr:focus-within td {
  background: rgba(240, 247, 255, 0.72) !important;
}

.excel-loan-table td.cell-num {
  text-align: center;
  font-weight: 700;
  color: #007aff;
  vertical-align: middle;
}

.mobile-item-title {
  display: none;
}

.badge-card-new {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #007aff;
  background: rgba(0, 122, 255, 0.1);
  border: 1px solid rgba(0, 122, 255, 0.28);
  padding: 1px 7px;
  border-radius: 99px;
  margin-left: 6px;
  line-height: 1.35;
  vertical-align: middle;
}

@keyframes newCardGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.4), 0 8px 20px -4px rgba(0, 122, 255, 0.2);
    transform: scale(0.995);
  }
  60% {
    box-shadow: 0 0 0 6px rgba(0, 122, 255, 0.22), 0 16px 36px -4px rgba(0, 122, 255, 0.26);
    transform: scale(1.005);
  }
  100% {
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.16), 0 14px 34px -4px rgba(0, 122, 255, 0.22);
    transform: scale(1);
  }
}

/* Collapsed Item Row in Loan Dialog (In-Column Minimal Luxury) */
.excel-loan-table tr.row-collapsed {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.excel-loan-table tr.row-collapsed:hover {
  background-color: #f8fafc;
}

.excel-loan-table tr.row-collapsed td {
  padding: 10px 10px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f8fafc;
  background: transparent;
}

.excel-loan-table tr.row-collapsed td:last-child {
  border-right: none;
}

.collapsed-cell-model-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.collapsed-item-badge {
  font-size: 11.5px;
  font-weight: 700;
  color: #007aff;
  background: rgba(0, 122, 255, 0.12);
  padding: 2px 8px;
  border-radius: 6px;
  line-height: 1.3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mobile-only-badge {
  display: none;
}

.collapsed-model-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collapsed-cell-qty-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.collapsed-qty-pill {
  font-size: 12px;
  font-weight: 700;
  color: #059669;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.22);
  padding: 2px 9px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
}

.collapsed-qty-pill.short {
  color: #e11d48;
  background: rgba(225, 29, 72, 0.1);
  border-color: rgba(225, 29, 72, 0.25);
}

.collapsed-cell-source-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.collapsed-source-pill {
  font-size: 11.5px;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.collapsed-cell-options-wrap,
.collapsed-cell-note-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.collapsed-acc-text,
.collapsed-note-text {
  font-size: 11.5px;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 100%;
}

.collapsed-att-text {
  font-size: 11px;
  color: #007aff;
  font-weight: 500;
  white-space: nowrap;
}

.collapsed-empty-dash {
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 500;
  user-select: none;
}

/* Edit item button (Icon-only, iOS Glass styling matching dup and delete) */
.btn-item-edit,
.btn-toggle-expand {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 9px;
  background: rgba(0, 122, 255, 0.09);
  color: #007aff;
  border: 1px solid rgba(0, 122, 255, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
  box-sizing: border-box;
}

.excel-loan-table td.cell-action .btn-item-edit,
.excel-loan-table td.cell-action .btn-item-dup,
.excel-loan-table td.cell-action .btn-item-delete,
.excel-loan-table td.cell-action .btn-collapse-mobile {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
}

.btn-item-edit:hover,
.btn-toggle-expand:hover {
  background: #007aff;
  border-color: #007aff;
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(0, 122, 255, 0.3);
  transform: translateY(-1px);
}

.btn-item-edit:active,
.btn-toggle-expand:active {
  transform: scale(0.92);
}

/* Delete item button */
.btn-item-delete,
.btn-item-delete-active {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 9px;
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
  box-sizing: border-box;
}

.btn-item-delete:hover:not(:disabled),
.btn-item-delete-active:hover:not(:disabled) {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(239, 68, 68, 0.3);
  transform: translateY(-1px);
}

.btn-item-delete:active:not(:disabled),
.btn-item-delete-active:active:not(:disabled) {
  transform: scale(0.92);
}

.btn-item-delete:disabled,
.btn-item-delete-active:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.2);
  color: #94a3b8;
}

/* Duplicate item button (Icon-only, iOS Glass styling) */
.btn-item-dup {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  background: rgba(14, 165, 233, 0.09);
  color: #0284c7;
  border: 1px solid rgba(14, 165, 233, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
  box-sizing: border-box;
}

.btn-item-dup:hover:not(:disabled) {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(2, 132, 199, 0.3);
  transform: translateY(-1px);
}

.btn-item-dup:active:not(:disabled) {
  transform: scale(0.92);
}

.btn-item-dup:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.2);
  color: #94a3b8;
  box-shadow: none;
  transform: none;
}

.collapsed-sn-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collapsed-sn-pill.complete {
  color: #059669;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.collapsed-sn-pill.warn {
  color: #d97706;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.collapsed-sn-pill.pending {
  color: #64748b;
  background: rgba(241, 245, 249, 0.85);
  border: 1px solid rgba(226, 232, 240, 0.9);
}

/* ============================================================================
   S/N & ACCESSORIES TRIGGER BUTTONS & MODAL SHEETS
   ============================================================================ */
.cell-options-wrap {
  margin-top: 6px;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  width: 100%;
}

/* Accessories Trigger Button */
.btn-acc-trigger {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  background: rgba(241, 245, 249, 0.85);
  border: 1px dashed rgba(148, 163, 184, 0.75);
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  box-sizing: border-box;
}

.btn-acc-trigger:hover {
  background: rgba(238, 242, 255, 0.85);
  border-color: #6366f1;
  color: #4f46e5;
}

.btn-acc-trigger .acc-trig-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acc-trig-filled-group {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.acc-trig-filled-group .btn-acc-trigger {
  flex: 1 1 0;
  min-width: 0;
}

.btn-acc-trigger.filled {
  border-style: solid;
  background: rgba(245, 243, 255, 0.95);
  border-color: rgba(196, 181, 253, 0.9);
  color: #6d28d9;
}

.btn-acc-trigger.filled:hover {
  background: #ede9fe;
  border-color: #8b5cf6;
}

.btn-acc-trigger .acc-trig-edit-hint {
  font-size: 11px;
  color: #64748b;
  margin-left: 2px;
  flex-shrink: 0;
}

.btn-clear-acc-quick {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-clear-acc-quick:hover {
  background: #ef4444;
  color: #ffffff;
}

/* Modal Dialog: modal-acc-sheet */
dialog.modal-acc-sheet {
  width: 480px;
  max-width: 94vw;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(25px) saturate(190%);
  backdrop-filter: blur(25px) saturate(190%);
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(226, 232, 240, 0.9);
  padding: 0;
  overflow: hidden;
  animation: confirmPop 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.acc-modal-content {
  display: flex;
  flex-direction: column;
}

.acc-modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(248, 250, 252, 0.7);
}

.acc-modal-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.acc-modal-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.12);
  color: #4f46e5;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.acc-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.acc-modal-sub {
  font-size: 12px;
  color: #64748b;
  margin: 2px 0 0;
}

.btn-close-acc-modal {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(241, 245, 249, 0.9);
  color: #64748b;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-close-acc-modal:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.acc-modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 58vh;
  overflow-y: auto;
}

.acc-modal-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.acc-modal-sec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.acc-modal-sec-title {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}

.acc-modal-selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 36px;
  padding: 8px 10px;
  background: rgba(248, 250, 252, 0.8);
  border: 1px dashed rgba(203, 213, 225, 0.9);
  border-radius: 10px;
}

.acc-modal-empty-hint {
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
  display: flex;
  align-items: center;
}

.acc-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid rgba(196, 181, 253, 0.9);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 8px;
}

.btn-rm-acc-tag {
  border: none;
  background: transparent;
  color: #7c3aed;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-rm-acc-tag:hover {
  color: #ef4444;
}

.acc-modal-add-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.acc-modal-input {
  flex: 1;
  height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 13px;
  color: #0f172a;
  background: #fff;
  transition: all 0.15s ease;
}

.acc-modal-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.acc-modal-quick-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.acc-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.acc-quick-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.acc-quick-btn.selected {
  background: #ede9fe;
  border-color: #a78bfa;
  color: #6d28d9;
}

.acc-modal-footer {
  padding: 12px 18px;
  border-top: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(248, 250, 252, 0.7);
}

.acc-modal-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* S/N Trigger Button */
.btn-sn-trigger {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  background: rgba(241, 245, 249, 0.85);
  border: 1px dashed rgba(148, 163, 184, 0.75);
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  box-sizing: border-box;
}

.btn-sn-trigger:hover {
  background: rgba(224, 242, 254, 0.85);
  border-color: #0284c7;
  color: #0369a1;
}

.btn-sn-trigger .sn-trig-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-sn-trigger .sn-trig-qty-badge {
  font-size: 11px;
  font-weight: 700;
  color: #0284c7;
  background: rgba(14, 165, 233, 0.12);
  padding: 1px 6px;
  border-radius: 99px;
  flex-shrink: 0;
}

.sn-trig-filled-group {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sn-trig-filled-group .btn-sn-trigger {
  flex: 1 1 0;
  min-width: 0;
}

.btn-sn-trigger.filled {
  border-style: solid;
}

.btn-sn-trigger.filled.complete {
  background: rgba(240, 253, 244, 0.95);
  border-color: rgba(74, 222, 128, 0.85);
  color: #15803d;
}

.btn-sn-trigger.filled.complete:hover {
  background: #dcfce7;
  border-color: #22c55e;
}

.btn-sn-trigger.filled.warn {
  background: rgba(254, 243, 199, 0.95);
  border-color: rgba(251, 191, 36, 0.85);
  color: #b45309;
}

.btn-sn-trigger .sn-trig-edit-hint {
  font-size: 11px;
  color: #64748b;
  margin-left: 2px;
  flex-shrink: 0;
}

.btn-clear-sn-quick {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-clear-sn-quick:hover {
  background: #ef4444;
  color: #ffffff;
}

/* Modal Dialog: modal-sn-sheet (Minimal Apple Style) */
dialog.modal-sn-sheet {
  width: 400px;
  max-width: 92vw;
  border-radius: 20px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: #ffffff;
  box-shadow: 0 20px 48px -10px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.04);
  padding: 0;
  overflow: visible;
  animation: confirmPop 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  margin: 10vh auto auto auto !important;
}

.sn-modal-content {
  display: flex;
  flex-direction: column;
}

.sn-modal-header {
  padding: 16px 20px 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  border-radius: 20px 20px 0 0;
}

.sn-modal-header-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sn-modal-icon {
  display: none;
}

.sn-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.2px;
  margin: 0;
  line-height: 1.25;
}

.sn-modal-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: #64748b;
  margin: 0;
  line-height: 1.3;
}

.sn-sub-model {
  font-weight: 600;
  color: #334155;
}

.sn-sub-source-pill {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 99px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.btn-close-sn-modal {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(241, 245, 249, 0.9);
  color: #64748b;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-close-sn-modal:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.sn-modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 55vh;
  overflow-y: auto;
  background: #ffffff;
}

.sn-modal-rule-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #0369a1;
  background: rgba(224, 242, 254, 0.7);
  border: 1px solid rgba(186, 230, 253, 0.9);
  padding: 8px 12px;
  border-radius: 10px;
  line-height: 1.4;
}

.sn-modal-alert {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(254, 242, 242, 0.9);
  border: 1px solid rgba(254, 202, 202, 0.9);
  color: #b91c1c;
  font-size: 12px;
  font-weight: 600;
}

.sn-modal-slots-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sn-modal-slot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 4px 10px;
  transition: all 0.15s ease;
}

.sn-modal-slot-row:hover {
  border-color: #cbd5e1;
  background: #ffffff;
}

.sn-modal-slot-row:focus-within {
  border-color: #007aff;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.14);
}

.sn-slot-num {
  font-size: 11px;
  font-weight: 700;
  color: #007aff;
  background: rgba(0, 122, 255, 0.08);
  padding: 2px 6px;
  border-radius: 5px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.sn-modal-slot-input {
  flex: 1;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  padding: 6px 0;
  box-shadow: none !important;
}

.sn-modal-slot-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
  font-size: 12.5px;
}

.sn-slot-status-wrap {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.sn-slot-status {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
  transition: all 0.15s ease;
  line-height: 1.3;
}

.sn-slot-status.in-db {
  color: #059669;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.sn-slot-status.not-in-db {
  color: #d97706;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.btn-clear-sn-slot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(148, 163, 184, 0.2);
  color: #64748b;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.btn-clear-sn-slot:hover {
  background: #ef4444;
  color: #ffffff;
}

.btn-sn-slot-arrow {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-sn-slot-arrow:hover {
  background: rgba(0, 122, 255, 0.1);
  color: #007aff;
}

#snModalDropdownMenu {
  position: absolute !important;
  background: rgba(255, 255, 255, 0.98);
  -webkit-backdrop-filter: blur(25px) saturate(190%);
  backdrop-filter: blur(25px) saturate(190%);
  box-shadow: 0 16px 40px -4px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(226, 232, 240, 0.95);
  border-radius: 14px;
  z-index: 100;
}

.sn-modal-footer {
  padding: 12px 20px 16px 20px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border-radius: 0 0 20px 20px;
}

.btn-clear-all-sn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 4px;
  transition: color 0.15s ease;
}

.btn-clear-all-sn:hover {
  color: #ef4444;
}

.sn-modal-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-cancel-sn {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 7px 12px;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.btn-cancel-sn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.btn-save-sn {
  background: #007aff;
  border: none;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 7px 18px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 122, 255, 0.25);
  transition: all 0.15s ease;
}

.btn-save-sn:hover {
  background: #0066d6;
  box-shadow: 0 3px 8px rgba(0, 122, 255, 0.32);
}

/* Placeholder for next row */
.cell-add-next-item {
  padding: 6px 8px !important;
  background: transparent !important;
}

.btn-add-next-item {
  width: 100%;
  border: 1.5px dashed rgba(0, 122, 255, 0.45);
  background: rgba(240, 247, 255, 0.65);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #007aff;
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px 14px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-add-next-item:hover {
  background: rgba(224, 239, 255, 0.85);
  border-color: #007aff;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.15);
}

.btn-quick-collapse {
  display: none; /* Mobile shows header collapse */
}

.cell-step-next {
  display: none; /* Hidden on desktop table, shown on mobile */
}

.excel-loan-table tbody td {
  vertical-align: middle;
  padding: 8px 6px;
}

.model-picker-cell {
  position: relative;
  min-width: 250px;
}

.cell-options-cell {
  vertical-align: middle;
  padding: 8px 6px;
}

.cell-options-cell .cell-options-wrap {
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
}

.model-input-wrap {
  position: relative;
  width: 100%;
}

.excel-loan-table .model-search-input {
  width: 100%;
  height: 38px;
  border: 1px solid rgba(203, 213, 225, 0.75);
  background: rgba(255, 255, 255, 0.85);
  padding: 0 34px 0 12px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03), 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.excel-loan-table .model-search-input:focus {
  outline: none;
  background: #ffffff;
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.18), inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.btn-clear-model-input {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(148, 163, 184, 0.22);
  color: #64748b;
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  z-index: 3;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
  line-height: 1;
}

.btn-clear-model-input:hover {
  background: #ef4444;
  color: #ffffff;
  transform: translateY(-50%) scale(1.1);
}

.btn-clear-model-input.hidden {
  display: none !important;
}

.cell-accessories-subrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 6px 10px;
  background: rgba(248, 250, 252, 0.65);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px dashed rgba(148, 163, 184, 0.6);
  border-radius: 10px;
  min-height: 32px;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.cell-accessories-subrow:hover {
  background: rgba(255, 255, 255, 0.88);
  border-color: #94a3b8;
}

.cell-accessories-subrow:focus-within {
  background: #ffffff;
  border-color: #007aff;
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.tag-editor-prefix {
  font-size: 11.5px;
  font-weight: 700;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  user-select: none;
}

.cell-inline-edit {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 8px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  transition: all 0.15s ease;
}

.cell-inline-edit:hover {
  border-color: var(--border-strong);
  background: #fff;
}

.cell-inline-edit:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.cell-inline-edit::placeholder {
  font-weight: normal;
  color: #94a3b8;
}

/* Quantity Stepper iOS Segmented Control Look */
.excel-loan-table .qty-stepper {
  display: inline-flex;
  align-items: center;
  background: rgba(241, 245, 249, 0.85);
  border: 1px solid rgba(203, 213, 225, 0.8);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}

.excel-loan-table .qty-step-btn {
  width: 32px;
  height: 36px;
  background: transparent;
  border: none;
  color: #007aff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.excel-loan-table .qty-step-btn:hover {
  background: rgba(0, 122, 255, 0.1);
}

.excel-loan-table .qty-step-btn:active {
  background: rgba(0, 122, 255, 0.2);
}

.excel-loan-table .qty-step-input {
  width: 38px;
  height: 36px;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  outline: none;
}

/* Real-time Simulated Stock Reservation */
.qty-stepper-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.qty-stepper.is-qty-short {
  border-color: rgba(239, 68, 68, 0.8) !important;
  background: rgba(254, 242, 242, 0.9) !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.18);
}

.stock-sim-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 1.5px 6px;
  border-radius: 6px;
  white-space: nowrap;
  line-height: 1.2;
}

.stock-sim-tag.ok {
  color: #059669;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.stock-sim-tag.short {
  color: #dc2626;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-weight: 700;
}

.sim-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.sim-dot.ok {
  background: #10b981;
}

.sim-dot.short {
  background: #ef4444;
}

.collapsed-stock-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.collapsed-stock-pill.ok {
  color: #059669;
  background: rgba(16, 185, 129, 0.1);
}

.collapsed-stock-pill.short {
  color: #dc2626;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-weight: 700;
}

.collapsed-qty-pill.short {
  background: rgba(239, 68, 68, 0.12) !important;
  color: #dc2626 !important;
}

/* Source Select iOS Glass Look */
.excel-loan-table .cell-source select,
.excel-loan-table .cell-source .cell-source-btn {
  width: 100%;
  height: 38px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(203, 213, 225, 0.75);
  border-radius: 10px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03), 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  box-sizing: border-box;
}

.excel-loan-table .cell-source select:hover,
.excel-loan-table .cell-source .cell-source-btn:hover {
  background: #ffffff;
  border-color: #94a3b8;
}

.excel-loan-table .cell-source select:focus,
.excel-loan-table .cell-source .cell-source-btn:focus {
  background: #ffffff;
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.18);
  outline: none;
}

.source-btn-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-btn-arrow {
  color: #64748b;
  font-size: 11px;
  margin-left: 4px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

/* Custom Source Dropdown Items (Matches Model Dropdown iOS Glass Style) */
.source-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  border-bottom: 1px solid rgba(241, 245, 249, 0.8);
}

.source-dropdown-item:last-child {
  border-bottom: none;
}

.source-dropdown-item:hover {
  background: rgba(0, 122, 255, 0.08);
}

.source-dropdown-item.is-selected {
  background: rgba(0, 122, 255, 0.07);
}

.source-check-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #007aff;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.source-item-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  letter-spacing: 0.2px;
}

.badge-source-demo {
  background: #f0fdfa;
  color: #0f766e;
  border: 1px solid #ccfbf1;
}

.badge-source-supplier {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-source-sales {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.badge-source-replacement {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.cell-note {
  vertical-align: top;
  min-width: 180px;
}

/* Unified Note Container (Single Line First, Expands on Multiline, Paperclip at Bottom-Right) */
.note-unified-box {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  height: 38px;
  min-height: 38px;
  padding: 7px 32px 7px 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(203, 213, 225, 0.85);
  border-radius: 10px;
  box-sizing: border-box;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03), 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  cursor: text;
}

.note-unified-box:hover {
  border-color: #94a3b8;
}

.note-unified-box:focus-within {
  border-color: #007aff;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.18);
}

.note-box-textarea {
  width: 100% !important;
  min-height: 22px !important;
  height: 22px;
  resize: none !important;
  line-height: 22px !important;
  font-family: inherit !important;
  font-size: 13.5px !important;
  padding: 0 !important;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  box-sizing: border-box !important;
  color: var(--text-main, #1e293b);
  overflow-y: hidden;
}

.note-box-textarea::placeholder {
  color: #94a3b8;
  line-height: 22px;
}

/* Attach Clip Icon */
.btn-box-clip {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #007aff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  padding: 0;
  z-index: 2;
}

.btn-box-clip:hover {
  background: rgba(0, 122, 255, 0.12);
  color: #0056b3;
  transform: scale(1.08);
}

.btn-box-clip:active {
  transform: scale(0.95);
}

.note-box-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  width: 100%;
}

.note-box-tags:not(:empty) {
  margin-top: 6px;
  padding-right: 26px;
}

/* Tag Pill with Numbering Header */
.note-file-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 7px 3px 4px;
  background: #f1f5f9;
  border: 1px solid rgba(203, 213, 225, 0.95);
  border-radius: 8px;
  font-size: 11.5px;
  color: #1e293b;
  box-sizing: border-box;
  max-width: 100%;
  transition: all 0.15s ease;
  cursor: pointer;
  user-select: none;
}

.note-file-tag:hover {
  background: #ffffff;
  border-color: #007aff;
  box-shadow: 0 2px 6px rgba(0, 122, 255, 0.15);
  transform: translateY(-0.5px);
}

.file-tag-num {
  font-size: 10.5px;
  font-weight: 700;
  color: #0284c7;
  background: #e0f2fe;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.file-tag-thumb-wrap,
.file-tag-thumb-link {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-tag-thumb {
  width: 20px;
  height: 20px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.file-tag-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.file-tag-name {
  color: #007aff;
  text-decoration: none;
  font-weight: 500;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-file-tag:hover .file-tag-name {
  text-decoration: underline;
}

.file-tag-size {
  color: #64748b;
  font-size: 10.5px;
  flex-shrink: 0;
}

.btn-remove-file-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: rgba(203, 213, 225, 0.65);
  color: #475569;
  font-size: 10px;
  cursor: pointer;
  margin-left: 2px;
  transition: all 0.15s ease;
  line-height: 1;
  padding: 0;
}

.btn-remove-file-tag:hover {
  background: #ef4444;
  color: #ffffff;
}

/* File Preview Lightbox Modal */
dialog.modal-preview-lightbox {
  width: 680px;
  max-width: 95vw;
  max-height: 90vh;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.98);
  -webkit-backdrop-filter: blur(25px) saturate(190%);
  backdrop-filter: blur(25px) saturate(190%);
  box-shadow: 0 30px 70px -15px rgba(15, 23, 42, 0.45), 0 0 0 1px rgba(0, 0, 0, 0.06);
  padding: 0;
  overflow: hidden;
  animation: confirmPop 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.preview-lightbox-inner {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.preview-lightbox-header {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #f1f5f9;
  background: #ffffff;
}

.preview-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.preview-header-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.preview-header-text {
  min-width: 0;
}

.preview-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-modal-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

.preview-counter-badge {
  font-size: 11px;
  font-weight: 700;
  color: #4f46e5;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  padding: 2px 7px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.preview-modal-meta {
  font-size: 11.5px;
  color: #64748b;
}

.preview-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.preview-external-link {
  font-size: 12px !important;
  padding: 5px 10px !important;
  text-decoration: none;
  border-radius: 8px !important;
}

.btn-close-preview-modal {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(241, 245, 249, 0.9);
  color: #64748b;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-close-preview-modal:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.preview-lightbox-body-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  width: 100%;
  min-height: 280px;
}

.btn-preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.7);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  transition: all 0.18s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  padding: 0;
}

.btn-preview-nav:hover {
  background: rgba(99, 102, 241, 0.95);
  border-color: rgba(255, 255, 255, 0.8);
  transform: translateY(-50%) scale(1.1);
}

.btn-preview-nav.prev {
  left: 12px;
}

.btn-preview-nav.next {
  right: 12px;
}

.preview-lightbox-body {
  padding: 16px 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  overflow: auto;
  width: 100%;
  min-height: 280px;
  max-height: calc(82vh - 120px);
  box-sizing: border-box;
}

.preview-img-content {
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  user-select: none;
  -webkit-user-drag: none;
}

.preview-lightbox-footer {
  padding: 10px 14px;
  background: #1e293b;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: center;
  overflow-x: auto;
  box-sizing: border-box;
}

.preview-thumbnails-track {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.preview-thumb-btn {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  padding: 0;
  background: #334155;
  cursor: pointer;
  opacity: 0.55;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.preview-thumb-btn:hover {
  opacity: 0.9;
  transform: scale(1.05);
}

.preview-thumb-btn.active {
  opacity: 1;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4);
  transform: scale(1.08);
}

.preview-thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-iframe-content {
  width: 100%;
  height: 65vh;
  border: none;
  border-radius: 8px;
  background: #ffffff;
}

.preview-card-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 30px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 360px;
}

.preview-fallback-icon {
  font-size: 48px;
}

.preview-fallback-name {
  font-weight: 700;
  font-size: 15px;
  color: #0f172a;
  word-break: break-all;
}

.preview-fallback-size {
  font-size: 12px;
  color: #64748b;
}

/* Collapsed card pills */
.collapsed-att-text {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #0284c7;
  font-weight: 600;
  background: rgba(2, 132, 199, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
}

/* Mini chip for dispatch */
.mini-att-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #0f766e;
  text-decoration: none;
  font-weight: 500;
}

.mini-att-chip:hover {
  background: #e2e8f0;
  color: #0d5f57;
}

.excel-loan-table td.cell-action {
  white-space: nowrap;
  vertical-align: middle !important;
}

.cell-action-group {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.excel-loan-table td.cell-action .btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.09);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.18);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s ease;
}

.excel-loan-table td.cell-action .btn:hover:not(:disabled) {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

.excel-loan-table td.cell-action .btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: rgba(148, 163, 184, 0.1);
  border-color: transparent;
}

.model-stock-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #0f766e;
  background: #f0fdfa;
  border: 1px solid #ccfbf1;
  padding: 1px 6px;
  border-radius: 4px;
  margin-top: 3px;
}

/* Custom Search & Select Dropdown Menu for Models (iOS Glass Popover) */
.model-dropdown-menu {
  position: fixed;
  width: 380px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.88);
  -webkit-backdrop-filter: blur(25px) saturate(190%);
  backdrop-filter: blur(25px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  box-shadow: 0 20px 45px -5px rgba(0, 0, 0, 0.18), 0 10px 15px -5px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  z-index: 99999;
  padding: 0;
}

.dropdown-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
  user-select: none;
}

.dropdown-header-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-close-dropdown {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
  padding: 0;
}

.btn-close-dropdown:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #ef4444;
}

.dropdown-scroll-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 0;
}

.dropdown-scroll-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  min-height: 24px;
  background: #f8fafc;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: background 0.15s ease, color 0.15s ease;
  z-index: 2;
}

.dropdown-scroll-arrow:hover {
  background: #eff6ff;
  color: #2563eb;
}

.dropdown-scroll-arrow:active {
  background: #dbeafe;
  color: #1d4ed8;
}

.dropdown-scroll-arrow.bottom-arrow {
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.04);
}

.dropdown-scroll-arrow.top-arrow {
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}

.model-dropdown-group-title {
  padding: 6px 12px 3px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
}

.model-dropdown-group-title:first-child {
  border-top: none;
}

.model-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  cursor: pointer;
  transition: background-color 0.1s ease;
  user-select: none;
}

.model-dropdown-item:hover,
.model-dropdown-item.is-selected {
  background-color: #f0f9ff;
}

.model-item-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.model-item-name {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
}

.model-item-sub {
  font-size: 11px;
  color: #64748b;
}

.model-item-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  white-space: nowrap;
}

.model-item-badge.badge-avail {
  background: #dcfce7;
  color: #166534;
}

.model-item-badge.badge-empty {
  background: #f1f5f9;
  color: #94a3b8;
}

/* Big Number Stock Display Badge */
.model-count-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-radius: 8px;
  min-width: 44px;
  text-align: center;
  user-select: none;
  font-family: 'Inter', 'Sarabun', -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: -0.2px;
  transition: all 0.15s ease;
}

.model-count-box .count-num {
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}

.model-count-box .count-denom {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.75;
  margin-left: 1px;
}

/* Full in stock: crisp green with prominent big number */
.model-count-box.count-full {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

/* Partially loaned: amber warning showing remaining/total e.g. 1/2 */
.model-count-box.count-partial {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

/* Fully loaned out: subtle muted rose/gray */
.model-count-box.count-zero {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.model-dropdown-empty {
  padding: 14px 12px;
  text-align: center;
  font-size: 12px;
  color: #94a3b8;
}

.cell-input,
.cell-select {
  width: 100%;
  border: 1px solid var(--border-color);
  background: #fff;
  padding: 6px 8px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
}

.cell-input:focus,
.cell-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

/* Stepper Quantity Control with +/- buttons (No default browser spinners) */
.qty-stepper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  height: 32px;
}

.qty-step-btn {
  width: 28px;
  height: 100%;
  border: none;
  background: #f8fafc;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.1s ease;
}

.qty-step-btn:hover {
  background: #e2e8f0;
  color: var(--primary);
}

.qty-step-btn:active {
  background: #cbd5e1;
}

.qty-step-input {
  width: 38px;
  height: 100%;
  border: none;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  background: #fff;
  padding: 0;
  outline: none;
  /* Hide native number arrows */
  -moz-appearance: textfield;
}

.qty-step-input::-webkit-outer-spin-button,
.qty-step-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.qty-step-input:focus {
  background: #eff6ff;
  color: var(--primary);
}

.cell-input:focus,
.cell-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11.5px;
  border-radius: 6px;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 7px;
}

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

.btn-secondary { background: #fff; border-color: var(--border-strong); color: var(--text-main); }
.btn-secondary:hover { background: var(--bg-subtle); }

.btn-outline { background: #fff; border-color: var(--border-color); color: var(--text-main); }
.btn-outline:hover { background: var(--bg-subtle); }

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

.btn-purple { background: #7c3aed; color: #fff; }
.btn-purple:hover { background: #6d28d9; }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text-main); }

.btn-danger { background: var(--danger, #e11d48); color: #fff; border-color: #e11d48; }
.btn-danger:hover { background: #be123c; border-color: #be123c; color: #fff; }

.btn-chip {
  border: 1px solid var(--border-strong);
  background: #fff;
  padding: 3px 10px;
  border-radius: 99px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-chip:hover {
  background: var(--blue-bg);
  border-color: var(--primary);
  color: var(--primary);
}

/* ============================================================================
   DIALOG MODALS (<dialog closedby="any">)
   ============================================================================ */
dialog.modal-dialog {
  margin: auto;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
  padding: 0;
  max-height: 92vh;
  width: 95vw;
}

/* Appllama Native Sheet Presentation: On mobile, non-fullscreen dialogs slide up as native bottom sheets */
@media (max-width: 640px) {
  dialog.modal-dialog:not(.modal-fullscreen):not(.modal-signature) {
    margin: auto 0 0 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 90vh !important;
    border-radius: 20px 20px 0 0 !important;
    box-shadow: 0 -12px 36px rgba(15, 23, 42, 0.22) !important;
    animation: sheetSlideUp 0.26s cubic-bezier(0.23, 1, 0.32, 1) !important;
    overflow: hidden;
  }

  @keyframes sheetSlideUp {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  /* Safe area inset clearance for bottom footers on iOS */
  dialog.modal-dialog:not(.modal-fullscreen) .modal-footer {
    padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
  }
}

/* Native bottom sheet grab handle (visible on mobile sheets) */
.sheet-drag-handle {
  display: none;
}

@media (max-width: 640px) {
  .sheet-drag-handle {
    width: 38px;
    height: 4.5px;
    border-radius: 9999px;
    background: #cbd5e1;
    margin: 8px auto 4px auto;
    display: block;
    flex-shrink: 0;
  }
}

dialog.modal-xl {
  max-width: 1020px;
}

dialog.modal-confirm {
  width: 440px;
  max-width: 92vw;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: #ffffff;
  box-shadow: 0 25px 60px -12px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(15, 23, 42, 0.04);
  animation: confirmPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

dialog.modal-confirm::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

@keyframes confirmPop {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.confirm-dialog-content {
  position: relative;
  padding: 28px 24px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.confirm-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.confirm-close-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.confirm-icon-bubble {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #fff1f2;
  border: 1px solid #ffe4e6;
  color: #e11d48;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 2px;
  box-shadow: 0 0 0 6px rgba(244, 63, 94, 0.06);
}

.confirm-title {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  letter-spacing: -0.01em;
}

.confirm-message {
  font-size: 13.5px;
  color: #64748b;
  line-height: 1.5;
  margin: 0;
}

.confirm-item-badge {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  width: 100%;
  box-sizing: border-box;
}

.confirm-item-custom-html {
  width: 100%;
  box-sizing: border-box;
}

.confirm-sig-preview-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 16px;
  width: 100%;
  box-sizing: border-box;
}

.confirm-sig-thumb {
  width: 100%;
  height: 68px;
  background: #ffffff;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.confirm-sig-thumb img {
  max-height: 56px;
  max-width: 90%;
  object-fit: contain;
}

.confirm-sig-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12.5px;
  width: 100%;
}

.confirm-sig-role {
  font-weight: 600;
  color: #0f172a;
}

.confirm-sig-person {
  color: #64748b;
}

/* Confirm Loan Card Summary */
.confirm-loan-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 16px;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.confirm-loan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px dashed #cbd5e1;
}

.confirm-loan-id {
  font-family: var(--font-mono, monospace);
  font-size: 13.5px;
  font-weight: 700;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 2px 8px;
  border-radius: 6px;
}

.confirm-loan-badge {
  font-size: 11px;
  font-weight: 600;
  color: #d97706;
  background: #fef3c7;
  border: 1px solid #fde68a;
  padding: 2px 8px;
  border-radius: 9999px;
}

.confirm-loan-details {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  line-height: 1.45;
}

.confirm-loan-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.confirm-loan-label {
  color: #64748b;
  font-size: 12px;
  flex-shrink: 0;
  min-width: 52px;
}

.confirm-loan-val {
  color: #0f172a;
  word-break: break-word;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

.confirm-actions .btn {
  flex: 1;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
}

dialog.modal-fullscreen {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  border-radius: 0;
}

dialog.modal-fullscreen .modal-inner {
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.print-modal-header {
  display: flex;
  flex-direction: column;
  padding: 12px 22px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  gap: 10px;
  flex-shrink: 0;
  z-index: 10;
}

/* Minimal Luxury Atmosphere for Loan Dialog */
#loanDialog.modal-fullscreen {
  background: #f8fafc;
}

#loanDialog .modal-inner {
  background: #f8fafc;
}

#loanDialog .modal-header {
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
}

#loanDialog .modal-body {
  background: #f8fafc;
  position: relative;
}

#loanDialog .modal-footer {
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
}

.fullscreen-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.loan-card.clickable-card {
  cursor: pointer;
}

.card-tap-hint {
  font-size: 11px;
  color: var(--text-muted);
}

dialog.modal-dialog::backdrop {
  background-color: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-inner {
  display: flex;
  flex-direction: column;
  max-height: 92vh;
}

.modal-header {
  padding: 12px 20px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffff;
}

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

.modal-title-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.modal-title-group h2,
.modal-header h2 {
  font-size: 16.5px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  letter-spacing: -0.3px;
  line-height: 1.25;
}

.modal-title-group .modal-subtitle,
.modal-subtitle {
  margin: 2px 0 0 0;
  font-size: 11.5px;
  color: #64748b;
  font-weight: 500;
}

/* Beautiful iOS / macOS Back Button (Capsule Glass Pill) with Elastic Spring & Arrow Slide */
.btn-back-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  padding: 0 14px 0 9px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(203, 213, 225, 0.85);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: #1e293b;
  letter-spacing: -0.2px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.16s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: relative;
}

.btn-back-nav .back-arrow-icon {
  color: #007aff;
  flex-shrink: 0;
  display: inline-block;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.15s ease;
}

.btn-back-nav .back-text {
  font-size: 13.5px;
  font-weight: 600;
  color: #1e293b;
  letter-spacing: -0.2px;
  transition: color 0.15s ease;
}

.btn-back-nav:hover {
  background: #ffffff;
  border-color: #93c5fd;
  box-shadow: 0 3px 10px -1px rgba(0, 122, 255, 0.18), 0 1px 3px rgba(15, 23, 42, 0.06);
}

.btn-back-nav:hover .back-arrow-icon {
  transform: translateX(-3.5px);
  color: #0066cc;
}

.btn-back-nav:hover .back-text {
  color: #0066cc;
}

.btn-back-nav:active,
.btn-back-nav.btn-back-pressed {
  transform: scale(0.91) translateX(-2.5px) !important;
  background: rgba(241, 245, 249, 0.98) !important;
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 3.5px rgba(59, 130, 246, 0.22), inset 0 1.5px 3px rgba(0, 0, 0, 0.06) !important;
}

.btn-back-nav:active .back-arrow-icon,
.btn-back-nav.btn-back-pressed .back-arrow-icon {
  transform: translateX(-6px) scale(1.1) !important;
  color: #0066cc !important;
}

.btn-back-nav:active .back-text,
.btn-back-pressed .back-text {
  color: #0066cc !important;
}

/* Smooth Exit Animations across all dialogs */
dialog.dialog-closing {
  pointer-events: none !important;
}

/* Fullscreen Modals Slide Out Smoothly to the Right (iOS style navigation pop) */
dialog.modal-fullscreen .modal-inner {
  transition: transform 0.14s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.13s ease-out;
  will-change: transform, opacity;
}

dialog.modal-fullscreen.dialog-closing .modal-inner {
  transform: translateX(36px) scale(0.99) !important;
  opacity: 0 !important;
}

/* Floating/Standard Modals Pop Down & Fade */
dialog:not(.modal-fullscreen) {
  transition: transform 0.14s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.13s ease-out;
  will-change: transform, opacity;
}

dialog:not(.modal-fullscreen).dialog-closing {
  transform: translateY(18px) scale(0.96) !important;
  opacity: 0 !important;
}

/* Backdrop Fade Out */
dialog.dialog-closing::backdrop {
  opacity: 0 !important;
  transition: opacity 0.13s ease-out !important;
}

/* Ensure all closed dialogs never render any children or fixed footers */
dialog:not([open]),
dialog:not([open]) * {
  display: none !important;
}

/* Beautiful Minimal Close Button (Circle with soft hover) */
.btn-close-modal {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  outline: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-close-modal:hover {
  background: #e2e8f0;
  color: #0f172a;
  transform: scale(1.05);
}

.btn-close-modal:active {
  transform: scale(0.92);
  background: #cbd5e1;
}

.modal-body {
  padding: 16px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 12px 22px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.input-attention-ring {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25) !important;
  transition: all 0.2s ease;
}

/* ============================================================================
   COLLAPSIBLE TOP INFO ACCORDION (HEADER INFO DRAWER)
   ============================================================================ */
.loan-top-accordion {
  display: flex;
  flex-direction: column;
  width: 100%;
  border-radius: 16px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: visible;
}

.loan-top-accordion.is-open {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 10px 30px -6px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(0, 0, 0, 0.02);
}

.loan-top-summary-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.88);
  -webkit-backdrop-filter: blur(25px) saturate(190%);
  backdrop-filter: blur(25px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  box-shadow: 0 4px 18px -2px rgba(15, 23, 42, 0.05),
              0 1px 2px rgba(0, 0, 0, 0.02),
              inset 0 1px 0 rgba(255, 255, 255, 0.95);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  gap: 12px;
}

.loan-top-accordion.is-open .loan-top-summary-bar {
  border-radius: 16px 16px 0 0;
  border: none;
  border-bottom: 1px solid #f1f5f9;
  box-shadow: none;
  background: #ffffff;
  padding: 12px 18px;
}

.loan-top-summary-bar:hover {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(203, 213, 225, 0.8);
  box-shadow: 0 6px 22px -2px rgba(15, 23, 42, 0.08), inset 0 1px 0 #ffffff;
}

.loan-top-accordion.is-open .loan-top-summary-bar:hover {
  background: #ffffff;
  border-color: transparent;
  box-shadow: none;
}

.summary-bar-main {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  flex: 1;
}

.summary-avatar-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: rgba(0, 122, 255, 0.09);
  color: #007aff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.summary-bar-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.summary-bar-headline {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-bar-sub {
  font-size: 11.5px;
  color: #64748b;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-bar-badge {
  font-size: 12px;
  font-weight: 600;
  color: #007aff;
  background: rgba(0, 122, 255, 0.08);
  border: 1px solid rgba(0, 122, 255, 0.2);
  padding: 4px 11px;
  border-radius: 99px;
  flex-shrink: 0;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.summary-bar-badge.is-expanded {
  background: rgba(100, 116, 139, 0.1);
  color: #475569;
  border-color: rgba(100, 116, 139, 0.2);
}

.loan-top-summary-bar:hover .summary-bar-badge {
  background: rgba(0, 122, 255, 0.14);
}

.loan-top-drawer {
  display: flex;
  flex-direction: column;
  animation: slideDownDrawer 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: visible;
}

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

/* ============================================================================
   MINIMAL LUXURY DOCUMENT HEADER CARD (หัวเอกสารใบยืม — เรียบหรู MINIMAL SLEEK)
   ============================================================================ */
.loan-minimal-card {
  background: #ffffff;
  border: none;
  border-radius: 0 0 16px 16px;
  padding: 16px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: visible;
}

.minimal-panels {
  display: grid;
  grid-template-columns: 1.22fr 1fr;
  gap: 24px;
  align-items: stretch;
  overflow: visible;
}

.minimal-panel {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: visible;
}

.minimal-panel:first-child {
  position: relative;
  padding-right: 24px;
  border-right: 1px solid #f1f5f9;
}

.minimal-panel-title {
  font-size: 10.5px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.minimal-panel-title::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #007aff;
  opacity: 0.75;
}

.parties-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 9px 12px;
  overflow: visible;
}

.terms-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 12px;
  overflow: visible;
}

.minimal-panel .field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  position: relative;
}

.minimal-panel .field-group label {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  letter-spacing: 0.15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.minimal-panel input[type="text"],
.minimal-panel input[type="tel"] {
  height: 38px;
  min-height: 38px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  border-radius: 9px;
  padding: 0 11px;
  box-sizing: border-box;
  color: #0f172a;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.02);
}

.minimal-panel input[type="text"]:hover,
.minimal-panel input[type="tel"]:hover {
  border-color: #cbd5e1;
}

.minimal-panel input[type="text"]:focus,
.minimal-panel input[type="tel"]:focus {
  border-color: #007aff;
  background: #ffffff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.minimal-panel .custom-select-trigger {
  height: 38px;
  min-height: 38px;
  border-radius: 9px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.02);
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.minimal-panel .custom-select-trigger:hover {
  border-color: #cbd5e1;
}

.minimal-panel .custom-select-trigger:focus,
.minimal-panel .custom-select-trigger[aria-expanded="true"] {
  border-color: #007aff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.minimal-panel .agoda-single-date-box {
  height: 38px;
  min-height: 38px;
  border-radius: 9px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.02);
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.minimal-panel .agoda-single-date-box:hover {
  border-color: #cbd5e1;
}

.minimal-panel .agoda-single-date-box:focus {
  border-color: #007aff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.minimal-collapse-bar {
  display: flex;
  justify-content: center;
  padding-top: 6px;
  border-top: 1px solid #f8fafc;
  margin-top: 2px;
}

.btn-minimal-collapse {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 3px 14px;
  border-radius: 99px;
  transition: all 0.15s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-minimal-collapse:hover {
  color: #007aff;
  background: #f1f5f9;
}

@media (max-width: 768px) {
  .loan-minimal-card {
    padding: 12px 14px 10px;
  }
  .minimal-panels {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .minimal-panel:first-child {
    padding-right: 0;
    border-right: none;
    padding-bottom: 14px;
    border-bottom: 1px solid #f1f5f9;
  }
  .parties-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .terms-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}

.top-drawer-actions {
  display: flex;
  justify-content: center;
  padding-top: 2px;
}

.top-drawer-actions .btn {
  font-size: 12.5px;
  padding: 6px 14px;
}

.footer-right-btns {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-right-btns .btn {
  height: 38px;
  min-height: 38px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  transition: all 0.15s ease;
}

.footer-right-btns .btn-secondary {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.footer-right-btns .btn-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.footer-right-btns .btn-primary {
  background: #007aff;
  border: 1px solid #007aff;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.22);
}

.footer-right-btns .btn-primary:hover {
  background: #0066d6;
  border-color: #0066d6;
}

.btn-cancel-modal {
  height: 38px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  padding: 0 14px;
  transition: all 0.15s ease;
}

.btn-cancel-modal:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.form-grid-5 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px 12px;
}

.field-group.span-2-desktop {
  grid-column: span 2;
}

.field-group-date {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.date-outer-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.req { color: var(--danger); }

.field-group input,
.field-group select {
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
}

/* Custom Select Component (Touch & Mobile Friendly, replaces clunky OS popup) */
.custom-select-wrap {
  position: relative;
  width: 100%;
}

.custom-select-trigger {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  background: #f8fafc;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  color: #0f172a;
  text-align: left;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.custom-select-trigger:hover,
.custom-select-trigger:focus {
  background: #ffffff;
  border-color: #3b82f6;
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.custom-select-val {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.custom-select-arrow {
  color: #64748b;
  font-size: 12px;
  flex-shrink: 0;
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  min-width: 250px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 16px 36px -4px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(226, 232, 240, 0.8);
  z-index: 100000;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.custom-select-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease;
  gap: 10px;
}

.custom-select-item:hover {
  background: #f1f5f9;
}

.custom-select-item.active {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.custom-select-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.custom-select-item-text .item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
}

.custom-select-item.active .item-title {
  color: #1d4ed8;
}

.custom-select-item-text .item-desc {
  font-size: 11.5px;
  color: #64748b;
}

.custom-select-item .item-check {
  font-size: 15px;
  font-weight: 700;
  color: #2563eb;
  opacity: 0;
}

.custom-select-item.active .item-check {
  opacity: 1;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.date-bar {
  background: transparent;
  padding: 0;
  border-radius: 0;
  display: flex;
  align-items: center;
  width: 100%;
}

/* Agoda Single Date Input Trigger Box (Matches 1-column input fields exactly) */
.agoda-single-date-box {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  height: 38px;
  padding: 0 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  user-select: none;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 13.5px;
  color: #0f172a;
}

.agoda-single-date-box:hover {
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12), 0 1px 3px rgba(15, 23, 42, 0.06);
}

.agoda-single-date-box:focus-visible {
  outline: none;
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.25);
}

.agoda-single-date-box .date-box-icon {
  font-size: 13.5px;
  line-height: 1;
  flex-shrink: 0;
}

.agoda-single-date-box .date-box-val {
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
  letter-spacing: -0.2px;
  font-variant-numeric: tabular-nums;
  flex: 1;
  text-align: left;
}

.agoda-single-date-box .agoda-range-days-pill {
  font-size: 10.5px;
  font-weight: 700;
  color: #007aff;
  background: rgba(0, 122, 255, 0.1);
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Agoda Date Range Picker Trigger Card (Minimal & Sleek, matching 38px inputs) */
.agoda-range-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  height: 38px;
  padding: 0 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  user-select: none;
  width: 100%;
  box-sizing: border-box;
}

.agoda-range-card:hover {
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12), 0 1px 3px rgba(15, 23, 42, 0.06);
}

.agoda-range-card:focus-visible {
  outline: none;
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.25);
}

.agoda-range-dates-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.agoda-range-dates-wrap .agoda-seg-icon {
  font-size: 13.5px;
  line-height: 1;
}

.agoda-range-dates-wrap .agoda-seg-date {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.2px;
  font-variant-numeric: tabular-nums;
}

.agoda-range-dates-wrap .agoda-range-arrow {
  font-size: 11px;
  color: #94a3b8;
  margin: 0 2px;
}

.agoda-range-days-pill {
  font-size: 11px;
  font-weight: 700;
  color: #007aff;
  background: rgba(0, 122, 255, 0.1);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.agoda-range-arrow {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1;
}

/* Modal Agoda Range Dialog */
.modal-agoda-range {
  padding: 0;
  border: none;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.08);
  background: #ffffff;
  max-width: 440px;
  width: 92vw;
  overflow: hidden;
}

.modal-agoda-range::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.agoda-date-content {
  display: flex;
  flex-direction: column;
  padding: 18px 20px 20px 20px;
}

.agoda-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.agoda-cal-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.btn-close-agoda-modal {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(241, 245, 249, 0.95);
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}

.btn-close-agoda-modal:hover {
  background: #e2e8f0;
  color: #0f172a;
  transform: scale(1.05);
}

.btn-close-agoda-modal:active {
  transform: scale(0.92);
}

/* Modal Range Bar */
.agoda-modal-range-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.agoda-m-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.agoda-m-box.end {
  text-align: right;
  align-items: flex-end;
}

.agoda-m-box .m-box-lbl {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
}

.agoda-m-box .m-box-val {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
}

.agoda-m-box.is-picking .m-box-lbl {
  color: #007aff;
}

.agoda-m-box.is-picking .m-box-val {
  color: #007aff;
}

.agoda-m-duration {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: #007aff;
  background: rgba(0, 122, 255, 0.1);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Quick Chips inside modal */
.agoda-cal-quick-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.btn-agoda-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-agoda-chip:hover {
  border-color: #007aff;
  background: rgba(0, 122, 255, 0.08);
  color: #007aff;
}

/* Calendar Navigation */
.agoda-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 4px;
}

.agoda-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #334155;
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.agoda-nav-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

.agoda-current-month-label {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

/* Weekday header */
.agoda-weekdays-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 6px;
}

.agoda-weekdays-grid .weekend {
  color: #ef4444;
}

/* Days Grid */
.agoda-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-gap: 4px;
  margin-bottom: 16px;
}

.agoda-day-cell {
  height: 40px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.agoda-day-cell.is-empty {
  cursor: default;
  pointer-events: none;
}

.agoda-day-cell .day-inner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13.5px;
  font-weight: 600;
  color: #1e293b;
  z-index: 2;
  transition: all 0.15s ease;
  position: relative;
}

.agoda-day-cell:hover .day-inner {
  background: #e2e8f0;
}

.agoda-day-cell.is-today .day-inner {
  border: 1.5px solid #007aff;
  color: #007aff;
}

/* Range Start & End (Agoda Capsule) - Draggable handles */
.agoda-day-cell.is-range-start,
.agoda-day-cell.is-range-end {
  cursor: grab;
  touch-action: none;
}

.agoda-day-cell.is-range-start:active,
.agoda-day-cell.is-range-end:active,
.agoda-day-cell.is-dragging {
  cursor: grabbing;
}

.agoda-day-cell.is-range-start .day-inner,
.agoda-day-cell.is-range-end .day-inner {
  background: #007aff !important;
  color: #ffffff !important;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 122, 255, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.agoda-day-cell.is-range-start:active .day-inner,
.agoda-day-cell.is-range-end:active .day-inner,
.agoda-day-cell.is-dragging .day-inner {
  transform: scale(1.14);
  box-shadow: 0 5px 14px rgba(0, 122, 255, 0.45);
  background: #0062cc !important;
  z-index: 10;
}

/* Agoda Range Connecting Bands */
.agoda-day-cell.is-range-start::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: 50%;
  background: rgba(0, 122, 255, 0.15);
  z-index: 1;
}

.agoda-day-cell.is-range-end::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 50%;
  background: rgba(0, 122, 255, 0.15);
  z-index: 1;
}

.agoda-day-cell.is-range-start.is-range-end::after {
  display: none;
}

.agoda-day-cell.is-in-range {
  background: rgba(0, 122, 255, 0.15);
}

.agoda-day-cell.is-in-range .day-inner {
  color: #007aff;
  font-weight: 700;
}

.agoda-day-cell.is-hover-range {
  background: rgba(0, 122, 255, 0.09);
}

.agoda-day-cell.is-hover-range .day-inner {
  color: #0284c7;
}

.agoda-day-cell:nth-child(7n + 1).is-in-range {
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}

.agoda-day-cell:nth-child(7n).is-in-range {
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

/* Footer */
.agoda-cal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
}

.agoda-cal-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-date-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 2px 8px 2px;
  gap: 10px;
}

.section-title-row h3 {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.section-title-row h3::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #007aff;
  opacity: 0.75;
}

.muted-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* Proof & Signature */
.proof-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.proof-box {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  background: #f8fafc;
}

.highlight-proof-box {
  border-color: #93c5fd;
  background: #f0f7ff;
}

.proof-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.proof-header h4 { font-size: 13px; font-weight: 700; }
.proof-header p { font-size: 11.5px; color: var(--text-muted); }

.photo-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 70px;
  align-items: center;
}

.photo-thumb {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: #fff;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
}

.sig-pad-wrap {
  background: #fff;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
}

#signatureCanvas {
  width: 100%;
  height: 90px;
  touch-action: none;
  cursor: crosshair;
}

/* ============================================================================
   RETURN & QC CHECKLIST
   ============================================================================ */
.return-items-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qc-item-card {
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qc-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.qc-item-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.qc-status-toggle {
  display: flex;
  gap: 6px;
}

.qc-radio-btn {
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.qc-radio-btn.pass.active { background: var(--success); color: #fff; border-color: var(--success); }
.qc-radio-btn.fail.active { background: var(--danger); color: #fff; border-color: var(--danger); }

.qc-acc-section {
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 8px;
}

.qc-acc-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.qc-tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.qc-tag-pill {
  border: 1px solid var(--emerald-border);
  background: var(--emerald-bg);
  color: var(--emerald-text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.qc-tag-pill.missing {
  background: var(--rose-bg);
  border-color: var(--rose-border);
  color: var(--rose-text);
  text-decoration: line-through;
}

.qc-destination-banner {
  padding: 8px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
}

.qc-destination-banner.dest-pass {
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  color: var(--emerald-text);
}

.qc-destination-banner.dest-fail {
  background: var(--rose-bg);
  border: 1px solid var(--rose-border);
  color: var(--rose-text);
}

.receiver-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.receiver-input-wrap input {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-family: inherit;
}

/* ============================================================================
   PRINT PREVIEW & GATE PASS SLIP (HIDES LOCATION FROM CUSTOMER)
   ============================================================================ */
.print-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.print-size-toggle {
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.print-size-toggle select {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  font-family: inherit;
}

/* Fullscreen Print Dialog & Gate Pass Sheet */
/* ============================================================================
   PRINT DIALOG / GATE PASS EXECUTIVE NAVBAR (Minimal Luxury)
   ============================================================================ */
.print-modal-header {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  height: 52px !important;
  min-height: 52px !important;
  padding: 0 20px !important;
  background: #ffffff !important;
  border-bottom: 1px solid #e2e8f0 !important;
  gap: 14px !important;
  flex-shrink: 0 !important;
  position: relative !important;
  z-index: 20 !important;
  box-sizing: border-box !important;
}

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

.btn-navbar-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.16s ease, color 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-navbar-back svg {
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.15s ease;
}

.btn-navbar-back:hover {
  background: #f1f5f9;
  color: #007aff;
}

.btn-navbar-back:hover svg {
  transform: translateX(-3.5px);
  color: #007aff;
}

.btn-navbar-back:active,
.btn-navbar-back.btn-back-pressed {
  transform: scale(0.91) translateX(-2.5px) !important;
  background: #e2e8f0 !important;
  border-color: #93c5fd !important;
  box-shadow: 0 0 0 3.5px rgba(59, 130, 246, 0.22) !important;
  color: #0066cc !important;
}

.btn-navbar-back:active svg,
.btn-navbar-back.btn-back-pressed svg {
  transform: translateX(-5.5px) scale(1.1) !important;
  color: #0066cc !important;
}

.print-nav-divider {
  width: 1px;
  height: 18px;
  background: #e2e8f0;
}

.print-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.print-nav-title {
  font-size: 14.5px;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.print-loan-badge {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.print-navbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.print-stage-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-navbar-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #334155;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.btn-navbar-icon-only {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 8px !important;
  flex-shrink: 0 !important;
}

.btn-navbar-back.btn-navbar-icon-only {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  border-radius: 50% !important;
  border: 1px solid rgba(203, 213, 225, 0.85) !important;
  background: #ffffff !important;
  color: #64748b !important;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
}

.btn-navbar-back.btn-navbar-icon-only:hover {
  background: #ffffff !important;
  color: #007aff !important;
  border-color: #93c5fd !important;
  box-shadow: 0 3px 8px -1px rgba(0, 122, 255, 0.2), 0 1px 3px rgba(15, 23, 42, 0.08) !important;
}

.btn-navbar-back.btn-navbar-icon-only:hover svg {
  transform: translateX(-3.5px) !important;
  color: #007aff !important;
}

.btn-navbar-back.btn-navbar-icon-only:active,
.btn-navbar-back.btn-navbar-icon-only.btn-back-pressed {
  transform: scale(0.90) translateX(-2.5px) !important;
  background: #f1f5f9 !important;
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 3.5px rgba(59, 130, 246, 0.25) !important;
}

.btn-navbar-back.btn-navbar-icon-only:active svg,
.btn-navbar-back.btn-navbar-icon-only.btn-back-pressed svg {
  transform: translateX(-5.5px) scale(1.12) !important;
  color: #0066cc !important;
}

.btn-navbar-action svg {
  flex-shrink: 0;
  color: #64748b;
  transition: color 0.15s ease;
}

.btn-navbar-edit {
  background: #fffbeb !important;
  color: #b45309 !important;
  border: 1px solid #fde68a !important;
  font-weight: 600 !important;
  padding: 0 10px !important;
  height: 32px !important;
  border-radius: 8px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
}

.btn-navbar-edit:hover {
  background: #fef3c7 !important;
  border-color: #fcd34d !important;
}

.btn-navbar-edit svg {
  color: #b45309;
}

.btn-navbar-deliver {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  border: 1px solid #93c5fd !important;
  font-weight: 600 !important;
  padding: 0 10px !important;
  height: 32px !important;
  border-radius: 8px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
}

.btn-navbar-deliver:hover {
  background: #dbeafe !important;
  border-color: #60a5fa !important;
}

.btn-navbar-deliver svg {
  color: #2563eb !important;
}

.btn-navbar-return {
  background: #f0fdf4 !important;
  color: #15803d !important;
  border: 1px solid #86efac !important;
  font-weight: 600 !important;
  padding: 0 10px !important;
  height: 32px !important;
  border-radius: 8px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
}

.btn-navbar-return:hover {
  background: #dcfce7 !important;
  border-color: #4ade80 !important;
}

.btn-navbar-return svg {
  color: #16a34a !important;
}

.btn-company-settings svg {
  color: #4f46e5;
}

.btn-send-email {
  color: #0f172a;
}

.btn-send-email svg {
  color: #2563eb;
}

/* ============================================================================
   SEND EMAIL MODAL (Luxury & Streamlined)
   ============================================================================ */
dialog.modal-send-email {
  width: 500px;
  max-width: 95vw;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: #ffffff;
  box-shadow: 0 25px 60px -12px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(15, 23, 42, 0.04);
}

.send-email-card {
  padding: 18px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.send-email-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
}

.send-email-body .form-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
}

.send-email-body .form-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.send-email-body .form-row .flex-1 {
  flex: 1;
  min-width: 0;
}

.send-email-body .form-control {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  color: #0f172a;
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.send-email-body .form-control:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.send-email-body .form-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #475569;
  margin: 0;
}

.label-with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.btn-icon-minimal {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.btn-icon-minimal:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.email-body-textarea {
  font-family: inherit;
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
  min-height: 80px;
  max-height: 180px;
  background: #f8fafc;
  color: #1e293b;
}

/* ============================================================================
   AUTOMATIC PDF ATTACHMENT CARD (Minimal & Streamlined)
   ============================================================================ */
.email-attachment-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 7px 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.attachment-icon-wrap {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: #fee2e2;
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.attachment-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.attachment-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}

.attachment-filename {
  font-size: 12.5px;
  font-weight: 600;
  color: #0f172a;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-tag {
  font-size: 10px;
  font-weight: 600;
  color: #166534;
  background: #dcfce7;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-attachment-preview.btn-icon-only {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-attachment-preview.btn-icon-only:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

/* Status Banner */
.email-status-banner {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.email-status-banner.loading {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.email-status-banner.success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
}

.email-status-banner.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.status-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #93c5fd;
  border-top-color: #1d4ed8;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

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

/* Footer & Action Buttons */
.send-email-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.email-footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.email-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon-round {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-email-setting {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #475569;
}

.btn-email-setting:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #94a3b8;
}

.btn-gmail-compose {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #e11d48;
}

.btn-gmail-compose:hover {
  background: #ffe4e6;
  color: #be123c;
  border-color: #fda4af;
}

.btn-direct-send {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  border: 1px solid #1d4ed8;
  color: #ffffff;
  padding: 6px 14px;
  height: 34px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.2);
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  white-space: nowrap;
}

.btn-direct-send:hover {
  background: linear-gradient(180deg, #1d4ed8 0%, #1e40af 100%);
  transform: translateY(-0.5px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.btn-direct-send:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

/* Mobile Responsive Optimization for Send Email Modal */
@media (max-width: 640px) {
  dialog.modal-send-email {
    width: calc(100vw - 20px) !important;
    max-width: 390px !important;
    border-radius: 14px !important;
    margin: auto !important;
  }
  .send-email-card {
    padding: 13px 12px 11px !important;
    gap: 8px !important;
  }
  .send-email-body {
    gap: 7px !important;
  }
  .send-email-body .form-row {
    gap: 6px !important;
  }
  .send-email-body .form-control {
    padding: 6px 9px !important;
    font-size: 12.5px !important;
  }
  .email-body-textarea {
    min-height: 65px !important;
    max-height: 100px !important;
    font-size: 11.5px !important;
  }
  .email-attachment-card {
    padding: 6px 9px !important;
    gap: 8px !important;
  }
  .attachment-icon-wrap {
    width: 26px !important;
    height: 26px !important;
    border-radius: 6px !important;
  }
  .attachment-icon-wrap svg {
    width: 15px !important;
    height: 15px !important;
  }
  .attachment-filename {
    font-size: 11.5px !important;
  }
  .attachment-tag {
    font-size: 9.5px !important;
    padding: 1px 4px !important;
  }
  .btn-attachment-preview.btn-icon-only {
    width: 26px !important;
    height: 26px !important;
    border-radius: 6px !important;
  }
  .send-email-footer {
    padding-top: 8px !important;
    gap: 6px !important;
  }
  .btn-email-close {
    padding: 4px 8px !important;
    font-size: 11.5px !important;
    height: 30px !important;
  }
  .btn-icon-round {
    width: 30px !important;
    height: 30px !important;
    border-radius: 7px !important;
  }
  .btn-icon-round svg {
    width: 14px !important;
    height: 14px !important;
  }
  .btn-direct-send {
    padding: 4px 10px !important;
    font-size: 12px !important;
    height: 30px !important;
    gap: 4px !important;
  }
  .btn-direct-send svg {
    width: 13px !important;
    height: 13px !important;
  }
}

/* ============================================================================
   SMTP SETTINGS IN COMPANY MODAL
   ============================================================================ */
.smtp-settings-section {
  border-top: 1px solid #e2e8f0;
  padding-top: 16px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.smtp-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.smtp-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 650;
  color: #0f172a;
}

.smtp-header-title svg {
  color: #2563eb;
}

.smtp-badge {
  font-size: 11px;
  font-weight: 600;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 2px 8px;
  border-radius: 5px;
}

/* Email Provider Tabs / Segmented Buttons */
.email-provider-tabs {
  display: flex;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
  gap: 4px;
}

.provider-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.provider-tab:hover {
  color: #1e293b;
}

.provider-tab.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.provider-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.provider-panel.hidden {
  display: none !important;
}

.font-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !important;
  font-size: 12.5px;
  letter-spacing: 0.2px;
}

.api-actions-row {
  display: flex;
  gap: 8px;
}

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

.input-password-wrap .form-control {
  padding-right: 36px;
}

.btn-toggle-pwd {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  color: #64748b;
  opacity: 0.8;
  transition: opacity 0.15s ease;
}

.btn-toggle-pwd:hover {
  opacity: 1;
}

.btn-test-smtp {
  width: 100%;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 550;
  border-radius: 7px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-test-smtp:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.smtp-status-box {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
}

.smtp-status-box.loading {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.smtp-status-box.success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
}

.smtp-status-box.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.smtp-guide-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 11.5px;
  color: #475569;
  line-height: 1.45;
}

.smtp-guide-note a {
  color: #2563eb;
  text-decoration: underline;
  font-weight: 500;
}

.btn-gmail-compose {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #dc2626;
  border-color: #fca5a5;
  background: #ffffff;
}

.btn-gmail-compose:hover {
  background: #fef2f2;
  border-color: #f87171;
  color: #b91c1c;
}

.btn-launch-mail {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}

.btn-launch-mail:hover {
  background: #1e293b;
  border-color: #1e293b;
}

.btn-navbar-action:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
  transform: translateY(-0.5px);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.05);
}

.btn-navbar-action:hover svg {
  color: #0f172a;
}

.btn-navbar-badge-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.btn-navbar-badge-action svg {
  flex-shrink: 0;
}

.btn-badge-purple {
  background: #faf5ff;
  color: #7c3aed;
  border: 1px solid #ddd6fe;
}

.btn-badge-purple svg {
  color: #7c3aed;
}

.btn-badge-purple:hover {
  background: #ede9fe;
  border-color: #c4b5fd;
  color: #6d28d9;
  transform: translateY(-0.5px);
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.14);
}

.btn-badge-blue {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.btn-badge-blue svg {
  color: #2563eb;
}

.btn-badge-blue:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
  transform: translateY(-0.5px);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.14);
}

.btn-badge-green {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.btn-badge-green svg {
  color: #16a34a;
}

.btn-badge-green:hover {
  background: #dcfce7;
  border-color: #86efac;
  color: #15803d;
  transform: translateY(-0.5px);
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.14);
}

.print-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.print-select-lead-icon {
  position: absolute;
  left: 9px;
  pointer-events: none;
  color: #64748b;
  transition: color 0.15s ease;
  z-index: 2;
}

.print-select-input {
  appearance: none;
  -webkit-appearance: none;
  background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 8px center;
  padding: 5px 24px 5px 28px;
  border-radius: 7px;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.print-select-input:hover {
  border-color: #cbd5e1;
  color: #0f172a;
}

.print-select-wrap:hover .print-select-lead-icon {
  color: #0f172a;
}

.print-select-input:focus {
  border-color: #0f172a;
}

/* Print Size Custom Dropdown Trigger */
.print-size-custom-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.btn-print-size-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px 0 8px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  white-space: nowrap;
}

.btn-print-size-trigger:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-print-size-trigger.is-active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}

.print-size-lead-icon {
  color: #2563eb;
  flex-shrink: 0;
}

.print-size-dropdown-arrow {
  color: #64748b;
  font-size: 11px;
  margin-left: 2px;
}

/* Custom Dropdown Menu for Print Layout */
.print-size-dropdown {
  position: fixed;
  width: 380px;
  max-width: calc(100vw - 20px);
  z-index: 9999999 !important;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(25px) saturate(190%);
  backdrop-filter: blur(25px) saturate(190%);
  border: 1px solid rgba(203, 213, 225, 0.8);
  border-radius: 14px;
  box-shadow: 0 20px 45px -5px rgba(15, 23, 42, 0.22), 0 10px 15px -5px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.print-size-dropdown .dropdown-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.print-size-dropdown .dropdown-header-title {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 6px;
}

.print-size-dropdown .dropdown-header-count {
  font-size: 10.5px;
  font-weight: 600;
  color: #64748b;
  background: #e2e8f0;
  padding: 1px 6px;
  border-radius: 4px;
}

.print-size-dropdown .dropdown-scroll-list {
  padding: 4px 0;
  max-height: 380px;
  overflow-y: auto;
}

.print-size-opt-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: all 0.12s ease;
  user-select: none;
}

.print-size-opt-item:last-child {
  border-bottom: none;
}

.print-size-opt-item:hover {
  background: #f8fafc;
}

.print-size-opt-item.is-selected {
  background: #eff6ff;
  border-left: 3.5px solid #2563eb;
}

.print-opt-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.print-opt-name {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.print-opt-sub {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
  line-height: 1.35;
}

.print-opt-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.3;
  white-space: nowrap;
}

.badge-recommended {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.badge-eco {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.badge-photo {
  background: #faf5ff;
  color: #7c3aed;
  border: 1px solid #e9d5ff;
}

.badge-single, .badge-compact {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.print-opt-check {
  color: #2563eb;
  font-weight: 800;
  font-size: 14px;
  margin-left: 8px;
  flex-shrink: 0;
}

.badge-mode-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 550;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 4px 9px;
  border-radius: 6px;
  white-space: nowrap;
}

.badge-mode-tag svg {
  flex-shrink: 0;
}

.badge-mode-tag.mode-dual {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.badge-mode-tag.mode-dual svg {
  color: #16a34a;
}

.badge-mode-tag.mode-full {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.badge-mode-tag.mode-full svg {
  color: #2563eb;
}

.btn-navbar-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 15px;
  border-radius: 7px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: #ffffff;
  border: 1px solid #0f172a;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.16), 0 1px 2px rgba(15, 23, 42, 0.08);
  white-space: nowrap;
}

.btn-navbar-primary svg {
  flex-shrink: 0;
}

.btn-navbar-primary:hover {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  border-color: #1e293b;
  transform: translateY(-0.5px);
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.22);
}

.btn-navbar-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  padding: 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.btn-navbar-close svg {
  color: #64748b;
  transition: color 0.15s ease;
}

.btn-navbar-close:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fecaca;
  transform: scale(1.05);
}

.btn-navbar-close:hover svg {
  color: #dc2626;
}

.btn-navbar-close-mobile {
  display: none; /* Only shown on mobile */
}

.btn-print-zoom-toggle,
.print-zoom-segmented {
  display: none; /* Only shown on mobile */
}

.print-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.print-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.print-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.print-mobile-footer {
  display: none; /* Hidden on desktop */
}

.print-preview-scroll {
  background: #f1f5f9;
  padding: 24px 32px 48px 32px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start !important;
  align-items: center;
  flex: 1;
  overflow-y: auto;
}

.print-scale-viewport {
  width: 100%;
  max-width: 860px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin: 0 auto;
  position: relative;
}

.fullscreen-sheet-wrap {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
}

.gate-pass-sheet {
  background: #fff;
  color: #0f172a;
  width: 100%;
  padding: 28px 36px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  font-size: 14px;
  box-sizing: border-box;
}

.gate-pass-sheet.size-half {
  padding: 9mm 12mm;
  font-size: 12px;
}

.gp-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  border-bottom: 1.5px solid #0f172a;
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.gp-header-issuer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.gp-issuer-top-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gp-issuer-logo-box {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.gp-issuer-logo {
  max-height: 38px;
  max-width: 130px;
  object-fit: contain;
  display: block;
}

.gp-issuer-brand-block {
  display: flex;
  flex-direction: column;
  gap: 1.5px;
}

.gp-issuer-brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.gp-issuer-name-th {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.gp-issuer-name-en {
  font-size: 10px;
  font-weight: 500;
  color: #64748b;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.gp-issuer-meta-tax {
  font-size: 10px;
  color: #475569;
  line-height: 1.3;
}

.gp-issuer-bottom-details {
  display: flex;
  flex-direction: column;
  gap: 1.5px;
  font-size: 10px;
  color: #64748b;
  line-height: 1.35;
  width: 100%;
  margin-top: 2px;
}

.gp-issuer-meta-tax {
  color: #475569;
}

.gp-issuer-address {
  color: #64748b;
}

.gp-issuer-contact {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  row-gap: 2px;
  color: #64748b;
  font-size: 10px;
}

.gp-contact-item {
  display: inline-flex;
  align-items: center;
  gap: 3.5px;
  line-height: 1;
}

.gp-contact-icon {
  width: 10.5px;
  height: 10.5px;
  flex-shrink: 0;
  color: #64748b;
  stroke-width: 2;
  display: inline-block;
  vertical-align: middle;
}

.gp-bullet {
  color: #cbd5e1;
  font-size: 8px;
  line-height: 1;
}

.gp-header-doc {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  flex-shrink: 0;
}

.gp-doc-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.gp-title {
  font-size: 15.5px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
}

.gp-sheet-badge {
  font-size: 9.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}

.gp-sheet-badge.original {
  background: #0f172a;
  color: #ffffff;
}

.gp-sheet-badge.copy {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.gp-meta-block-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 6px;
}

.gp-doc-qr-wrap {
  width: 50px;
  height: 50px;
  padding: 2.5px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
}

.gp-doc-qr-wrap svg {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.gp-meta-table {
  display: flex;
  flex-direction: column;
  gap: 2.5px;
  margin-top: 0;
}

.gp-meta-row {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 10px;
  font-size: 11px;
  line-height: 1.35;
}

.gp-meta-lbl {
  color: #64748b;
  font-weight: 400;
  text-align: right;
}

.gp-meta-val {
  color: #0f172a;
  font-weight: 600;
  text-align: right;
  min-width: 82px;
}

.gp-meta-val.gp-meta-id {
  font-family: inherit;
  letter-spacing: 0.02em;
}

.gp-meta-val.gp-meta-due {
  color: #dc2626;
  font-weight: 700;
}

.gp-phone { font-size: 11px; color: #475569; }

.gp-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 24px;
  margin-bottom: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
}

.gp-info-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.gp-info-lbl {
  color: #64748b;
  font-weight: 500;
  white-space: nowrap;
  font-size: 11.5px;
}

.gp-info-val {
  color: #0f172a;
  font-weight: 600;
  font-size: 12px;
}

.gp-table-wrap {
  width: 100%;
  margin-bottom: 8px;
  overflow-x: auto;
}

.gp-table {
  width: 100% !important;
  table-layout: auto !important;
  border-collapse: collapse !important;
  margin-bottom: 0;
}

.gp-table th,
.gp-table td {
  border: 1px solid #94a3b8;
  padding: 4.5px 7px;
  font-size: 11.5px;
  line-height: 1.3;
}

.gp-table th {
  background: #f1f5f9;
  font-weight: 700;
  color: #1e293b;
  text-align: center !important;
}

.gp-th-idx, .gp-td-idx {
  width: 34px !important;
  min-width: 34px !important;
  white-space: nowrap !important;
  text-align: center !important;
}

.gp-th-sn, .gp-td-sn {
  min-width: 120px !important;
  white-space: nowrap !important;
  text-align: center !important;
}

.gp-sn-code {
  font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  font-size: 11px;
  color: #0f172a;
  background: transparent !important;
  padding: 0 !important;
  border: none !important;
  display: inline-block;
  text-align: center;
}

.gp-sn-pending {
  color: #64748b;
  font-style: italic;
  font-size: 10.5px;
}

.gp-th-model {
  min-width: 140px;
  text-align: center !important;
}

.gp-td-model {
  min-width: 140px;
  text-align: left;
}

.gp-th-acc {
  min-width: 150px;
  text-align: center !important;
}

.gp-td-acc {
  min-width: 150px;
  text-align: left;
}

.gp-th-note {
  min-width: 130px;
  text-align: center !important;
}

.gp-td-note {
  min-width: 130px;
  text-align: center;
  word-break: break-word;
}

.gp-ret-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  padding: 2px 7px;
  border-radius: 4px;
  margin-bottom: 3px;
}

.gp-ret-tag.gp-ret-returned {
  color: #15803d;
  background-color: #dcfce7;
  border: 1px solid #bbf7d0;
}

.gp-ret-tag.gp-ret-pending {
  color: #b91c1c;
  background-color: #fee2e2;
  border: 1px solid #fecaca;
}

.gp-note-free {
  font-size: 11px;
  color: #334155;
  margin-top: 2px;
}

.gp-note-qc {
  font-size: 10.5px;
  color: #b45309;
  margin-top: 2px;
}

.gp-acc-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 1px 8px 1px 0 !important;
  font-size: 10.5px;
  line-height: 1.35;
  color: #1e293b;
  white-space: nowrap;
}

.gp-att-chip {
  display: inline-block;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  border-radius: 3px;
  padding: 0.5px 4px;
  font-size: 9.5px;
}

.gp-photos-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.gp-photos-row img {
  height: 75px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
}

.gp-terms-notice {
  font-size: 11.5px;
  color: #334155;
  margin-top: 8px;
}

.gp-signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 18px;
  text-align: center;
}

.gp-sig-box {
  padding-top: 0;
  margin-top: 8px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gp-sig-slot {
  min-height: 44px;
  height: 44px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  margin-bottom: 2px;
}

.gp-sig-line {
  width: 82%;
  max-width: 170px;
  border-bottom: 1px dashed #64748b;
  margin: 0 auto 6px;
}

.gp-sig-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.gp-sig-preview-wrap {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 0;
}

.gp-sig-preview-wrap .gp-sig-img {
  position: static;
  transform: none;
  max-height: 44px;
  max-width: 140px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.gp-sig-hover-actions {
  display: flex;
  gap: 4px;
  position: absolute;
  top: -8px;
  right: -24px;
  opacity: 0.85;
}

.gp-sig-preview-wrap:hover .gp-sig-hover-actions {
  opacity: 1;
}

.btn-sig-icon-action {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 10px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.btn-sig-icon-action:hover {
  background: #f1f5f9;
}

.btn-sig-icon-action.btn-sig-clear:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #ef4444;
}

.gp-sig-time {
  font-size: 10px;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  margin-bottom: 4px;
  font-weight: 500;
}

.btn-open-signature {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 500;
  color: #475569;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 4px;
}

.btn-open-signature:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.gp-sig-line-print {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 4px;
}

.gp-sig-role {
  font-weight: 700;
  color: #0f172a;
}

.gp-sig-name,
.gp-sig-date {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.gp-sig-img {
  max-height: 44px;
}

/* Dual Sheet Layout for A4 2-in-1 (Original + Copy) */
.gate-pass-dual-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.gp-half-slot {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Full Pair Layout for A4 (2 Pages: Original + Copy) */
.gate-pass-full-pair-wrapper {
  display: flex;
  flex-direction: column;
  gap: 28px;
  width: 100%;
  align-items: center;
}

.gp-page-sheet {
  width: 100%;
  max-width: 820px;
  position: relative;
}

.gp-page-indicator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  padding: 4px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.badge-mode-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
}

.badge-mode-tag.mode-full {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.badge-mode-tag.mode-dual {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.gate-pass-sheet.size-dual {
  padding: 20px 28px 24px 28px;
  font-size: 12px;
  border-radius: 12px;
  position: relative;
}

.gp-sheet-badge-strip {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.gp-sheet-badge {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 3px 12px;
  border-radius: 14px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.gp-sheet-badge.original {
  background: #0f172a;
  color: #ffffff;
}

.gp-sheet-badge.copy {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.gp-perforation-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 8px 0;
}

.gp-perf-line {
  flex: 1;
  border-top: 1.5px dashed #94a3b8;
}

.gp-perf-label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  background: #f8fafc;
  padding: 3px 12px;
  border-radius: 12px;
  border: 1px dashed #cbd5e1;
  white-space: nowrap;
}

/* Digital Signature Modal (Minimal, Clean & Landscape Fullscreen on Mobile) */
.modal-signature {
  max-width: 560px;
  width: 92vw;
  border-radius: 16px;
  padding: 0;
  border: 1px solid #e2e8f0;
  box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.18);
  background: #ffffff;
  overflow: hidden;
}

.signature-modal-card {
  padding: 20px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
}

.sig-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.sig-title-text {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  letter-spacing: -0.01em;
}

.sig-subtitle-text {
  font-size: 12.5px;
  color: #64748b;
  margin: 2px 0 0;
  font-weight: 500;
}

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

.btn-toggle-sig-orient {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-toggle-sig-orient:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.signature-modal-body {
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sig-mode-tabs {
  display: flex;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 3px;
  gap: 4px;
}

.sig-tab-btn {
  flex: 1;
  padding: 7px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sig-tab-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.sig-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sig-canvas-wrap {
  position: relative;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  overflow: hidden;
  touch-action: none;
  height: 230px;
  transition: border-color 0.15s ease;
}

.sig-canvas-wrap.is-drawing,
.sig-canvas-wrap:active {
  border-color: #3b82f6;
}

.sig-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.sig-baseline-guide {
  position: absolute;
  bottom: 35px;
  left: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  opacity: 0.45;
  transition: opacity 0.2s ease;
}

.sig-canvas-wrap.has-signature .sig-baseline-guide {
  opacity: 0.15;
}

.baseline-x {
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
  font-family: sans-serif;
  line-height: 1;
}

.baseline-line {
  flex: 1;
  border-bottom: 1.5px dashed #cbd5e1;
  height: 1px;
}

.sig-canvas-watermark {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
  user-select: none;
  text-align: center;
  letter-spacing: 0.02em;
}

.sig-canvas-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px;
}

.sig-tools-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sig-tools-divider {
  width: 1px;
  height: 18px;
  background-color: #e2e8f0;
}

.sig-color-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sig-color-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sig-color-btn.active {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #3b82f6;
}

.sig-stroke-slider-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  padding: 3px 10px 3px 9px;
  border-radius: 20px;
}

.sig-stroke-icon-min {
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
}

.sig-stroke-icon-max {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
}

.sig-stroke-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 88px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  transition: background 0.15s ease;
  margin: 0;
  padding: 0;
}

.sig-stroke-slider:hover {
  background: #94a3b8;
}

.sig-stroke-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--sig-active-pen-color, #0f172a);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
  cursor: grab;
  transition: transform 0.1s ease, border-color 0.15s ease;
}

.sig-stroke-slider:active::-webkit-slider-thumb {
  transform: scale(1.2);
  cursor: grabbing;
}

.sig-stroke-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--sig-active-pen-color, #0f172a);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
  cursor: grab;
  transition: transform 0.1s ease, border-color 0.15s ease;
}

.sig-stroke-slider:active::-moz-range-thumb {
  transform: scale(1.2);
  cursor: grabbing;
}

.sig-stroke-val-badge {
  font-size: 11px;
  font-weight: 600;
  color: #0f172a;
  min-width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.btn-sig-clear-link {
  background: none;
  border: none;
  font-size: 12.5px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

.btn-sig-clear-link:hover {
  color: #dc2626;
}

.sig-upload-box {
  border: 1.5px dashed #cbd5e1;
  border-radius: 12px;
  padding: 36px 16px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  transition: all 0.15s ease;
}

.sig-upload-box:hover {
  background: #f1f5f9;
  border-color: #3b82f6;
}

.sig-upload-box .upload-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.sig-upload-box .upload-text {
  font-weight: 600;
  color: #0f172a;
  font-size: 13.5px;
}

.sig-upload-box .upload-hint {
  font-size: 11.5px;
  color: #64748b;
  margin-top: 4px;
}

.sig-upload-preview-wrap {
  text-align: center;
  padding: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
}

.sig-upload-preview-wrap img {
  max-height: 120px;
  max-width: 100%;
  object-fit: contain;
  margin-bottom: 12px;
}

.sig-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

.sig-time-badge {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  font-feature-settings: 'tnum';
  display: flex;
  align-items: center;
  gap: 4px;
}

.sig-footer-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Hide orientation toggle on wide desktop */
@media (min-width: 769px) {
  .btn-toggle-sig-orient {
    display: none;
  }
}

/* Mobile Portrait Mode */
@media (max-width: 640px) {
  .modal-signature::backdrop {
    background: #ffffff !important;
  }

  .modal-signature:not(.is-rotated-landscape) {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-width: 100dvw !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
    overflow: hidden !important;
  }

  .modal-signature:not(.is-rotated-landscape) .signature-modal-card {
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-width: 100dvw !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    padding: 12px 16px 14px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
    background: #ffffff !important;
  }

  .modal-signature:not(.is-rotated-landscape) .signature-modal-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .modal-signature:not(.is-rotated-landscape) #sigDrawSection {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .modal-signature:not(.is-rotated-landscape) .sig-canvas-wrap {
    flex: 1;
    min-height: 0;
    height: 100%;
  }
}

/* Mobile Rotated Landscape (Hold phone sideways while in portrait orientation) */
@media (max-width: 640px) {
  .modal-signature.is-rotated-landscape {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-width: 100dvw !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: #ffffff !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
    overflow: hidden !important;
    z-index: 9999 !important;
  }

  .modal-signature.is-rotated-landscape .signature-modal-card {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    width: 100vh !important;
    width: 100dvh !important;
    height: 100vw !important;
    height: 100dvw !important;
    max-width: 100vh !important;
    max-width: 100dvh !important;
    max-height: 100vw !important;
    max-height: 100dvw !important;
    transform: translate(-50%, -50%) rotate(90deg) !important;
    transform-origin: center center !important;
    background: #ffffff !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 8px 16px !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    overflow: hidden !important;
    z-index: 10000 !important;
  }

  .modal-signature.is-rotated-landscape .sig-modal-header {
    padding-bottom: 4px !important;
    flex-shrink: 0 !important;
  }

  .modal-signature.is-rotated-landscape .sig-title-text {
    font-size: 15px !important;
  }

  .modal-signature.is-rotated-landscape .sig-subtitle-text {
    font-size: 11.5px !important;
  }

  .modal-signature.is-rotated-landscape .sig-mode-tabs {
    padding: 2px !important;
    gap: 2px !important;
    flex-shrink: 0 !important;
  }

  .modal-signature.is-rotated-landscape .sig-tab-btn {
    padding: 4px 8px !important;
    font-size: 11.5px !important;
  }

  .modal-signature.is-rotated-landscape .signature-modal-body {
    flex: 1 !important;
    min-height: 0 !important;
    padding: 2px 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    overflow: hidden !important;
  }

  .modal-signature.is-rotated-landscape #sigDrawSection {
    flex: 1 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    overflow: hidden !important;
  }

  .modal-signature.is-rotated-landscape .sig-canvas-wrap {
    flex: 1 !important;
    min-height: 0 !important;
    height: auto !important;
  }

  .modal-signature.is-rotated-landscape .sig-canvas-wrap canvas {
    width: 100% !important;
    height: 100% !important;
  }

  .modal-signature.is-rotated-landscape .sig-baseline-guide {
    bottom: 24px !important;
    left: 16px !important;
    right: 16px !important;
  }

  .modal-signature.is-rotated-landscape .sig-canvas-tools {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex-shrink: 0 !important;
    height: 26px !important;
    padding: 0 !important;
  }

  .modal-signature.is-rotated-landscape .sig-tools-left {
    gap: 8px !important;
  }

  .modal-signature.is-rotated-landscape .sig-stroke-slider {
    width: 65px !important;
  }

  .modal-signature.is-rotated-landscape .sig-stroke-slider-wrap {
    padding: 2px 7px !important;
    gap: 6px !important;
  }

  .modal-signature.is-rotated-landscape .sig-modal-footer {
    padding-top: 4px !important;
    flex-shrink: 0 !important;
  }

  .modal-signature.is-rotated-landscape .sig-time-badge {
    font-size: 11px !important;
  }

  .modal-signature.is-rotated-landscape .btn {
    padding: 5px 12px !important;
    font-size: 12px !important;
  }
}

/* Physical Landscape Mode on Mobile/Tablet */
@media (max-width: 920px) and (orientation: landscape) {
  .modal-signature {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  .signature-modal-card {
    height: 100vh !important;
    padding: 8px 16px 8px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .sig-modal-header {
    padding-bottom: 4px !important;
  }

  .sig-title-text {
    font-size: 15px !important;
  }

  .sig-subtitle-text {
    font-size: 11.5px !important;
  }

  .sig-mode-tabs {
    padding: 2px !important;
    gap: 2px !important;
  }

  .sig-tab-btn {
    padding: 4px 8px !important;
    font-size: 11.5px !important;
  }

  .signature-modal-body {
    flex: 1 !important;
    min-height: 0 !important;
    padding: 2px 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    overflow: hidden !important;
  }

  #sigDrawSection {
    flex: 1 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    overflow: hidden !important;
  }

  .sig-canvas-wrap {
    flex: 1 !important;
    min-height: 0 !important;
    height: 100% !important;
  }

  .sig-baseline-guide {
    bottom: 24px !important;
    left: 16px !important;
    right: 16px !important;
  }

  .sig-modal-footer {
    padding-top: 4px !important;
  }

  .sig-time-badge {
    font-size: 11px !important;
  }

  .btn {
    padding: 5px 12px !important;
    font-size: 12px !important;
  }

  .btn-toggle-sig-orient {
    display: none !important;
  }
}

.hidden { display: none !important; }
.print-only { display: none; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999999;
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 550;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  transition: all 0.2s ease;
}

@media screen and (max-width: 768px) {
  .toast {
    bottom: 72px;
    left: 16px;
    right: 16px;
    margin: 0 auto;
    max-width: 380px;
    justify-content: center;
    text-align: center;
    font-size: 13px;
  }
}

/* ============================================================================
   MOBILE RESPONSIVE STYLES (สำหรับหน้าจอสมาร์ทโฟนและแท็บเล็ต)
   ============================================================================ */
@media screen and (max-width: 768px) {
  /* 1. Fullscreen Modals on Mobile */
  dialog.modal-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    overflow: hidden;
  }

  /* Fullscreen Modal on Mobile for Add Demo Modal */
  #addDemoModalDialog:not([open]) {
    display: none !important;
  }

  #addDemoModalDialog[open] {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: #ffffff !important;
    z-index: 99999 !important;
  }

  #addDemoModalDialog .add-demo-modal-inner {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
    background: #ffffff !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #addDemoModalDialog .modal-header {
    flex-shrink: 0 !important;
    padding: 12px 16px !important;
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: auto !important;
    min-height: 48px !important;
  }

  #addDemoModalDialog .modal-header .modal-title {
    font-size: 16px !important;
    font-weight: 700 !important;
    margin: 0 !important;
  }

  #addDemoModalDialog .modal-header .modal-subtitle {
    display: none !important;
  }

  #addDemoModalDialog .modal-body-scroll {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 14px 16px 16px !important;
    overscroll-behavior: contain !important;
    box-sizing: border-box !important;
  }

  #addDemoModalDialog .modal-footer {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    flex-shrink: 0 !important;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    background: #ffffff !important;
    border-top: 1px solid #e2e8f0 !important;
    display: flex !important;
    gap: 10px !important;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08) !important;
    z-index: 20 !important;
    box-sizing: border-box !important;
  }

  #addDemoModalDialog .modal-footer .btn {
    border-radius: 10px !important;
    justify-content: center !important;
    height: 44px !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
  }

  #addDemoModalDialog .modal-footer #btnCancelAddDemo {
    flex: 0 0 90px !important;
    max-width: 100px !important;
    padding: 10px 12px !important;
  }

  #addDemoModalDialog .modal-footer #btnSaveAddDemo {
    flex: 1 1 auto !important;
    padding: 10px 14px !important;
  }

  #addDemoModalDialog .form-grid-2 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  dialog.modal-fullscreen .modal-inner {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
  }

  .modal-header {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    height: 52px;
    min-height: 52px;
    box-sizing: border-box;
    gap: 10px;
  }

  .fullscreen-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
  }

  .btn-back-nav {
    height: 32px;
    padding: 0 11px 0 8px;
    font-size: 13px;
    border-radius: 99px;
  }

  .modal-title-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .modal-title-group h2 {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    letter-spacing: -0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .modal-subtitle {
    display: none; /* ซ่อน subtitle ยาวๆ บนจอมือถือเพื่อเพิ่มพื้นที่ */
  }

  .btn-close-modal {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
  }

  .btn-close-modal:hover {
    background: #e2e8f0;
    color: #0f172a;
  }

  .modal-body {
    padding: 14px 14px calc(84px + env(safe-area-inset-bottom, 14px)) !important; /* เผื่อพื้นที่ด้านล่างไม่ให้ถูก footer ที่ fix อยู่ล่างสุดบัง */
    gap: 12px;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    overflow-y: auto;
    background: #f8fafc;
  }

  /* ป้องกัน iOS Safari ซูมหน้าจออัตโนมัติเมื่อแตะช่องกรอก */
  .field-group input,
  .field-group select,
  .date-field input[type="date"],
  .cell-inline-edit,
  .tag-add-input {
    font-size: 16px !important;
  }

  .loan-top-summary-bar {
    padding: 8px 10px;
    min-height: 46px;
    height: auto;
  }
  .summary-bar-icon {
    width: 28px;
    height: 28px;
    font-size: 15px;
  }
  .summary-bar-headline {
    font-size: 13px;
  }
  .summary-bar-sub {
    font-size: 11px;
  }
  .summary-bar-badge {
    font-size: 11.5px;
    padding: 3px 8px;
  }

  /* 2. Top Info Grid: 2 columns บนมือถือ จัดเรียงสวยงามประหยัดพื้นที่ */
  .form-grid-5 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  }

  .field-group.span-full-mobile {
    grid-column: 1 / -1;
  }

  .field-group label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 2px;
  }

  .field-group input,
  .field-group select {
    height: 40px;
    padding: 0 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    font-size: 15px;
    color: #0f172a;
    width: 100%;
    box-sizing: border-box;
  }

  .field-group input:focus,
  .field-group select:focus {
    background: #ffffff;
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  }

  .custom-select-trigger {
    height: 40px;
    font-size: 15px !important;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    padding: 0 10px;
  }

  .custom-select-trigger:focus {
    background: #ffffff;
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  }

  .custom-select-menu {
    position: absolute;
    right: 0;
    left: auto;
    width: max-content;
    min-width: 260px;
    max-width: calc(100vw - 32px);
    border-radius: 14px;
    padding: 6px;
    box-shadow: 0 18px 45px -5px rgba(15, 23, 42, 0.3), 0 0 0 1px rgba(226, 232, 240, 0.9);
  }

  .field-group.span-full-mobile .custom-select-menu {
    left: 0;
    right: 0;
    width: auto;
  }

  .custom-select-item {
    padding: 10px 12px;
    min-height: 46px;
  }

  .custom-select-item-text .item-title {
    font-size: 14px;
  }

  .custom-select-item-text .item-desc {
    font-size: 11.5px;
  }

  /* 3. แถบเลือกวันที่ยืม - กำหนดคืน (บนมือถือ: เรียบง่าย มินิมอล กะทัดรัด) */
  .date-outer-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 2px;
  }

  .date-bar {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    gap: 0;
  }

  .agoda-single-date-box {
    height: 40px;
    padding: 0 10px;
  }

  .agoda-range-card {
    min-width: 0;
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .agoda-range-dates-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .agoda-range-dates-wrap .agoda-seg-date {
    font-size: 13.5px;
  }

  .agoda-range-days-pill {
    font-size: 10.5px;
    padding: 2px 7px;
  }

  .modal-agoda-range {
    max-width: 380px;
    width: 95vw;
    border-radius: 18px;
  }

  .agoda-date-content {
    padding: 16px 14px 16px 14px;
  }

  .agoda-day-cell {
    height: 38px;
  }

  .agoda-day-cell .day-inner {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .quick-date-btns {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    padding-top: 6px;
    border-top: 1px dashed #cbd5e1;
  }

  .quick-date-label {
    font-size: 11.5px;
    font-weight: 600;
    color: #64748b;
    width: 100%;
    margin-bottom: 2px;
  }

  .quick-date-btns .btn-chip {
    flex: 1;
    min-width: 54px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    padding: 0 4px;
    border-radius: 6px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
  }

  .quick-date-btns .btn-chip:hover {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
  }

  /* 4. Section Title */
  .section-title-row {
    margin: 12px 2px 8px 2px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .section-title-row h3 {
    font-size: 13.5px;
    font-weight: 700;
    color: #334155;
    letter-spacing: -0.2px;
    margin: 0;
  }

  /* 5. แปลงตารางรายการสินค้าให้เป็นการ์ดแนวตั้งบนมือถือ (Mobile Cards with iOS Glass Look) */
  .excel-table-wrap {
    border: none;
    border-radius: 0;
    overflow: visible;
    background: transparent !important;
    box-shadow: none !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  .excel-loan-table,
  .excel-loan-table thead,
  .excel-loan-table tbody,
  .excel-loan-table th,
  .excel-loan-table td,
  .excel-loan-table tr {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }

  .excel-loan-table thead {
    display: none; /* ซ่อนหัวตารางแบบเดสก์ท็อป */
  }

  .excel-loan-table tbody {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .excel-loan-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.82);
    -webkit-backdrop-filter: blur(25px) saturate(190%);
    backdrop-filter: blur(25px) saturate(190%);
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 25px -4px rgba(15, 23, 42, 0.07),
                0 1px 3px rgba(0, 0, 0, 0.03),
                inset 0 1px 0 rgba(255, 255, 255, 0.95);
    position: relative;
    box-sizing: border-box;
  }

  .excel-loan-table tr.row-empty {
    border: 1px solid rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.75);
  }

  /* Active & Newly Added Card Framing in Mobile View */
  /* Inside cards, all cells MUST be completely clean with NO borders or backgrounds */
  .excel-loan-table tr td,
  .excel-loan-table tr.row-newly-added td,
  .excel-loan-table tr.row-active-expanded td {
    border: none !important;
    background: transparent !important;
  }

  .excel-loan-table tr.row-active-expanded:not(.row-newly-added) {
    border: 1.5px solid #94a3b8;
    box-shadow: 0 8px 24px -4px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(0, 0, 0, 0.03);
  }

  .excel-loan-table tr.row-newly-added {
    border: 2px solid #007aff !important;
    background: rgba(255, 255, 255, 0.98) !important;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.16),
                0 14px 34px -4px rgba(0, 122, 255, 0.22),
                inset 0 1px 0 #ffffff !important;
    animation: newCardGlow 0.4s ease-out;
  }

  .excel-loan-table tr.row-collapsed .collapsed-item-card.is-new-card {
    border: 1.5px solid #007aff !important;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12), 0 4px 15px -2px rgba(0, 122, 255, 0.1) !important;
  }

  /* Collapsed row in mobile view - Unified Luxury Card */
  .excel-loan-table tr.row-collapsed {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding: 14px 16px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    border: 1px solid rgba(226, 232, 240, 0.95) !important;
    border-radius: 16px !important;
    box-shadow: 0 4px 15px -2px rgba(15, 23, 42, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.95) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
  }

  .excel-loan-table tr.row-collapsed:active {
    background: #f8fafc !important;
    transform: scale(0.995);
  }

  .excel-loan-table tr.row-collapsed td {
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .excel-loan-table tr.row-collapsed td.cell-num {
    display: none !important;
  }

  .mobile-only-badge {
    display: inline-flex !important;
  }

  .excel-loan-table tr.row-collapsed td.cell-model {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
  }

  .excel-loan-table tr.row-collapsed .collapsed-cell-model-wrap {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .excel-loan-table tr.row-collapsed .collapsed-model-name {
    font-size: 14.5px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
  }

  .excel-loan-table tr.row-collapsed .collapsed-cell-qty-wrap {
    justify-content: flex-start !important;
  }

  .excel-loan-table tr.row-collapsed td.cell-qty,
  .excel-loan-table tr.row-collapsed td.cell-source {
    display: flex !important;
    width: 100% !important;
    vertical-align: middle !important;
  }

  .excel-loan-table tr.row-collapsed td.cell-options-cell,
  .excel-loan-table tr.row-collapsed td.cell-note {
    display: flex !important;
    width: 100% !important;
  }

  .excel-loan-table tr.row-collapsed .collapsed-empty-dash {
    display: none !important;
  }

  .excel-loan-table tr.row-collapsed td.cell-action {
    display: flex !important;
    justify-content: flex-end !important;
    border-top: 1px solid #f1f5f9 !important;
    padding-top: 8px !important;
    margin-top: 2px !important;
    width: 100% !important;
  }

  /* Next row placeholder in mobile view */
  .excel-loan-table tr.row-add-next-item {
    display: block !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  .excel-loan-table tr.row-add-next-item td.cell-add-next-item {
    display: block !important;
    padding: 0 !important;
    border: none !important;
    width: 100% !important;
  }

  .excel-loan-table tr.row-add-next-item .btn-add-next-item {
    padding: 13px;
    border-radius: 16px;
    font-size: 14px;
    background: rgba(240, 247, 255, 0.75);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1.5px dashed rgba(0, 122, 255, 0.45);
    color: #007aff;
  }

  /* แถวบนของการ์ด: แสดงลำดับที่ + คำว่า เลือกรุ่น และปุ่มจัดการ */
  .excel-loan-table td.cell-num {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent !important;
    border: none !important;
    padding: 0;
    width: auto;
    height: 32px;
    box-sizing: border-box;
    align-self: center;
    justify-self: start;
    transition: all 0.2s ease;
  }

  .excel-loan-table td.cell-num .cell-num-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 700;
    color: #007aff;
    background: rgba(0, 122, 255, 0.12);
    border: 1px solid rgba(0, 122, 255, 0.25);
    padding: 0 8px;
    border-radius: 9px;
    min-width: 32px;
    height: 32px;
    box-sizing: border-box;
  }

  .excel-loan-table td.cell-num.is-complete .cell-num-badge {
    background: rgba(34, 197, 94, 0.13) !important;
    color: #15803d !important;
    border-color: rgba(34, 197, 94, 0.35) !important;
  }

  .mobile-item-title {
    display: inline-block;
    font-size: 13.5px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
  }

  .badge-item-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #22c55e;
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(34, 197, 94, 0.4);
    flex-shrink: 0;
  }

  .collapsed-item-badge.is-complete {
    background: rgba(34, 197, 94, 0.13) !important;
    color: #15803d !important;
    border: 1px solid rgba(34, 197, 94, 0.35) !important;
  }

  .badge-item-check-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #22c55e;
    color: #ffffff;
    margin-left: 3px;
    box-shadow: 0 1px 3px rgba(34, 197, 94, 0.4);
    flex-shrink: 0;
  }

  .excel-loan-table td.cell-action {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    border: none;
    padding: 0;
    z-index: 2;
    align-self: center;
    justify-self: end;
  }

  .btn-collapse-mobile {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: rgba(241, 245, 249, 0.9);
    color: #475569;
    border: 1px solid rgba(203, 213, 225, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .btn-collapse-mobile:active {
    background: #e2e8f0;
    transform: scale(0.92);
  }

  .excel-loan-table td.cell-action .btn {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .excel-loan-table td.cell-action .btn:active {
    background: #ef4444;
    color: #fff;
    transform: scale(0.92);
  }

  .excel-loan-table td.cell-action .btn-item-dup {
    width: 32px;
    height: 32px;
    padding: 0;
  }

  .sn-slots-container {
    grid-template-columns: 1fr;
  }

  .excel-loan-table td.cell-step-next {
    display: none !important;
  }

  /* เลือกรุ่นสินค้า: เต็มความกว้าง บรรทัดที่ 2 */
  .excel-loan-table td.model-picker-cell {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    border: none;
    padding: 0;
    margin: 0;
  }

  .excel-loan-table td.model-picker-cell::before {
    display: none !important;
  }

  .excel-loan-table td.model-picker-cell input {
    height: 44px;
    font-size: 15px;
    font-weight: 600;
    border: 1px solid rgba(203, 213, 225, 0.85);
    border-radius: 12px;
    padding: 0 40px 0 14px;
    width: 100%;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: all 0.2s ease;
  }

  .btn-clear-model-input {
    right: 12px;
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .excel-loan-table td.model-picker-cell input:focus {
    background: #ffffff;
    border-color: #007aff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
    outline: none;
  }

  /* จำนวน: ครึ่งซ้าย (ไม่แสดง label ตามความต้องการ) */
  .excel-loan-table td.cell-qty {
    grid-column: 1;
    display: flex;
    flex-direction: column;
    border: none;
    padding: 0;
  }

  .excel-loan-table td.cell-qty .qty-stepper {
    display: flex;
    align-items: center;
    border: 1px solid rgba(203, 213, 225, 0.8);
    border-radius: 12px;
    height: 44px;
    background: rgba(241, 245, 249, 0.9);
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
  }

  .excel-loan-table td.cell-qty .qty-step-btn {
    width: 42px;
    height: 44px;
    font-size: 20px;
    background: transparent;
    border: none;
    color: #007aff;
    cursor: pointer;
    font-weight: 700;
    transition: background-color 0.15s ease;
  }

  .excel-loan-table td.cell-qty .qty-step-btn:first-child {
    border-right: 1px solid rgba(226, 232, 240, 0.8);
  }

  .excel-loan-table td.cell-qty .qty-step-btn:last-child {
    border-left: 1px solid rgba(226, 232, 240, 0.8);
  }

  .excel-loan-table td.cell-qty .qty-step-btn:active {
    background: rgba(0, 122, 255, 0.15);
  }

  .excel-loan-table td.cell-qty .qty-step-input {
    flex: 1;
    height: 44px;
    border: none;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    background: transparent;
    width: 36px;
  }

  /* Source คลัง: ครึ่งขวา (ไม่แสดง label ตามความต้องการ) */
  .excel-loan-table td.cell-source {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    border: none;
    padding: 0;
  }

  .excel-loan-table td.cell-source select,
  .excel-loan-table td.cell-source .cell-source-btn {
    height: 44px;
    font-size: 14.5px;
    border: 1px solid rgba(203, 213, 225, 0.8);
    border-radius: 12px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.9);
    width: 100%;
    box-sizing: border-box;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .excel-loan-table td.cell-source select:focus,
  .excel-loan-table td.cell-source .cell-source-btn:focus {
    background: #ffffff;
    border-color: #007aff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
    outline: none;
  }

  /* อุปกรณ์เสริม & S/N: เต็มความกว้าง อยู่ต่อจากแถว จำนวน & Source คลัง */
  .excel-loan-table td.cell-options-cell {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border: none;
    padding: 0;
  }

  .excel-loan-table td.cell-options-cell .cell-options-wrap {
    margin-top: 0;
    width: 100%;
    gap: 8px;
  }

  .excel-loan-table td.cell-options-cell .btn-acc-trigger,
  .excel-loan-table td.cell-options-cell .btn-sn-trigger {
    height: 44px;
    font-size: 14px;
    border-radius: 12px;
  }

  /* หมายเหตุเพิ่มเติม: เต็มความกว้าง */
  .excel-loan-table td.cell-note {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border: none;
    padding: 0;
  }

  .excel-loan-table td.cell-note::before {
    content: "หมายเหตุ:";
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
  }

  .excel-loan-table td.cell-note .note-unified-box {
    width: 100%;
    height: 44px;
    min-height: 44px;
    border: 1px solid rgba(203, 213, 225, 0.85);
    border-radius: 12px;
    padding: 0 34px 0 12px;
    background: rgba(255, 255, 255, 0.9);
    box-sizing: border-box;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
    position: relative;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  }

  .excel-loan-table td.cell-note .note-unified-box:focus-within {
    background: #ffffff;
    border-color: #007aff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
  }

  .excel-loan-table td.cell-note textarea.note-box-textarea,
  .excel-loan-table td.cell-note .note-unified-box textarea {
    min-height: 24px !important;
    height: auto;
    font-size: 14.5px !important;
    line-height: 24px !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
  }

  .excel-loan-table td.cell-note .btn-box-clip {
    position: absolute;
    right: 6px;
    bottom: 8px;
  }

  /* 6. แถบปุ่มบันทึกด้านล่างแบบ Fixed อยู่ล่างสุดของหน้าจอมือถือตลอดเวลา (เฉพาะ modal ออกใบยืมขณะเปิดอยู่เท่านั้น) */
  #loanDialog[open] .modal-footer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 64px !important;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 10px)) !important;
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border-top: 1px solid #e2e8f0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    z-index: 1000 !important;
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08) !important;
    box-sizing: border-box !important;
  }

  .btn-cancel-modal {
    display: none; /* ซ่อนปุ่มยกเลิกด้านล่างเนื่องจากมีปุ่มย้อนกลับและปิดที่หัวหน้าต่างแล้ว */
  }

  .footer-right-btns {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .footer-right-btns .btn {
    height: 42px;
    min-height: 42px;
    font-size: 13.5px;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    white-space: nowrap;
  }

  /* 7. Dropdown เมนูเลือกรุ่น/อุปกรณ์เสริมบนมือถือ */
  .model-dropdown-menu:not(#snModalDropdownMenu) {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    max-width: calc(100vw - 20px) !important;
    border-radius: 14px !important;
    box-shadow: 0 16px 40px -4px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(226, 232, 240, 0.8) !important;
    z-index: 999999 !important;
  }

  .dropdown-header-bar {
    padding: 10px 14px;
  }

  .btn-close-dropdown {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .model-dropdown-item {
    padding: 10px 14px;
    min-height: 44px;
  }

  .model-item-name {
    font-size: 14px;
  }

  .model-item-sub {
    font-size: 12px;
  }

  /* 8. หัวเว็บ / Search bar บนมือถือ (Minimal Mode: โฟกัสค้นหา และ + ออกใบยืม) */
  .brand-group {
    gap: 8px !important;
  }

  .brand-logo {
    width: 26px !important;
    height: 26px !important;
    font-size: 13px !important;
    border-radius: 6px !important;
  }

  .brand-title {
    font-size: 14.5px !important;
  }

  .brand-subtitle {
    display: none !important;
  }

  .view-switcher {
    display: flex !important;
    align-items: center !important;
    gap: 3px !important;
    padding: 2.5px !important;
    border-radius: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .view-switcher::-webkit-scrollbar {
    display: none !important;
  }

  .view-btn {
    flex: 1 !important;
    justify-content: center !important;
    padding: 6px 8px !important;
    font-size: 11.5px !important;
    border-radius: 6px !important;
    white-space: nowrap !important;
    text-align: center !important;
  }

  .sort-btn {
    height: 26px !important;
    padding: 0 7px !important;
    font-size: 10.5px !important;
    border-radius: 6px !important;
    flex-shrink: 0 !important;
  }

  /* -------------------------------------------------------------
     Print Preview & Gate Pass Modal on Mobile
     ------------------------------------------------------------- */
  .print-modal-header {
    height: auto !important;
    min-height: unset !important;
    padding: 8px 12px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    flex-shrink: 0 !important;
  }

  .print-navbar-left {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
  }

  .print-title-group {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    min-width: 0 !important;
  }

  .print-title-wrap {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    min-width: 0 !important;
  }

  .print-nav-title {
    font-size: 15px !important;
    font-weight: 800 !important;
    white-space: nowrap !important;
  }

  .print-loan-badge {
    font-size: 11px !important;
    padding: 2px 7px !important;
    white-space: nowrap !important;
    max-width: 125px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .btn-navbar-close-mobile {
    display: inline-flex !important;
    width: 32px !important;
    height: 32px !important;
    flex-shrink: 0 !important;
  }

  .print-navbar-right {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    gap: 6px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 1px !important;
  }

  .print-toolbar-left {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    min-width: 0 !important;
  }

  .print-toolbar-right {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
  }

  .btn-navbar-close-desktop {
    display: none !important;
  }

  .btn-desktop-print,
  #btnOpenSendEmailModal {
    display: none !important; /* Bottom fixed footer handles these on mobile */
  }

  .print-select-input {
    height: 32px !important;
    font-size: 12px !important;
    padding: 0 8px 0 24px !important;
    border-radius: 6px !important;
  }

  .print-zoom-segmented {
    display: inline-flex !important;
    align-items: center !important;
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    padding: 2px !important;
    gap: 2px !important;
    flex-shrink: 0 !important;
  }

  .btn-zoom-seg {
    border: none !important;
    background: transparent !important;
    color: #475569 !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    padding: 3px 8px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    line-height: 1.3 !important;
    white-space: nowrap !important;
  }

  .btn-zoom-seg:hover {
    color: #0f172a !important;
  }

  .btn-zoom-seg.is-active {
    background: #ffffff !important;
    color: #2563eb !important;
    font-weight: 700 !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12) !important;
  }

  /* Preview Scroll Container & Sheet: Keep exact A4 desktop proportions */
  .print-preview-scroll {
    padding: 14px 10px calc(84px + env(safe-area-inset-bottom, 14px)) 10px !important;
    background: #cbd5e1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .print-scale-viewport {
    display: flex !important;
    justify-content: center !important;
    align-items: flex-start !important;
    margin: 0 auto !important;
    position: relative !important;
    transition: width 0.2s ease, height 0.2s ease !important;
  }

  .fullscreen-sheet-wrap {
    width: 780px !important;
    min-width: 780px !important;
    max-width: 780px !important;
    margin: 0 auto !important;
    transform-origin: 0 0 !important;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  .gate-pass-sheet {
    background: #ffffff !important;
    padding: 24px 32px !important;
    border-radius: 10px !important;
    border: 1px solid #94a3b8 !important;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.12) !important;
    width: 780px !important;
    min-width: 780px !important;
    max-width: 780px !important;
    box-sizing: border-box !important;
    font-size: 13.5px !important;
    line-height: 1.4 !important;
  }

  .gate-pass-sheet.size-dual {
    width: 780px !important;
    min-width: 780px !important;
    max-width: 780px !important;
    padding: 12px 18px !important;
    font-size: 11px !important;
  }

  /* Gate Pass Document Header on Mobile: Preserve desktop side-by-side layout */
  .gp-header {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    gap: 16px !important;
    border-bottom: 1.5px solid #0f172a !important;
    padding-bottom: 10px !important;
    margin-bottom: 10px !important;
  }

  .gp-header-issuer {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: 65% !important;
  }

  .gp-issuer-logo {
    max-height: 38px !important;
    max-width: 120px !important;
  }

  .gp-issuer-name-th {
    font-size: 13.5px !important;
    font-weight: 800 !important;
  }

  .gp-issuer-name-en {
    font-size: 10px !important;
  }

  .gp-issuer-meta-line {
    font-size: 9.5px !important;
    flex-wrap: wrap !important;
  }

  .gp-header-doc {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    text-align: right !important;
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: 35% !important;
    margin-top: 0 !important;
  }

  .gp-title-row {
    justify-content: flex-end !important;
    width: 100% !important;
  }

  .gp-title {
    font-size: 15px !important;
    font-weight: 800 !important;
    color: #0f172a !important;
    line-height: 1.25 !important;
  }

  .gp-desc {
    font-size: 10.5px !important;
    color: #64748b !important;
    margin-top: 1px !important;
  }

  .gp-doc-meta {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    gap: 2px !important;
    font-size: 10.5px !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    text-align: right !important;
    margin-top: 4px !important;
  }

  .gp-meta-item {
    display: inline-flex !important;
    gap: 4px !important;
    margin-bottom: 0 !important;
  }

  /* Info Grid: Clean 2-column balanced grid */
  .gp-info-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 5px 20px !important;
    padding: 8px 12px !important;
    margin-bottom: 10px !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
    border-radius: 6px !important;
  }

  .gp-info-item {
    word-break: break-word !important;
  }

  /* Table on Mobile: Beautiful 5-column table with guaranteed min-widths */
  .gp-table-wrap {
    margin-bottom: 10px !important;
    border: 1px solid #94a3b8 !important;
    border-radius: 6px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
  }

  .gp-table {
    width: 100% !important;
    min-width: 600px !important;
    margin: 0 !important;
    border-collapse: collapse !important;
  }

  .gp-table th,
  .gp-table td {
    padding: 5px 7px !important;
    font-size: 11.5px !important;
    line-height: 1.35 !important;
    border: 1px solid #94a3b8 !important;
  }

  .gp-acc-tag {
    display: inline-flex !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    font-size: 10.5px !important;
    margin: 1px 6px 1px 0 !important;
  }

  .gp-terms-notice {
    font-size: 10.5px !important;
    line-height: 1.35 !important;
    color: #475569 !important;
    margin-top: 8px !important;
  }

  /* Signatures on Mobile: 3 columns side-by-side with signature lines */
  .gp-signatures {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px !important;
    margin-top: 14px !important;
    text-align: center !important;
  }

  .gp-sig-box {
    margin-top: 6px !important;
    padding-top: 0 !important;
    border-top: none !important;
  }

  .gp-sig-role {
    font-size: 11px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    line-height: 1.25 !important;
  }

  .gp-sig-name,
  .gp-sig-date {
    font-size: 10px !important;
    color: #64748b !important;
    line-height: 1.2 !important;
    margin-top: 2px !important;
  }

  .gp-sig-img {
    max-height: 38px !important;
    bottom: 18px !important;
  }

  /* Fixed Bottom Action on Mobile */
  .print-mobile-footer {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    background: #ffffff !important;
    border-top: 1px solid #e2e8f0 !important;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 12px)) 14px !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08) !important;
    z-index: 100 !important;
    justify-content: center !important;
    box-sizing: border-box !important;
  }

  .btn-mobile-print-action {
    width: 100% !important;
    height: 46px !important;
    border-radius: 10px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    background: #2563eb !important;
    color: #ffffff !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25) !important;
    cursor: pointer !important;
  }

  .btn-mobile-print-action:active {
    background: #1d4ed8 !important;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }
  html, body {
    width: 210mm !important;
    height: auto !important;
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    overflow: visible !important;
  }
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  .print-modal-header,
  .print-mobile-footer { display: none !important; }
  dialog, dialog::backdrop { display: none !important; }
  body > *:not(#printMount) { display: none !important; }

  #printMount {
    width: 210mm !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    overflow: visible !important;
  }

  /* Dual Sheet Layout for A4 Split (Original + Copy) */
  .gate-pass-dual-wrapper {
    display: flex !important;
    flex-direction: column !important;
    width: 210mm !important;
    height: 297mm !important;
    max-height: 297mm !important;
    position: relative !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    page-break-inside: avoid !important;
    page-break-after: avoid !important;
    overflow: hidden !important;
  }

  .gp-half-slot {
    width: 210mm !important;
    height: 148.5mm !important;
    max-height: 148.5mm !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: center !important;
    padding: 6mm 10mm 4mm !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .gate-pass-dual-wrapper .gp-perforation-divider {
    position: absolute !important;
    top: 148.5mm !important;
    left: 0 !important;
    right: 0 !important;
    transform: translateY(-50%) !important;
    width: 210mm !important;
    padding: 0 10mm !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Full Pair Layout for A4 (2 Pages: Page 1 Original, Page 2 Copy) */
  .gate-pass-full-pair-wrapper {
    width: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
  }

  .gate-pass-full-pair-wrapper .gp-page-sheet {
    width: 210mm !important;
    min-height: 297mm !important;
    max-width: 210mm !important;
    box-sizing: border-box !important;
    padding: 8mm 12mm !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
  }

  .gate-pass-full-pair-wrapper .gp-page-original {
    page-break-after: always !important;
    break-after: page !important;
  }

  .gate-pass-full-pair-wrapper .gp-page-copy {
    page-break-after: auto !important;
    break-after: auto !important;
  }

  .gate-pass-full-pair-wrapper .gp-page-indicator {
    display: none !important;
  }

  .gate-pass-sheet {
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 13px !important;
    box-sizing: border-box !important;
  }

  .gate-pass-sheet.size-dual {
    width: 100% !important;
    padding: 3mm 6mm !important;
    font-size: 10.5px !important;
    line-height: 1.35 !important;
    border: 1px solid #64748b !important;
    border-radius: 6px !important;
    page-break-inside: avoid !important;
    box-sizing: border-box !important;
    margin: 0 !important;
  }

  .gate-pass-sheet.size-dual .gp-header {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    border-bottom: 1.5px solid #0f172a !important;
    padding-bottom: 5px !important;
    margin-bottom: 6px !important;
    gap: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .gate-pass-sheet.size-dual .gp-header-issuer {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 1.5px !important;
    flex: 1 1 auto !important;
    width: auto !important;
    max-width: 65% !important;
    min-width: 0 !important;
  }

  .gate-pass-sheet.size-dual .gp-issuer-top-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .gate-pass-sheet.size-dual .gp-issuer-logo-box {
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
  }

  .gate-pass-sheet.size-dual .gp-issuer-logo {
    max-height: 24px !important;
    max-width: 75px !important;
    object-fit: contain !important;
    display: block !important;
  }

  .gate-pass-sheet.size-dual .gp-issuer-brand-block {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5px !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  .gate-pass-sheet.size-dual .gp-issuer-brand {
    display: flex !important;
    flex-direction: row !important;
    align-items: baseline !important;
    gap: 5px !important;
    flex-wrap: wrap !important;
  }

  .gate-pass-sheet.size-dual .gp-issuer-name-th {
    font-size: 10.5px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
  }

  .gate-pass-sheet.size-dual .gp-issuer-name-en {
    font-size: 8px !important;
    white-space: nowrap !important;
  }

  .gate-pass-sheet.size-dual .gp-issuer-meta-tax {
    font-size: 7.5px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
  }

  .gate-pass-sheet.size-dual .gp-issuer-bottom-details {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5px !important;
    width: 100% !important;
    font-size: 7.5px !important;
    line-height: 1.2 !important;
    margin-top: 1px !important;
  }

  .gate-pass-sheet.size-dual .gp-issuer-address {
    white-space: normal !important;
    word-break: break-word !important;
    color: #475569 !important;
  }

  .gate-pass-sheet.size-dual .gp-issuer-contact {
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
    font-size: 7.5px !important;
  }

  .gate-pass-sheet.size-dual .gp-contact-item {
    display: inline-flex !important;
    align-items: center !important;
    gap: 2.5px !important;
  }

  .gate-pass-sheet.size-dual .gp-contact-icon {
    width: 8px !important;
    height: 8px !important;
    flex-shrink: 0 !important;
  }

  .gate-pass-sheet.size-dual .gp-header-doc {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    text-align: right !important;
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: 35% !important;
  }

  .gate-pass-sheet.size-dual .gp-doc-heading {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
  }

  .gate-pass-sheet.size-dual .gp-title {
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
  }

  .gate-pass-sheet.size-dual .gp-sheet-badge {
    font-size: 8px !important;
    padding: 1.5px 5px !important;
  }

  .gate-pass-sheet.size-dual .gp-meta-block-wrap {
    gap: 8px !important;
    margin-top: 2px !important;
  }

  .gate-pass-sheet.size-dual .gp-doc-qr-wrap {
    width: 36px !important;
    height: 36px !important;
    padding: 1.5px !important;
    border-radius: 3px !important;
    border-color: #cbd5e1 !important;
  }

  .gate-pass-sheet.size-dual .gp-meta-table {
    margin-top: 0 !important;
    gap: 1px !important;
  }

  .gate-pass-sheet.size-dual .gp-meta-row {
    font-size: 8.5px !important;
    line-height: 1.25 !important;
    gap: 6px !important;
  }

  .gate-pass-sheet.size-dual .gp-meta-lbl {
    font-size: 8px !important;
  }

  .gate-pass-sheet.size-dual .gp-meta-val {
    font-size: 8.5px !important;
    min-width: 65px !important;
  }

  .gate-pass-sheet.size-dual .gp-info-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 2px 12px !important;
    margin-bottom: 5px !important;
    padding: 4px 8px !important;
    font-size: 9.5px !important;
    line-height: 1.3 !important;
  }

  .gate-pass-sheet.size-dual .gp-table-wrap {
    margin-bottom: 3px !important;
  }

  .gate-pass-sheet.size-dual .gp-table th,
  .gate-pass-sheet.size-dual .gp-table td {
    padding: 2px 4px !important;
    font-size: 8.5px !important;
    line-height: 1.2 !important;
  }

  .gate-pass-sheet.size-dual .gp-sn-code {
    font-size: 8px !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
  }

  .gate-pass-sheet.size-dual .gp-acc-tag {
    display: inline-flex !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    font-size: 8px !important;
    line-height: 1.2 !important;
    margin: 0.5px 5px 0.5px 0 !important;
  }

  .gate-pass-sheet.size-dual .gp-att-chip {
    font-size: 7.5px !important;
    padding: 0 2px !important;
  }

  .gate-pass-sheet.size-dual .gp-terms-notice {
    font-size: 7.5px !important;
    margin-top: 2px !important;
    line-height: 1.15 !important;
  }

  .gate-pass-sheet.size-dual .gp-signatures {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
    margin-top: 4px !important;
    text-align: center !important;
  }

  .gate-pass-sheet.size-dual .gp-sig-box {
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: none !important;
  }

  .gate-pass-sheet.size-dual .gp-sig-slot {
    min-height: 22px !important;
    height: 22px !important;
    margin-bottom: 1px !important;
  }

  .gate-pass-sheet.size-dual .gp-sig-line {
    width: 75% !important;
    max-width: 120px !important;
    margin: 0 auto 2px !important;
    border-bottom: 1px dashed #64748b !important;
  }

  .gate-pass-sheet.size-dual .gp-sig-preview-wrap .gp-sig-img {
    height: 20px !important;
    max-width: 75px !important;
  }

  .gate-pass-sheet.size-dual .gp-sig-time {
    font-size: 7px !important;
    color: #047857 !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin-bottom: 1px !important;
  }

  .gate-pass-sheet.size-dual .gp-sig-role {
    font-size: 8.5px !important;
    font-weight: 700 !important;
  }

  .gate-pass-sheet.size-dual .gp-sig-name,
  .gate-pass-sheet.size-dual .gp-sig-date {
    font-size: 7.5px !important;
    margin-top: 1px !important;
  }

  .gp-perf-line {
    border-top: 1px dashed #64748b !important;
    flex: 1 !important;
  }

  .gp-perf-label {
    font-size: 8.5px !important;
    color: #64748b !important;
    background: #fff !important;
    padding: 0 6px !important;
    border: none !important;
    white-space: nowrap !important;
  }

  .gp-sheet-badge.original {
    background: #0f172a !important;
    color: #ffffff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .gp-sheet-badge.copy {
    background: #f1f5f9 !important;
    color: #334155 !important;
    border: 1px solid #94a3b8 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .gp-header {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
  }
  .gp-doc-meta {
    display: block !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    text-align: right !important;
  }
  .gp-doc-meta .gp-meta-item {
    display: block !important;
  }
  .gp-signatures {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px !important;
  }
}

/* ==========================================================================
   Company Autocomplete Field (3-Tier DBD & Custom Search)
   ========================================================================== */
.company-field-group {
  position: relative;
}

.company-input-wrap {
  position: relative;
  width: 100%;
}

.company-input-wrap input {
  width: 100%;
  padding-right: 28px;
}

.company-search-spinner {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  animation: spinCompany 1s linear infinite;
  pointer-events: none;
}

@keyframes spinCompany {
  from { transform: translateY(-50%) rotate(0deg); }
  to { transform: translateY(-50%) rotate(360deg); }
}

.company-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 440px;
  max-width: 90vw;
  max-height: 320px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid rgba(203, 213, 225, 0.95);
  border-radius: 12px;
  box-shadow: 0 12px 30px -4px rgba(15, 23, 42, 0.18), 0 6px 12px -4px rgba(15, 23, 42, 0.08);
  z-index: 1000;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  animation: fadeInDown 0.15s ease-out;
}

.company-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s ease;
  user-select: none;
  gap: 8px;
}

.company-item:hover,
.company-item.is-selected {
  background: #f1f5f9;
}

.company-item-main {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.company-item-icon {
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 2px;
}

.company-item-text-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.company-item-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
  white-space: normal;
  line-height: 1.4;
  word-break: break-word;
}

.company-item-sub {
  font-size: 11.5px;
  color: #64748b;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
  margin-top: 1px;
}

.company-item-en {
  color: #334155;
  font-weight: 500;
}

.company-item-tax {
  color: #64748b;
}

.company-item-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 6px;
}

.company-item-badge.badge-history {
  background: #eff6ff;
  color: #007aff;
  border: 1px solid rgba(0, 122, 255, 0.2);
}

.company-item-badge.badge-dbd {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid rgba(22, 163, 74, 0.2);
}

.company-item-badge.badge-custom {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.company-online-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #007aff;
  cursor: pointer;
  margin-top: 4px;
  transition: all 0.15s ease;
}

.company-online-trigger:hover {
  background: #eff6ff;
  border-color: #007aff;
}

.company-add-new-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  color: #7e22ce;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: all 0.12s ease;
}

.company-add-new-item:hover {
  background: #f3e8ff;
}

.company-dropdown-empty {
  padding: 10px;
  text-align: center;
  font-size: 12px;
  color: #94a3b8;
}

/* ==========================================================================
   STOCK VIEW (CARD GRID & ADD DEMO ASSET)
   ========================================================================== */
.stock-view-section {
  --stock-filter-h: 52px;
  --stock-sheet-th-h: 38px;
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 90px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
}

.stock-toolbar {
  padding: 12px 18px;
  background: #ffffff;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.stock-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stock-count-badge {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
}

.btn-add-demo-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 9px;
  background: #2563eb;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.22);
  transition: all 0.15s ease;
}

.btn-add-demo-header:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.stock-brands-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-top: none;
  border-radius: 0 0 12px 12px;
  flex-shrink: 0;
  min-height: min-content;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.brand-group-block:last-child {
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

.stock-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
  align-items: start;
}

@media (max-width: 768px) {
  .stock-cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .stock-view-section {
    --stock-filter-h: 70px;
    --stock-sheet-th-h: 40px;
  }
  .stock-header-card.compact-stock-header,
  .stock-header-card {
    padding: 6px 10px !important;
    margin-bottom: 0 !important;
    border-radius: 10px 10px 0 0 !important;
  }
  .stock-brands-container {
    border-radius: 0 0 10px 10px !important;
  }
  .stock-header-inner-wrap {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
  }
  .source-chips-modern {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding-bottom: 2px !important;
  }
  .source-chips-modern::-webkit-scrollbar {
    display: none !important;
  }
  .chip-filter {
    padding: 3px 8px !important;
    font-size: 11px !important;
    height: 25px !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
  }
  .stock-header-side-wrap {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px !important;
    width: 100% !important;
  }
  .stock-quick-stats {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
  }
  .quick-stat-pill {
    padding: 2px 7px !important;
    font-size: 11px !important;
  }
  .stock-stat-total {
    font-size: 11px !important;
    padding: 2px 7px !important;
  }
  .btn-add-demo-header {
    display: none !important;
  }
  .btn-toggle-all-brands {
    padding: 2px 8px !important;
    font-size: 11px !important;
    height: 24px !important;
    flex-shrink: 0 !important;
  }
  .brand-group-header-banner {
    padding: 10px 14px;
    border-radius: 12px;
  }
  .brand-header-left {
    gap: 8px;
  }
  .brand-group-name {
    font-size: 14.5px;
  }
  .brand-metrics-cluster {
    width: 100%;
    margin-top: 4px;
    margin-left: 36px;
  }
  .brand-collapse-badge {
    white-space: nowrap;
    padding: 3px 10px;
  }

  /* Fullscreen Asset Detail Modal on Mobile */
  #assetDetailModalDialog.modal-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    padding: 0 !important;
    z-index: 9999 !important;
  }
  #assetDetailModalDialog .modal-header.asset-modal-header-v2 {
    padding: 8px 12px !important;
    min-height: 54px !important;
    gap: 8px !important;
  }
  #assetDetailModalDialog .fullscreen-header-left {
    gap: 8px !important;
    align-items: center !important;
    min-width: 0 !important;
    flex: 1 !important;
  }
  #assetDetailModalDialog .btn-back-nav {
    height: 32px !important;
    padding: 0 8px !important;
    flex-shrink: 0 !important;
    border-radius: 99px !important;
  }
  #assetDetailModalDialog .btn-back-nav .back-text {
    display: none !important;
  }
  #assetDetailModalDialog .asset-device-avatar {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    font-size: 18px !important;
    border-radius: 9px !important;
  }
  #assetDetailModalDialog .asset-header-title-row {
    flex-wrap: nowrap !important;
    gap: 6px !important;
    min-width: 0 !important;
  }
  #assetDetailModalDialog .asset-header-title {
    font-size: 15px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  #assetDetailModalDialog .asset-header-sn-badge {
    font-size: 11px !important;
    padding: 1.5px 5.5px !important;
    flex-shrink: 0 !important;
  }
  #assetDetailModalDialog .asset-header-sn-badge .sn-lbl {
    font-size: 8.5px !important;
    padding: 0.5px 3.5px !important;
  }
  #assetDetailModalDialog .asset-header-meta-row {
    font-size: 11px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 1px !important;
  }
  #assetDetailModalDialog .asset-header-meta-row::-webkit-scrollbar {
    display: none !important;
  }
  #assetDetailModalDialog .btn-close-modal {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    flex-shrink: 0 !important;
  }
  #assetDetailModalDialog .asset-detail-nav-tabs {
    padding: 6px 12px 0 12px !important;
  }
  #assetDetailModalDialog .modal-body-scroll {
    padding: 12px 12px 24px 12px !important;
  }
  #assetDetailModalDialog.tab-history-active .modal-body-scroll,
  #assetDetailModalDialog .modal-body-scroll:has(#assetTabPaneHistory:not(.hidden)) {
    padding: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    flex: 1 1 auto !important;
    background: #fbf9f4 !important;
  }
  #assetDetailModalDialog #assetTabPaneHistory:not(.hidden) {
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }
  #assetDetailModalDialog .library-card-wrapper {
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    border: none !important;
    border-left: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  #assetDetailModalDialog .library-card-header {
    padding: 9px 12px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 5px !important;
    border-bottom: 1px solid #ded5c4 !important;
    background: #f7f3ea !important;
  }
  #assetDetailModalDialog .lib-header-row-primary {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
  }
  #assetDetailModalDialog .lib-title-wrap .lib-title-text {
    font-size: 14px !important;
  }
  #assetDetailModalDialog .lib-header-row-meta {
    font-size: 11px !important;
    gap: 6px !important;
    margin-top: 2px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch !important;
  }
  #assetDetailModalDialog .lib-header-row-meta::-webkit-scrollbar {
    display: none !important;
  }
  #assetDetailModalDialog .library-sheet-container {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border: none !important;
  }
  #assetDetailModalDialog .library-card-pagination {
    flex: 0 0 auto !important;
    margin-top: auto !important;
    padding: 7px 12px calc(8px + env(safe-area-inset-bottom, 8px)) 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px !important;
    border-top: 1px solid #ded5c4 !important;
    border-radius: 0 !important;
  }
  #assetDetailModalDialog .lib-page-info {
    font-size: 11px !important;
  }
  #assetDetailModalDialog .lib-total-records {
    display: none !important;
  }
  #assetDetailModalDialog .btn-lib-nav {
    padding: 3px 8px !important;
    font-size: 11px !important;
  }
  #assetDetailModalDialog .modal-footer {
    display: none !important;
  }
}

.card-new-highlight {
  animation: assetHighlight 2.5s ease-out forwards;
}

@keyframes assetHighlight {
  0% { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.45); border-color: #2563eb; }
  100% { box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04); border-color: #e2e8f0; }
}

.asset-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.asset-top-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.asset-tag-badge {
  background: #0f172a;
  color: #ffffff;
  font-weight: 700;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.3px;
  font-family: 'SF Mono', Menlo, monospace;
}

.asset-source-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
}

.asset-source-pill.src-demo {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.asset-source-pill.src-supplier {
  background: #fdf4ff;
  color: #9333ea;
  border: 1px solid #f0abfc;
}

.asset-source-pill.src-sales {
  background: #fefce8;
  color: #b45309;
  border: 1px solid #fef08a;
}

.asset-source-pill.src-repair {
  background: #ecfeff;
  color: #0e7490;
  border: 1px solid #a5f3fc;
}

.asset-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.asset-status-pill.avail {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.asset-status-pill.loaned {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.status-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.status-indicator-dot.avail {
  background: #10b981;
}

.status-indicator-dot.loaned {
  background: #3b82f6;
}

.asset-card-headline {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.asset-model-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.35;
}

.asset-sn-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.sn-meta-label {
  color: #64748b;
  font-weight: 500;
}

.sn-meta-code {
  color: #1e293b;
  background: #f8fafc;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  font-size: 11.5px;
}

/* On-Loan Callout */
.asset-loan-callout {
  background: #f0f7ff;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: #1e3a8a;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.loan-callout-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.callout-icon {
  font-size: 12px;
  opacity: 0.85;
}

.callout-sep {
  color: #93c5fd;
  font-size: 10px;
}

.loan-callout-row.due-row {
  font-size: 11.5px;
  color: #2563eb;
  font-weight: 500;
}

/* Card Field Rows */
.asset-card-fields {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 4px;
  border-top: 1px solid #f1f5f9;
}

.asset-prop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.asset-prop-label {
  color: #64748b;
  font-weight: 600;
  font-size: 11.5px;
  white-space: nowrap;
}

.asset-prop-input,
.asset-prop-select {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
  background: #f8fafc;
  font-family: inherit;
  color: #1e293b;
  transition: all 0.15s ease;
}

.asset-prop-input:focus,
.asset-prop-select:focus {
  outline: none;
  border-color: #2563eb;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* Accessories Tag Editor */
.asset-card-acc-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  border-radius: 8px;
  padding: 8px 10px;
}

.asset-acc-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.asset-acc-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.asset-chip-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #ffffff;
  color: #334155;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11.5px;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.chip-remove-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: #94a3b8;
  font-size: 12px;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  transition: color 0.1s ease;
}

.chip-remove-btn:hover {
  color: #ef4444;
}

.asset-add-acc-input {
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  width: 75px;
  font-family: inherit;
  background: #ffffff;
  outline: none;
  transition: all 0.15s ease;
}

.asset-add-acc-input:focus {
  width: 120px;
  border-color: #2563eb;
  border-style: solid;
}

/* Note Section */
.asset-card-note-row {
  margin-top: -2px;
}

.asset-card-note-input {
  width: 100%;
  border: 1px solid transparent;
  background: #f8fafc;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11.5px;
  color: #475569;
  font-family: inherit;
  transition: all 0.15s ease;
}

.asset-card-note-input:hover,
.asset-card-note-input:focus {
  border-color: #cbd5e1;
  background: #ffffff;
  outline: none;
}

/* Empty State */
.stock-empty-state {
  grid-column: 1 / -1;
  padding: 48px 24px;
  text-align: center;
  background: #ffffff;
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-icon {
  font-size: 40px;
  line-height: 1;
}

.empty-title {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
}

.empty-desc {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 8px;
}

/* ==========================================================================
   ADD DEMO MODAL
   ========================================================================== */
.modal-card-sheet {
  max-width: 620px;
  width: 92vw;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  padding: 0;
  background: #ffffff;
}

.modal-card-sheet .modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-card-sheet .modal-title {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.modal-card-sheet .modal-subtitle {
  font-size: 12.5px;
  color: #64748b;
  margin: 2px 0 0 0;
}

.modal-card-sheet .btn-close-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-card-sheet .btn-close-icon:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.modal-card-sheet .modal-body-scroll {
  padding: 20px 22px;
  max-height: calc(85vh - 130px);
  overflow-y: auto;
}

.modal-card-sheet .modal-footer {
  padding: 14px 22px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.add-demo-modal-inner {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.add-demo-form,
.asset-detail-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-card-sheet .form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 5px;
  display: block;
}

.modal-card-sheet .form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: #1e293b;
  background: #ffffff;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.modal-card-sheet .form-control:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Field Error State & Shake Animation */
.form-control.is-invalid,
.form-control.is-invalid:focus,
.input-clearable-wrap.has-error .form-control,
.input-clearable-wrap.has-error .form-control:focus {
  border-color: #ef4444 !important;
  background-color: #fff8f8 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.22) !important;
  animation: shakeInput 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shakeInput {
  10%, 90% { transform: translate3d(-1.5px, 0, 0); }
  20%, 80% { transform: translate3d(2.5px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-3.5px, 0, 0); }
  40%, 60% { transform: translate3d(3.5px, 0, 0); }
}

.field-error-text {
  font-size: 12px;
  font-weight: 600;
  color: #dc2626 !important;
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1.3;
  animation: fieldErrorFadeIn 0.2s ease-out;
}

@keyframes fieldErrorFadeIn {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 520px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Clearable input wrap & quick clear button (✕) & dropdown arrow (▾) */
.input-clearable-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-clearable-wrap .form-control {
  padding-right: 32px !important;
}

.input-clearable-wrap.has-dropdown .form-control {
  padding-right: 56px !important;
}

.input-actions-end {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 3px;
  z-index: 5;
}

.input-actions-end .btn-input-clear,
.input-clearable-wrap > .btn-input-clear {
  position: static;
  transform: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(148, 163, 184, 0.25);
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.input-clearable-wrap > .btn-input-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.input-clearable-wrap.has-textarea > .btn-input-clear,
.input-clearable-wrap:has(textarea) > .btn-input-clear {
  position: absolute;
  top: 9px;
  right: 8px;
  transform: none;
}

.input-clearable-wrap textarea.form-control {
  min-height: 56px;
  max-height: 140px;
  line-height: 1.45;
  padding: 8px 32px 8px 12px !important;
  resize: vertical;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.input-actions-end .btn-input-clear:hover,
.input-clearable-wrap > .btn-input-clear:hover {
  background: #ef4444;
  color: #ffffff;
  transform: scale(1.15);
}

.input-clearable-wrap:not(.has-textarea) > .btn-input-clear:hover {
  transform: translateY(-50%) scale(1.15);
}

.input-clearable-wrap.has-textarea > .btn-input-clear:hover,
.input-clearable-wrap:has(textarea) > .btn-input-clear:hover {
  transform: scale(1.15);
}

.btn-input-dropdown-arrow {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.btn-input-dropdown-arrow:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-input-clear.hidden {
  display: none !important;
}

/* --------------------------------------------------------------------------
   FORM SECTION GROUPS (MINIMAL, BORDERLESS & FULL-WIDTH)
   -------------------------------------------------------------------------- */
.form-section-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.form-section-card + .form-section-card {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

.form-section-card:focus-within {
  border-color: transparent;
  box-shadow: none;
}

.section-card-header {
  display: flex;
  align-items: center;
  padding-bottom: 4px;
  border-bottom: 1.5px solid #e2e8f0;
  margin-bottom: 2px;
}

.section-card-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

@media (min-width: 769px) {
  #addDemoModalDialog.modal-card-sheet:not([open]) {
    display: none !important;
  }
  #addDemoModalDialog.modal-card-sheet[open] {
    width: 640px !important;
    max-width: 95vw !important;
    height: 86vh !important;
    height: 86dvh !important;
    max-height: 820px !important;
    min-height: 480px !important;
    border-radius: 16px !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25) !important;
    overflow: hidden !important;
    padding: 0 !important;
    background: #ffffff !important;
    display: flex !important;
    flex-direction: column !important;
  }

  #addDemoModalDialog .add-demo-modal-inner {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #addDemoModalDialog .modal-header {
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    padding: 14px 20px !important;
    border-bottom: 1px solid #e2e8f0 !important;
    background: #f8fafc !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    z-index: 5 !important;
  }

  #addDemoModalDialog .modal-body-scroll {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    background: #ffffff !important;
    padding: 16px 20px 18px !important;
    box-sizing: border-box !important;
  }

  #addDemoForm .form-section-card:last-child {
    margin-bottom: 0 !important;
  }

  #addDemoModalDialog .modal-footer {
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    background: #ffffff !important;
    border-top: 1px solid #e2e8f0 !important;
    padding: 14px 20px !important;
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center !important;
    gap: 10px !important;
    z-index: 20 !important;
    box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.05) !important;
    box-sizing: border-box !important;
  }
}

#addDemoModalDialog .modal-footer .btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

#addDemoModalDialog .modal-footer .btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.demo-acc-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  min-height: 42px;
  align-items: center;
  transition: all 0.15s ease;
}

.demo-acc-tags-container:focus-within {
  border-color: #2563eb;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.tag-add-inline {
  border: none;
  background: transparent;
  outline: none;
  font-size: 12.5px;
  font-family: inherit;
  flex: 1;
  min-width: 140px;
  color: #1e293b;
}

.tag-input-with-arrow {
  display: inline-flex;
  align-items: center;
  flex: 1;
  min-width: 160px;
  position: relative;
}

.tag-input-with-arrow .tag-add-inline {
  flex: 1;
  width: 100%;
}

.btn-tag-dropdown-arrow {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 13px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
  line-height: 1;
}

.btn-tag-dropdown-arrow:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.field-hint {
  font-size: 11.5px;
  color: #64748b;
  margin-top: 3px;
  display: block;
}

.req {
  color: #ef4444;
  font-weight: 700;
}

/* Multi-photo Gallery & Watermark Dropzone for Add Demo Modal */
.demo-multi-photos-box {
  background: #f8fafc;
  border: 1.5px dashed #cbd5e1;
  border-radius: 12px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 105px;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
  box-sizing: border-box;
}

.demo-multi-photos-box:hover,
.demo-multi-photos-box.drag-over {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.demo-multi-photos-box:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.demo-multi-photos-box.has-photos {
  justify-content: flex-start;
  align-items: stretch;
  padding: 12px;
  background: #ffffff;
}

/* Center Watermark */
.demo-upload-watermark {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  pointer-events: none;
  padding: 6px 10px;
}

.demo-upload-watermark.hidden {
  display: none !important;
}

.demo-upload-watermark .watermark-icon {
  font-size: 28px;
  line-height: 1;
  opacity: 0.45;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.demo-multi-photos-box:hover .demo-upload-watermark .watermark-icon {
  transform: scale(1.12);
  opacity: 0.85;
}

.demo-upload-watermark .watermark-text {
  font-size: 14px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: -0.01em;
  opacity: 0.85;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.demo-multi-photos-box:hover .demo-upload-watermark .watermark-text {
  color: #1d4ed8;
  opacity: 1;
}

.demo-upload-watermark .watermark-sub {
  font-size: 11.5px;
  color: #94a3b8;
  transition: color 0.2s ease;
}

.demo-multi-photos-box:hover .demo-upload-watermark .watermark-sub {
  color: #3b82f6;
}

.demo-photos-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

.demo-photos-gallery:empty {
  display: none;
}

.demo-photo-thumb-card {
  position: relative;
  width: 86px;
  height: 86px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.demo-photo-thumb-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}

.demo-photo-thumb-card.demo-photo-add-more {
  border: 1.5px dashed #93c5fd;
  background: #eff6ff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: #2563eb;
  transition: all 0.15s ease;
}

.demo-photo-thumb-card.demo-photo-add-more:hover {
  background: #dbeafe;
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.15);
}

.demo-photo-thumb-card.demo-photo-add-more .add-more-icon {
  font-size: 18px;
  line-height: 1;
}

.demo-photo-thumb-card.demo-photo-add-more .add-more-text {
  font-size: 11px;
  font-weight: 700;
}

.demo-photo-thumb-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.demo-photo-thumb-card .btn-remove-photo {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.72);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.6);
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  backdrop-filter: blur(4px);
  padding: 0;
  z-index: 2;
}

.demo-photo-thumb-card .btn-remove-photo:hover {
  background: #ef4444;
  border-color: #ef4444;
  transform: scale(1.12);
}

.demo-photo-thumb-card .primary-photo-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(37, 99, 235, 0.9);
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.2px;
  backdrop-filter: blur(3px);
  z-index: 2;
}

.demo-upload-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.btn-upload-demo-photos {
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-upload-demo-photos:hover {
  background: #eff6ff;
  border-color: #2563eb;
  color: #2563eb;
}

/* ==========================================================================
   ULTRA-COMPACT STOCK HEADER BAR (Minimal Space)
   ========================================================================== */
.stock-header-card.compact-stock-header,
.stock-header-card {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid #cbd5e1;
  border-radius: 12px 12px 0 0;
  border-bottom: 1px solid #cbd5e1;
  padding: 8px 14px;
  margin-bottom: 0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  position: sticky;
  top: 0;
  z-index: 30;
}

.stock-header-inner-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.stock-header-side-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stock-stat-total {
  font-size: 12px;
  font-weight: 600;
  background: #eff6ff;
  color: #2563eb;
  padding: 2px 10px;
  border-radius: 99px;
  border: 1px solid #dbeafe;
}

.stock-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-toggle-all-brands {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 99px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-toggle-all-brands:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

.source-chips-modern {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap !important;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.source-chips-modern::-webkit-scrollbar {
  display: none;
}

.source-chips-modern .filter-caption {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}

.chip-filter {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
  background: #f8fafc;
  color: #475569;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}

.chip-filter:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

.chip-filter.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
}

.stock-quick-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-stat-pill {
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.quick-stat-pill.avail {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.quick-stat-pill.loaned {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

/* Brand Group Block (Sheet Row Style) */
.brand-group-block {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  border-bottom: 1px solid #f1f5f9;
  position: relative;
  transition: background-color 0.15s ease;
}

.brand-group-block:last-child {
  border-bottom: none;
}

.brand-group-block:not(.is-collapsed) {
  margin-bottom: 8px;
  border-bottom: 1px solid #cbd5e1;
  background: #fcfdfd;
}

/* ==========================================================================
   SHEET-STYLE TABULAR OUTLINE GROUPING FOR BRAND CATALOG
   ========================================================================== */

/* Sheet Column Header Bar */
.stock-sheet-header {
  display: grid;
  grid-template-columns: 24px minmax(140px, 1fr) 60px 64px 64px;
  gap: 10px;
  align-items: center;
  padding: 9px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.2px;
  user-select: none;
  position: sticky;
  top: var(--stock-filter-h, 52px);
  z-index: 28;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.stock-sheet-header .sheet-th {
  display: flex;
  align-items: center;
}

.stock-sheet-header .sheet-th.col-total,
.stock-sheet-header .sheet-th.col-avail,
.stock-sheet-header .sheet-th.col-loaned {
  justify-content: center;
}

/* Header line: compact sheet row with aligned columns */
.excel-brand-line-header {
  display: grid;
  grid-template-columns: 24px minmax(140px, 1fr) 60px 64px 64px;
  gap: 10px;
  align-items: center;
  padding: 8px 14px;
  min-height: 44px;
  cursor: pointer;
  user-select: none;
  background: #ffffff;
  transition: background-color 0.12s ease;
}

.excel-brand-line-header:hover {
  background: #f1f5f9;
}

.brand-group-block:not(.is-collapsed) .excel-brand-line-header {
  background: #ffffff;
  border-bottom: 1.5px solid #cbd5e1;
  position: sticky;
  top: calc(var(--stock-filter-h, 52px) + var(--stock-sheet-th-h, 38px));
  z-index: 26;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.08);
}

.excel-brand-line-header:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

/* Excel square outline button: [-] or [+] */
.excel-outline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.excel-box-icon {
  width: 19px;
  height: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  color: #334155;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.15s ease;
}

.excel-brand-line-header:hover .excel-box-icon {
  border-color: #2563eb;
  color: #2563eb;
  background: #f8fafc;
}

/* SVG minus / plus */
.excel-minus-plus-svg {
  display: block;
}

/* When expanded: show minus [-] by hiding vertical bar */
.excel-minus-plus-svg .svg-v-bar {
  opacity: 0;
  transition: opacity 0.12s ease;
}

/* When collapsed: show plus [+] by making vertical bar visible */
.brand-group-block.is-collapsed .excel-minus-plus-svg .svg-v-bar {
  opacity: 1;
}

/* Brand Identity */
.brand-line-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.brand-avatar-mini {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.5px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.brand-line-name {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-col-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.brand-pill-mini {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "SF Mono", monospace;
  font-size: 14.5px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 5px;
  line-height: 1.25;
  white-space: nowrap;
  text-align: center;
  width: 100%;
  display: block;
  font-variant-numeric: tabular-nums;
}

.brand-pill-mini.total {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.brand-pill-mini.avail {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.brand-pill-mini.loaned {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.brand-pill-mini.loaned.is-zero {
  background: #f8fafc;
  color: #94a3b8;
  border: 1px dashed #cbd5e1;
}

/* Excel tree guide rail & body */
.excel-group-body {
  display: flex;
  position: relative;
  padding-left: 8px; /* Centered with the 17px outline icon (8.5px center) */
  margin-top: 10px;
}

.excel-group-body .stock-cards-grid {
  flex: 1;
  min-width: 0;
}

.excel-tree-rail {
  width: 16px;
  margin-right: 12px;
  flex-shrink: 0;
  position: relative;
}

/* The vertical guideline like Excel group margin */
.excel-tree-rail::before {
  content: '';
  position: absolute;
  top: -8px;
  bottom: 20px;
  left: 0;
  width: 1px;
  background: #94a3b8;
}

/* The bottom elbow bracket └── connecting to the bottom edge */
.excel-tree-rail::after {
  content: '';
  position: absolute;
  bottom: 20px;
  left: 0;
  width: 14px;
  height: 1px;
  background: #94a3b8;
}

/* When collapsed, hide the cards body completely */
.brand-group-block.is-collapsed .excel-group-body {
  display: none !important;
}

.brand-group-block.is-collapsed {
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .stock-sheet-header,
  .excel-brand-line-header {
    grid-template-columns: 20px minmax(85px, 1fr) 48px 52px 52px !important;
    gap: 6px !important;
    padding: 7px 10px !important;
    min-height: 40px !important;
  }
  .stock-sheet-header {
    font-size: 12px !important;
    font-weight: 700 !important;
    padding: 8px 10px !important;
  }
  .brand-line-name {
    font-size: 15px !important;
    font-weight: 700 !important;
  }
  .brand-avatar-mini {
    width: 22px !important;
    height: 22px !important;
    font-size: 11.5px !important;
    border-radius: 4px !important;
  }
  .brand-pill-mini {
    font-size: 14px !important;
    font-weight: 700 !important;
    padding: 2px 4px !important;
    border-radius: 4px !important;
  }
  .excel-group-body {
    padding-left: 2px;
  }
  .excel-tree-rail {
    width: 10px;
    margin-right: 8px;
  }
  .excel-tree-rail::after {
    width: 8px;
  }
}

/* ==========================================================================
   MINIMAL ASSET STOCK CARDS (FOCUSED ON MODEL & S/N)
   ========================================================================== */
.stock-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.asset-stock-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #10b981;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  position: relative;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  transition: all 0.16s cubic-bezier(0.4, 0, 0.2, 1);
}

.asset-stock-card.is-avail {
  background: #ffffff;
  border-color: #e2e8f0;
  border-left-color: #10b981;
}

.asset-stock-card.is-avail:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px -2px rgba(16, 185, 129, 0.12), 0 2px 4px rgba(15, 23, 42, 0.03);
  border-color: #a7f3d0;
}

.asset-stock-card.is-loaned {
  background: #fbfdff;
  border-color: #cbd5e1;
  border-left-color: #3b82f6;
}

.asset-stock-card.is-loaned:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px -2px rgba(59, 130, 246, 0.14), 0 2px 4px rgba(15, 23, 42, 0.03);
  border-color: #93c5fd;
}

.asset-stock-card:active {
  transform: scale(0.99);
}

/* Card Top Bar */
.asset-card-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.asset-top-tags {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 0;
}

.asset-tag-code {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 700;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  padding: 1.5px 6px;
  border-radius: 5px;
  letter-spacing: 0.2px;
}

.asset-loc-pill {
  font-size: 11px;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.asset-source-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
}

.asset-source-badge.src-demo {
  background: #eef2ff;
  color: #4f46e5;
  border-color: #c7d2fe;
}

.asset-source-badge.src-supplier {
  background: #fffbeb;
  color: #d97706;
  border-color: #fde68a;
}

.asset-source-badge.src-sales {
  background: #f0fdf4;
  color: #16a34a;
  border-color: #bbf7d0;
}

.asset-source-badge.src-repair {
  background: #ecfeff;
  color: #0e7490;
  border-color: #a5f3fc;
}

/* Clean Status Badges */
.asset-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 4.5px;
  letter-spacing: 0.1px;
  white-space: nowrap;
}

.asset-status-badge.avail {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.asset-status-badge.loaned {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.status-dot {
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.green {
  background: #10b981;
}

.status-dot.blue {
  background: #2563eb;
}

/* Hero Section: Model Name & Serial Number */
.asset-hero-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 1px 0;
}

.asset-model-hero {
  font-size: 17.5px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
  letter-spacing: -0.3px;
  word-break: break-word;
}

.asset-sn-hero {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 3px 8px;
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
}

.sn-hero-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.5px;
  background: #e2e8f0;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.2;
  flex-shrink: 0;
}

.sn-hero-value {
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: 0.3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-stock-card.is-loaned .asset-sn-hero {
  background: #eff6ff;
  border-color: #dbeafe;
}

.asset-stock-card.is-loaned .sn-hero-label {
  background: #dbeafe;
  color: #1e40af;
}

.asset-stock-card.is-loaned .sn-hero-value {
  color: #1e3a8a;
}

/* Active Loan Info (Minimal 2-Row Bar) */
.asset-loan-minimal-bar {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11.5px;
  line-height: 1.35;
  margin-top: 2px;
}

.asset-stock-card.is-loaned .asset-loan-minimal-bar {
  background: #ffffff;
  border-color: #dbeafe;
}

.loan-min-row-1 {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loan-min-icon {
  font-size: 11px;
}

.loan-min-borrower {
  font-weight: 700;
  color: #1d4ed8;
  flex-shrink: 0;
}

.loan-min-sep {
  color: #cbd5e1;
}

.loan-min-customer {
  color: #475569;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loan-min-row-2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: #64748b;
  font-size: 11px;
}

.loan-min-due strong {
  color: #d97706;
  font-weight: 700;
}

/* Subtle Accessories / Note */
.asset-acc-mini-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-top: 2px;
}

.acc-mini-text,
.note-mini-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Detail Modal Loan Callout */
.asset-detail-loan-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-loan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-loan-badge {
  font-size: 12px;
  font-weight: 700;
  color: #1d4ed8;
}

.detail-loan-id {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11.5px;
  font-weight: 700;
  background: #dbeafe;
  color: #1e40af;
  padding: 2px 7px;
  border-radius: 5px;
}

.detail-loan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.detail-loan-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-loan-item .item-label {
  font-size: 11px;
  color: #64748b;
  font-weight: 500;
}

.detail-loan-item .item-val {
  font-size: 12.5px;
  color: #0f172a;
  font-weight: 600;
}

.detail-loan-item .item-val.text-blue {
  color: #2563eb;
}

/* Jump link in active loan callout */
.detail-loan-footer-action {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed #bfdbfe;
}

.btn-jump-history {
  background: transparent;
  border: none;
  color: #2563eb;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-jump-history:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

/* Asset Modal Tabs Navigation */
.asset-detail-nav-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 22px 0 22px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.asset-nav-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  background: transparent;
  border: none;
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  border-radius: 8px 8px 0 0;
  margin-bottom: -1px;
}

.asset-nav-tab-btn:hover {
  color: #0f172a;
  background: rgba(148, 163, 184, 0.08);
}

.asset-nav-tab-btn.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  background: #ffffff;
  font-weight: 700;
}

.history-count-badge {
  font-size: 10.5px;
  font-weight: 700;
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  padding: 1px 6px;
  border-radius: 99px;
  line-height: 1.2;
}

.asset-nav-tab-btn.active .history-count-badge {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

/* Tab Panes */
.asset-tab-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.asset-tab-pane.hidden {
  display: none !important;
}

/* ==========================================================================
   FULLSCREEN ASSET DETAIL MODAL DIALOG (Consistent with other views)
   ========================================================================== */
#assetDetailModalDialog.modal-fullscreen {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  border-radius: 0;
  border: none;
  background: #f8fafc;
}

#assetDetailModalDialog .asset-detail-modal-inner {
  height: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f8fafc;
}

#assetDetailModalDialog .modal-header.asset-modal-header-v2 {
  flex: 0 0 auto;
  padding: 12px 24px !important;
  background: #ffffff !important;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 14px !important;
  box-sizing: border-box !important;
}

#assetDetailModalDialog .fullscreen-header-left {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  flex: 1 !important;
  min-width: 0 !important;
}

#assetDetailModalDialog .asset-detail-nav-tabs {
  flex: 0 0 auto;
  padding: 8px 24px 0 24px;
}

#assetDetailModalDialog .modal-body-scroll {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px 24px;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

#assetDetailModalDialog.tab-history-active .modal-body-scroll,
#assetDetailModalDialog .modal-body-scroll:has(#assetTabPaneHistory:not(.hidden)) {
  padding: 0 !important;
  overflow: hidden !important;
  background: #fbf9f4 !important;
}

#assetDetailModalDialog .asset-tab-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

#assetDetailModalDialog #assetTabPaneInfo {
  height: auto;
}

#assetDetailModalDialog #assetTabPaneHistory:not(.hidden) {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 100% !important;
  width: 100% !important;
  margin: 0 !important;
}

#assetDetailModalDialog .modal-footer {
  display: none !important;
}

/* ==========================================================================
   BORDERLESS FULLSCREEN LIBRARY CIRCULATION SHEET (บัตรประวัติการยืม-คืน)
   ========================================================================== */
.library-card-wrapper {
  background: #fbf9f4;
  border: none !important;
  border-left: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box;
  overflow: hidden;
}

/* Redesigned Clean Header */
.library-card-header {
  padding: 12px 20px;
  background: #f7f3ea;
  border-bottom: 1px solid #ded5c4;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
}

.lib-header-row-primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lib-title-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
}

.lib-title-wrap .lib-icon {
  font-size: 16px;
  line-height: 1;
}

.lib-title-wrap .lib-title-text {
  font-size: 15px;
  font-weight: 700;
  color: #332f2b;
  letter-spacing: -0.2px;
}

.lib-header-status-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lib-status-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1.2;
  text-decoration: none;
  border: 1px solid transparent;
}

.lib-status-pill.avail {
  background: #f0fdf4;
  color: #166534;
  border-color: rgba(34, 197, 94, 0.25);
}

.lib-status-pill.loaned {
  background: #eff6ff;
  color: #1e40af;
  border-color: rgba(59, 130, 246, 0.3);
  cursor: pointer;
  transition: all 0.15s ease;
}

.lib-status-pill.loaned:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
  transform: translateY(-1px);
}

.lib-header-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #57534e;
  flex-wrap: wrap;
}

.lib-meta-badge.tag {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  background: #e7dfce;
  color: #292524;
  padding: 1.5px 7px;
  border-radius: 4px;
  border: 1px solid #d3c8b4;
}

.lib-meta-text.model {
  font-weight: 600;
  color: #1c1917;
}

.lib-meta-sep {
  color: #a8a29e;
  font-size: 10px;
}

.lib-meta-text.sn {
  color: #78716c;
}

.lib-meta-text.sn strong {
  color: #292524;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
  align-items: flex-end;
  gap: 3px;
}

.lib-stat-badge {
  font-size: 11px;
  font-weight: 700;
  background: #e7dfce;
  color: #44403c;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid #d3c8b4;
}

.lib-curr-status {
  font-size: 11.5px;
  font-weight: 700;
  color: #0f172a;
}

/* Library Sheet & Table */
.library-sheet-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  background: #ffffff;
  -webkit-overflow-scrolling: touch;
}

.library-card-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  table-layout: fixed;
}

.library-card-table th {
  background: #f7f3ea;
  color: #57534e;
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid #ded5c4;
  border-right: 1px solid #ede7db;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}

.library-card-table th:last-child {
  border-right: none;
}

.library-card-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #e7e2d6;
  border-right: 1px solid #f1ece1;
  font-size: 12px;
  vertical-align: middle;
  height: 54px;
  box-sizing: border-box;
}

.library-card-table td:last-child {
  border-right: none;
}

.library-card-table tr:hover td {
  background: #fdfcf8;
}

.lib-date-val {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  color: #292524;
  white-space: nowrap;
  letter-spacing: -0.2px;
}

.lib-date-val.due-ongoing {
  color: #2563eb;
  font-weight: 700;
}

.lib-date-val.returned-ok {
  color: #059669;
  font-weight: 700;
}

.lib-borrower-name {
  font-weight: 600;
  color: #1c1917;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.lib-borrower-role {
  font-size: 10.5px;
  color: #78716c;
  white-space: nowrap;
}

.lib-company-name {
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: middle;
}

.lib-loan-slip-tag {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 1px 5px;
  border-radius: 4px;
  display: inline-block;
  white-space: nowrap;
  flex-shrink: 0;
  margin-right: 4px;
}

.lib-acc-summary {
  font-size: 10.5px;
  color: #64748b;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Rubber Stamp Seals */
.lib-stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3px;
  border-radius: 5px;
  border: 1.5px solid currentColor;
  transform: rotate(-1.5deg);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7) inset;
  line-height: 1.1;
  text-align: center;
}

.lib-stamp.stamped-ongoing {
  color: #1d4ed8;
  border-color: #3b82f6;
  background: #eff6ff;
}

.lib-stamp.stamped-returned {
  color: #047857;
  border-color: #10b981;
  background: #ecfdf5;
}

.lib-stamp.stamped-overdue {
  color: #b91c1c;
  border-color: #ef4444;
  background: #fef2f2;
}

/* Blank Ruled Row for Library Card */
.lib-blank-row td {
  background: #ffffff;
  color: #d6d3d1;
  text-align: center;
  font-size: 14px;
  font-family: monospace;
}

.lib-blank-row:hover td {
  background: #ffffff;
}

/* Pagination Footer */
.library-card-pagination {
  background: #f5f0e6;
  border-top: 1.5px solid #ded5c4;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  margin-top: auto;
}

.lib-page-info {
  font-size: 12px;
  color: #57534e;
  font-weight: 500;
}

.lib-page-info span {
  font-weight: 700;
  color: #1c1917;
}

.lib-total-records {
  font-size: 11px;
  color: #78716c;
  margin-left: 4px;
}

.lib-page-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-lib-nav {
  background: #ffffff;
  border: 1px solid #d3c8b4;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: #44403c;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-lib-nav:hover:not(:disabled) {
  background: #e7dfce;
  border-color: #b8ac95;
  color: #1c1917;
}

.btn-lib-nav:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #f5f0e6;
  border-color: #e5dfd3;
}

.lib-page-pills {
  display: flex;
  align-items: center;
  gap: 3px;
}

.lib-page-pill-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 1px solid transparent;
  font-size: 11.5px;
  font-weight: 600;
  color: #57534e;
  background: transparent;
  cursor: pointer;
}

.lib-page-pill-btn:hover {
  background: #e7dfce;
  color: #1c1917;
}

.lib-page-pill-btn.active {
  background: #44403c;
  color: #ffffff;
  font-weight: 700;
}

.acc-title-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

/* Sleek Luxury Minimal Asset Detail Header v2 */
.asset-modal-header-v2,
#assetDetailModalDialog .modal-header.asset-modal-header-v2 {
  padding: 14px 22px;
  background: #ffffff;
  border-bottom: 1px solid rgba(226, 232, 240, 0.7);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: auto;
  min-height: 64px;
  box-sizing: border-box;
}

.asset-header-left {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.asset-device-avatar {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;
  background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  flex-shrink: 0;
}

.asset-header-info-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.asset-header-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.asset-header-title {
  font-size: 20px !important;
  font-weight: 700 !important;
  color: #0f172a !important;
  margin: 0 !important;
  line-height: 1.25 !important;
  letter-spacing: -0.025em !important;
}

/* S/N Badge in Asset Header */
.asset-header-sn-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 8px 2.5px 6px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 11.5px;
  color: #334155;
  white-space: nowrap;
  letter-spacing: -0.1px;
  line-height: 1.2;
}

.asset-header-sn-badge .sn-lbl {
  font-size: 9.5px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  background: #e2e8f0;
  padding: 1px 4.5px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}

.asset-header-sn-badge .sn-code {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
  font-weight: 700;
  color: #0f172a;
}

/* Asset Status Pill in Header Meta */
.asset-status-pill,
.asset-header-meta-row .asset-status-pill,
.asset-header-title-row .asset-status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 4.5px;
  letter-spacing: 0.1px;
  line-height: 1.2;
}

.asset-status-pill.avail {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid rgba(34, 197, 94, 0.28);
}

.asset-status-pill.loaned {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid rgba(59, 130, 246, 0.28);
}

.asset-status-pill .status-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.asset-status-pill .status-indicator-dot.avail {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.asset-status-pill .status-indicator-dot.loaned {
  background: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* ============================================================================
   UNIVERSAL CLICKABLE DOCUMENT LINK PILL (เลขที่เอกสาร / ใบยืมจริง ทุกหน้า)
   ============================================================================ */
.doc-link-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 2px 7px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  color: #1d4ed8 !important;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
  transition: all 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.05);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  vertical-align: middle;
  line-height: 1.25;
  outline: none;
  white-space: nowrap !important;
  word-break: keep-all !important;
  flex-shrink: 0;
}

.doc-link-pill .doc-link-icon {
  flex-shrink: 0;
  color: #2563eb;
  transition: transform 0.15s ease, color 0.15s ease;
}

.doc-link-pill:hover {
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #1d4ed8 !important;
  box-shadow: 0 3px 8px -1px rgba(37, 99, 235, 0.35) !important;
  transform: translateY(-1px);
}

.doc-link-pill:hover .doc-link-icon {
  color: #ffffff !important;
  transform: translate(1.5px, -1.5px);
}

.doc-link-pill:active {
  transform: scale(0.94) translateY(0);
  background: #1e40af !important;
}

/* Inside Loan Box in Asset Detail */
.doc-link-loan-box {
  padding: 4px 10px;
  font-size: 12.5px;
  border-radius: 7px;
}

/* Inside Kanban Cards */
.kanban-doc-pill {
  margin: 0;
  padding: 1.5px 6px;
  font-size: 11px;
}

/* Inside List View Tables */
.list-doc-pill {
  padding: 3px 8px;
  font-size: 12px;
}

/* Inside Stock View Cards */
.stock-loan-pill {
  padding: 2px 7px;
  font-size: 11px;
}

.asset-header-meta-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #64748b;
  line-height: 1.3;
}

/* Luxury minimal asset tag */
.asset-header-meta-row .asset-tag-badge {
  background: #f8fafc;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  padding: 1.5px 7px;
  border-radius: 5px;
  letter-spacing: 0.4px;
  font-family: 'SF Mono', ui-monospace, Menlo, monospace;
}

.asset-header-meta-row .asset-source-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 1.5px 7px;
  border-radius: 5px;
}

.asset-header-meta-row .asset-source-pill.src-demo {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.asset-header-meta-row .asset-source-pill.src-supplier {
  background: #f5f3ff;
  color: #7c3aed;
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.asset-header-meta-row .asset-source-pill.src-sales {
  background: #fff7ed;
  color: #ea580c;
  border: 1px solid rgba(234, 88, 12, 0.2);
}

.asset-header-meta-row .asset-source-pill.src-repair {
  background: #ecfeff;
  color: #0e7490;
  border: 1px solid rgba(14, 116, 144, 0.25);
}

.asset-header-meta-row .meta-dot {
  color: #cbd5e1;
  font-size: 9px;
}

.asset-header-meta-row .meta-sn-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #94a3b8;
  font-size: 11.5px;
}

.asset-header-meta-row .meta-sn-wrap strong {
  color: #475569;
  font-weight: 600;
  font-size: 11.5px;
}

.asset-header-meta-row .meta-cat-val {
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
}

/* Minimal Luxury Close Button */
#assetDetailModalDialog .btn-close-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  color: #94a3b8 !important;
  font-size: 15px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  box-shadow: none !important;
}

#assetDetailModalDialog .btn-close-icon:hover {
  background: #f1f5f9 !important;
  color: #0f172a !important;
}

#assetDetailModalDialog .btn-close-icon:focus {
  outline: none !important;
}

.asset-modal-header-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.asset-modal-tag-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Add Demo Image Box */
.demo-image-upload-box {
  background: #f8fafc;
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  transition: border-color 0.15s ease;
}

.demo-image-upload-box:hover {
  border-color: #94a3b8;
}

.demo-image-placeholder-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
}

.demo-image-placeholder-drop .upload-icon {
  font-size: 26px;
}

.demo-image-placeholder-drop .upload-prompt {
  font-size: 12px;
  color: #64748b;
}

.demo-image-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.demo-thumb-preview {
  max-width: 100%;
  max-height: 150px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 4px;
}

/* Asset Detail Modal Photo Section */
.asset-detail-photo-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.asset-detail-photo-preview-wrap {
  width: 130px;
  height: 95px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.detail-hero-thumb {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  padding: 4px;
}

.detail-photo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #94a3b8;
  padding: 6px;
  text-align: center;
}

.detail-photo-empty .empty-icon {
  font-size: 20px;
}

.detail-photo-empty .empty-text {
  font-size: 11px;
}

.asset-detail-photo-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  flex: 1;
}

/* ==========================================================================
   ASSET DETAIL: READ-ONLY VIEW WITH INLINE FIELD-BY-FIELD EDITING
   ========================================================================== */
.asset-detail-sections-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-section-block {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.detail-section-block.is-editing {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
  background: #fbfdff;
}

.detail-section-block.is-editing .btn-inline-edit {
  display: none;
}

/* In-place Source Selection List (List only, no typing) */
.source-select-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.source-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  gap: 8px;
}

.source-select-option:hover {
  background: #f8fafc;
  border-color: #93c5fd;
  transform: translateX(2px);
}

.source-select-option:active {
  transform: scale(0.99);
}

.source-select-option.is-selected {
  background: #eff6ff;
  border-color: #3b82f6;
  box-shadow: 0 0 0 1.5px rgba(59, 130, 246, 0.25);
}

.source-option-main {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.source-option-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.source-option-text {
  display: flex;
  flex-direction: column;
  gap: 1.5px;
  min-width: 0;
}

.source-option-name {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.25;
}

.source-select-option.is-selected .source-option-name {
  color: #1d4ed8;
}

.source-option-sub {
  font-size: 11px;
  color: #64748b;
  line-height: 1.2;
}

.source-option-end {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.source-option-count {
  font-size: 11px;
  font-weight: 600;
  color: #059669;
  background: #ecfdf5;
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 1.5px 7px;
  border-radius: 99px;
  white-space: nowrap;
}

.source-option-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: transparent;
  background: #ffffff;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.source-select-option.is-selected .source-option-check {
  border-color: #3b82f6;
  background: #3b82f6;
  color: #ffffff;
}

.source-list-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.btn-cancel-edit-source {
  background: transparent;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-cancel-edit-source:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

.detail-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}

.detail-section-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-section-icon {
  font-size: 14px;
}

.detail-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  letter-spacing: -0.1px;
}

.detail-section-count {
  font-size: 11px;
  font-weight: 600;
  background: #f1f5f9;
  color: #64748b;
  padding: 1px 7px;
  border-radius: 99px;
  border: 1px solid #e2e8f0;
}

.btn-inline-edit {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: transparent;
  color: #94a3b8;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.btn-inline-edit:hover {
  background: #f1f5f9;
  color: #2563eb;
}

.detail-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 640px) {
  .detail-grid-2 {
    grid-template-columns: 1fr;
  }
}

.detail-field-view {
  min-height: 24px;
  display: flex;
  align-items: center;
}

.detail-val-box {
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
  word-break: break-word;
}

.detail-val-box .asset-source-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.detail-empty-text {
  color: #94a3b8;
  font-style: italic;
  font-size: 12.5px;
  font-weight: 400;
}

.detail-note-view-text {
  font-size: 13px;
  color: #334155;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8fafc;
  border-radius: 6px;
  padding: 8px 10px;
  border: 1px solid #f1f5f9;
  width: 100%;
  box-sizing: border-box;
}

.detail-photos-gallery-readonly {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  width: 100%;
}

.detail-photo-thumb-readonly {
  width: 84px;
  height: 84px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.detail-photo-thumb-readonly:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.detail-photo-thumb-readonly img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.detail-photo-thumb-readonly .primary-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  font-size: 9.5px;
  font-weight: 700;
  background: rgba(37, 99, 235, 0.9);
  color: #ffffff;
  padding: 1px 5px;
  border-radius: 4px;
  line-height: 1.1;
}

.detail-photos-empty-view {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #94a3b8;
  font-size: 13px;
  padding: 6px 2px;
}

.detail-acc-chips-readonly {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 28px;
  width: 100%;
}

.detail-acc-chip-ro {
  display: inline-flex;
  align-items: center;
  background: #f8fafc;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
}

.detail-field-edit {
  margin-top: 6px;
}

.detail-inline-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-top: 0;
  border-top: none;
}

.btn-action-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  line-height: 1;
  padding: 0;
  user-select: none;
}

.btn-action-icon.cancel {
  background: #f8fafc;
  color: #94a3b8;
  border-color: #e2e8f0;
}

.btn-action-icon.cancel:hover {
  background: #fef2f2;
  color: #ef4444;
  border-color: #fecaca;
}

.btn-action-icon.save {
  background: #10b981;
  color: #ffffff;
  border-color: #059669;
  box-shadow: 0 1px 2px rgba(16, 185, 129, 0.2);
}

.btn-action-icon.save:hover {
  background: #059669;
}

.btn-action-icon:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================================================
   COMPANY SETTINGS MODAL & BUTTON (Minimal Luxury)
   ============================================================================ */
.btn-company-settings {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-weight: 500;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-company-settings:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

/* Fullscreen Company & System Settings Modal */
dialog.modal-company-settings,
dialog.modal-company-settings.modal-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-height: 100vh !important;
  max-height: 100dvh !important;
  margin: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  background: #f8fafc !important;
  overflow: hidden !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}

.company-settings-inner {
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  background: #f8fafc !important;
}

.company-settings-header {
  height: 52px;
  min-height: 52px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  z-index: 10;
}

.company-settings-header-title {
  font-size: 15.5px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.company-main-tabs {
  display: flex;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 20px 0;
  gap: 4px;
  flex-shrink: 0;
  overflow-x: auto;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.02);
}

.company-main-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: #64748b;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.company-main-tab:hover {
  color: #0f172a;
  background: rgba(241, 245, 249, 0.6);
}

.company-main-tab.is-active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  background: transparent;
}

.company-settings-body {
  padding: 20px 24px;
  flex: 1 1 auto !important;
  overflow-y: auto !important;
  box-sizing: border-box;
}

/* Tab 1, 2, 3 Clean Card Container */
#tabPanelCompanyInfo,
#tabPanelCompanyEmail,
#tabPanelCompanyAuth {
  max-width: 860px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  padding: 24px 28px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}

.company-main-tab svg {
  color: inherit;
  flex-shrink: 0;
}

.company-tab-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.company-tab-panel.hidden {
  display: none !important;
}

.email-tab-content {
  border-bottom: none !important;
  padding-bottom: 0 !important;
}

.company-settings-body {
  padding: 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1 1 auto !important;
  overflow-y: auto !important;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  dialog.modal-company-settings,
  dialog.modal-company-settings.modal-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: #f8fafc !important;
    padding: 0 !important;
  }

  .company-settings-inner {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
  }

  .company-settings-header {
    height: 48px !important;
    min-height: 48px !important;
    padding: 0 12px !important;
  }

  .fullscreen-header-left {
    gap: 8px !important;
    min-width: 0 !important;
    flex: 1 !important;
  }

  .btn-back-nav {
    padding: 4px 8px !important;
    font-size: 12px !important;
    flex-shrink: 0 !important;
  }

  .company-settings-header-title {
    font-size: 13.5px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .btn-header-save-settings {
    padding: 5px 10px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  /* Smooth horizontal scrolling tabs on mobile */
  .company-main-tabs {
    padding: 4px 10px 0 !important;
    margin: 0 !important;
    gap: 4px !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .company-main-tabs::-webkit-scrollbar {
    display: none !important;
  }

  .company-main-tab {
    padding: 8px 12px !important;
    font-size: 12.5px !important;
    gap: 5px !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
  }

  .company-settings-body {
    padding: 12px 14px 20px !important;
    gap: 12px !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Hide duplicate bottom footer in fullscreen mode on mobile */
  .modal-company-settings .modal-footer {
    display: none !important;
  }
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f8fafc;
}

.settings-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.company-logo-uploader {
  display: flex;
  align-items: center;
  gap: 14px;
  background: transparent;
  border: none;
  padding: 2px 0;
}

.company-logo-preview {
  width: 104px;
  height: 48px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  padding: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.company-logo-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.logo-placeholder {
  font-size: 11.5px;
  color: #94a3b8;
  text-align: center;
  font-weight: 400;
}

.company-logo-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.logo-btn-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.logo-btn-group .btn-secondary {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.logo-btn-group .btn-secondary:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}

.logo-btn-group .btn-ghost.text-danger {
  background: transparent;
  border: none;
  color: #ef4444;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.logo-btn-group .btn-ghost.text-danger:hover {
  background: #fef2f2;
}

.company-settings-card .form-label {
  font-size: 11.5px;
  font-weight: 500;
  color: #64748b;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  min-height: 18px;
  line-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.company-settings-card .form-control {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 13px;
  color: #0f172a;
  background: #ffffff;
  width: 100%;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.company-settings-card input.form-control {
  height: 38px;
}

.company-settings-card .input-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
  height: 38px;
}

.company-settings-card .form-control:focus {
  border-color: #0f172a;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
  outline: none;
}

.company-settings-card .form-control::placeholder {
  color: #cbd5e1;
  font-weight: 400;
}

.company-settings-card .form-hint {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 1px;
}

.company-settings-card .modal-footer {
  padding: 12px 22px 16px 22px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.company-settings-card .btn-dark {
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #0f172a;
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
  padding: 7px 20px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}

.company-settings-card .btn-dark:hover {
  background: #1e293b;
  border-color: #1e293b;
}

.company-settings-card .btn-outline {
  background: #ffffff;
  color: #64748b;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
  padding: 7px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.company-settings-card .btn-outline:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #cbd5e1;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

/* ============================================================================
   MINIMAL STEP-BY-STEP ORDER PICKING (หน้าจัดของ & สแกน S/N)
   ============================================================================ */
.dispatch-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dispatch-modal-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16.5px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.3;
}

.dispatch-title-sep {
  color: #cbd5e1;
  font-weight: 400;
}

.dispatch-title-loan-id {
  color: #475569;
  font-size: 15px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.dispatch-title-subline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dispatch-mobile-loan-code {
  display: none;
}

.badge-stage-picking {
  background: #f3e8ff;
  color: #7e22ce;
  border: 1px solid #d8b4fe;
  font-size: 11px;
  font-weight: 650;
  padding: 2px 9px;
  border-radius: 999px;
}

.fullscreen-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.btn-header-printpass {
  font-size: 12px;
  font-weight: 550;
  padding: 5px 12px;
  border-radius: 7px;
  border: 1px solid #cbd5e1;
  color: #334155;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  cursor: pointer;
}

.btn-header-printpass:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.dispatch-modal-body {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 24px 36px !important;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Minimal 2-Step Navigation */
.picking-step-nav {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 6px;
  gap: 8px;
}

.picking-step-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.picking-step-btn:hover {
  background: #f1f5f9;
}

.picking-step-btn.active {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.step-num-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.picking-step-btn.active .step-num-circle {
  background: #6366f1;
  color: #ffffff;
}

.step-nav-text {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.step-nav-title {
  font-size: 13px;
  color: #0f172a;
  font-weight: 700;
}

.step-nav-sub {
  font-size: 11px;
  color: #64748b;
}

.step-count-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
}

.picking-step-btn.active .step-count-pill {
  background: #eef2ff;
  color: #4f46e5;
}

.step-nav-divider {
  color: #cbd5e1;
  font-size: 14px;
  font-weight: bold;
}

/* Step Panels */
.picking-step-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.picking-step-panel.hidden {
  display: none !important;
}

/* Fast Barcode Scanner Input Bar */
.barcode-scanner-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  padding: 6px 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.15s ease;
  position: relative;
}

.barcode-scanner-bar:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.scanner-icon-wrap {
  color: #6366f1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dispatch-barcode-input {
  border: none !important;
  box-shadow: none !important;
  padding: 6px 0 !important;
  font-size: 14px !important;
  font-weight: 500;
  flex: 1;
  background: transparent !important;
}

.dispatch-barcode-input:focus {
  outline: none !important;
}

.barcode-scanner-bar .dispatch-barcode-actions {
  position: static;
  transform: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.btn-dispatch-camera-scan {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-dispatch-camera-scan:hover {
  background: #eef2ff;
  border-color: #6366f1;
  color: #4f46e5;
  box-shadow: 0 1px 3px rgba(99, 102, 241, 0.15);
}

.btn-dispatch-camera-scan:active {
  transform: scale(0.96);
}

.btn-dispatch-camera-scan svg {
  stroke: currentColor;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .btn-dispatch-camera-scan .btn-cam-text {
    display: none;
  }
  .btn-dispatch-camera-scan {
    padding: 6px 8px;
  }
}

.btn-input-camera-scan {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: #64748b;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.btn-input-camera-scan:hover {
  background: #f1f5f9;
  color: #2563eb;
}

.btn-input-camera-scan:active {
  transform: scale(0.92);
}

/* Minimal Picking Cards List */
.picking-cards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.picking-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.15s ease;
}

.picking-card.pending {
  border-left: 4px solid #f59e0b;
}

.picking-card.matched {
  border-left: 4px solid #10b981;
  background: #fbfdfc;
}

.picking-card-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.pick-info-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.pick-model-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.pick-location-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.pick-loc-badge {
  font-size: 12px;
  font-weight: 600;
  color: #0369a1;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pick-avail-stock {
  font-size: 11.5px;
  font-weight: 600;
  color: #15803d;
}

.pick-avail-stock.out {
  color: #dc2626;
}

/* S/N Scan & Matching Action Column */
.pick-action-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 320px;
}

.pick-status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pick-status-pill.pending {
  background: #fef3c7;
  color: #b45309;
}

.pick-status-pill.matched {
  background: #dcfce7;
  color: #15803d;
}

.pick-matched-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 6px 12px;
  border-radius: 8px;
  width: 100%;
  justify-content: space-between;
}

.pick-matched-text {
  font-size: 12.5px;
  color: #15803d;
}

.pick-matched-text strong {
  font-family: ui-monospace, Menlo, Monaco, monospace;
}

.btn-unpick-sn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.12s ease;
}

.btn-unpick-sn:hover {
  color: #ef4444;
  background: #fee2e2;
}

.pick-sn-select {
  width: 100%;
  height: 36px;
  border-radius: 7px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-size: 12.5px;
  color: #1e293b;
  padding: 0 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pick-sn-select:focus {
  border-color: #6366f1;
  outline: none;
}

/* Accessories & Tags inside Picking Card */
.pick-card-sub {
  border-top: 1px solid #f1f5f9;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.pick-acc-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pick-acc-title {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
}

.pick-tag-chip {
  font-size: 11px;
  color: #334155;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 2px 7px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pick-tag-chip button {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 11px;
  padding: 0;
}

.pick-tag-chip button:hover {
  color: #ef4444;
}

.btn-add-acc-chip {
  background: transparent;
  border: 1px dashed #cbd5e1;
  color: #6366f1;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-add-acc-chip:hover {
  background: #eef2ff;
  border-color: #6366f1;
}

/* Step Footer Actions */
.step-footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
}

.step-status-hint {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.btn-next-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: 8px;
}

/* Demo Photo Box */
.demo-photo-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.demo-photo-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.demo-photo-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #0f172a;
}

.demo-photo-sub {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

.proof-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.dispatch-photo-dropzone {
  margin-top: 10px;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 12px;
  background: #f8fafc;
  min-height: 120px;
  transition: all 0.15s ease;
}

.dispatch-photo-dropzone.dragover {
  border-color: #6366f1;
  background: #eef2ff;
}

.photo-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.photo-card-item {
  position: relative;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
}

.photo-card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  cursor: pointer;
  background: #0f172a;
}

.photo-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.photo-card-media:hover img {
  transform: scale(1.05);
}

.photo-zoom-hint {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(15, 23, 42, 0.75);
  color: #ffffff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.photo-card-media:hover .photo-zoom-hint {
  opacity: 1;
}

.photo-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
}

.photo-card-num {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
}

.btn-rm-photo {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 3px;
  transition: all 0.12s ease;
}

.btn-rm-photo:hover {
  color: #ef4444;
  background: #fee2e2;
}

.dispatch-photo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 16px;
  gap: 6px;
}

.empty-photo-icon {
  font-size: 30px;
  opacity: 0.6;
}

.empty-photo-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #334155;
}

.empty-photo-sub {
  font-size: 12px;
  color: #64748b;
  max-width: 460px;
}

.btn-save-dispatch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 22px;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.btn-save-dispatch:disabled,
.btn-save-dispatch.is-disabled {
  opacity: 0.55 !important;
  background: #cbd5e1 !important;
  border-color: #cbd5e1 !important;
  color: #64748b !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
  transform: none !important;
}

.btn-save-dispatch:disabled:hover,
.btn-save-dispatch.is-disabled:hover {
  background: #cbd5e1 !important;
  color: #64748b !important;
}

.card-tap-dispatch {
  color: #6366f1 !important;
  font-weight: 600 !important;
}

/* Modal Mismatch Sheet & Substitution Selector */
.modal-mismatch-sheet {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: 560px;
  width: 92vw;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
  background: #ffffff;
  overflow: hidden;
}

.modal-mismatch-sheet::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.mismatch-dialog-content {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
}

.mismatch-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
}

.mismatch-icon-bubble {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fef3c7;
  color: #b45309;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mismatch-title-group {
  flex: 1;
}

.mismatch-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.mismatch-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: #64748b;
}

.mismatch-scanned-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 14px 0 16px;
}

.scanned-card-label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.scanned-card-details {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.scanned-model-name {
  font-size: 14.5px;
  font-weight: 700;
  color: #0f172a;
}

.scanned-sn-badge {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
}

.scanned-sn-badge strong {
  font-family: ui-monospace, Menlo, Monaco, monospace;
}

.scanned-tag-badge {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
}

.mismatch-choice-section {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}

.mismatch-choice-label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}

.mismatch-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.mismatch-option-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
  background: #ffffff;
  transition: all 0.15s ease;
}

.mismatch-option-card:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.mismatch-option-card.selected {
  border-color: #6366f1;
  background: #f5f3ff;
}

.mismatch-option-radio {
  width: 17px;
  height: 17px;
  accent-color: #6366f1;
  cursor: pointer;
}

.mismatch-opt-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.mismatch-opt-title {
  font-size: 13px;
  color: #0f172a;
}

.mismatch-opt-status {
  font-size: 11.5px;
  color: #64748b;
}

.mismatch-opt-status.empty {
  color: #b45309;
  font-weight: 600;
}

.mismatch-opt-status.filled {
  color: #64748b;
}

.mismatch-footer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid #f1f5f9;
  padding-top: 14px;
}

/* ============================================================================
   MINIMAL DISPATCH MODAL (คล้ายออกใบยืม — EXCEL-LIKE SHEET & ROW PHOTO ICON)
   ============================================================================ */
.dispatch-summary-strip {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.summary-strip-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.strip-label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.strip-label svg {
  color: #94a3b8;
  flex-shrink: 0;
}

.th-icon-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.th-icon-title svg {
  color: #64748b;
  flex-shrink: 0;
}

.strip-val {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
}

.summary-strip-divider {
  width: 1px;
  height: 28px;
  background: #e2e8f0;
}

.dispatch-table-wrap {
  width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

.dispatch-table {
  width: 100% !important;
  table-layout: fixed !important;
  border-collapse: collapse !important;
}

.dispatch-table thead th {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  box-sizing: border-box;
}

.dispatch-table thead th.col-num {
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  text-align: center;
}

.dispatch-table thead th.col-model {
  width: 33% !important;
}

.dispatch-table thead th.col-sn {
  width: 28% !important;
}

.dispatch-table thead th.col-acc {
  width: 23% !important;
}

.dispatch-table thead th.col-photo {
  width: 64px !important;
  min-width: 64px !important;
  max-width: 64px !important;
  text-align: center;
}

.dispatch-table thead th.col-toggle {
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  text-align: center;
}

.dispatch-table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
  box-sizing: border-box;
}

.dispatch-table tbody tr.dispatch-row td:nth-child(1) {
  width: 40px;
  max-width: 40px;
  text-align: center;
}

.dispatch-table tbody tr.dispatch-row td:nth-child(2) {
  width: 33%;
  overflow: hidden;
}

.dispatch-table tbody tr.dispatch-row td:nth-child(3) {
  width: 28%;
  overflow: hidden;
}

.dispatch-table tbody tr.dispatch-row td:nth-child(4) {
  width: 23%;
  overflow: hidden;
}

.dispatch-table tbody tr.dispatch-row td:nth-child(5) {
  width: 64px;
  max-width: 64px;
  text-align: center;
}

.dispatch-table tbody tr.dispatch-row td:nth-child(6) {
  width: 40px;
  max-width: 40px;
  text-align: center;
}

/* ============================================================================
   IN-LINE ACCORDION PICKING SHEET (Ultra-Minimal Quiet Luxury)
   ============================================================================ */
.barcode-scanner-minimal {
  padding: 6px 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  margin-bottom: 12px;
}

.dispatch-table tbody tr.dispatch-row {
  cursor: pointer;
  transition: all 0.12s ease;
}

.dispatch-table tbody tr.dispatch-row:hover td {
  background: #f8fafc;
}

.dispatch-table tbody tr.dispatch-row.row-picked td {
  background: #fcfdfd;
}

.dispatch-table tbody tr.dispatch-row.row-picked:hover td {
  background: #f0fdf4;
}

.dispatch-table tbody tr.dispatch-row.row-expanded td {
  background: #f8fafc;
  border-bottom: none;
}

.stock-mini {
  font-size: 11px;
  color: #059669;
  font-weight: 500;
}

.stock-mini.out {
  color: #ef4444;
}

.sn-picked-display {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  background: #ecfdf5;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #86efac;
  color: #15803d;
  white-space: nowrap;
}

.sn-picked-display.is-returned-sn {
  background: #ecfdf5 !important;
  border-color: #86efac !important;
  color: #15803d !important;
}
.sn-picked-display.is-returned-sn .sn-picked-val {
  color: #15803d !important;
}

.sn-picked-display.is-pending-sn {
  background: #fff7ed !important;
  border-color: #fdba74 !important;
  color: #c2410c !important;
}
.sn-picked-display.is-pending-sn .sn-picked-val {
  color: #c2410c !important;
}

.sn-picked-display.is-unreturned-sn {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #334155 !important;
}
.sn-picked-display.is-unreturned-sn .sn-picked-val {
  color: #334155 !important;
  font-weight: 600 !important;
}

/* Desktop row states */
.dispatch-table tbody tr.dispatch-row.row-item-returned td {
  background: #f0fdf4 !important;
}

@media (min-width: 641px) {
  /* Returned items */
  .dispatch-table tbody tr.dispatch-row.row-item-returned td {
    background: #f0fdf4 !important;
    border-top: 1.5px solid #86efac !important;
    border-bottom: 1.5px solid #86efac !important;
  }
  .dispatch-table tbody tr.dispatch-row.row-item-returned td:first-child {
    border-left: 1.5px solid #86efac !important;
  }
  .dispatch-table tbody tr.dispatch-row.row-item-returned td:last-child {
    border-right: 1.5px solid #86efac !important;
  }
  .dispatch-table tbody tr.dispatch-row.row-item-returned.row-expanded td {
    border-bottom: 1px dashed #86efac !important;
  }
  .dispatch-table tbody tr.dispatch-inline-row.row-item-returned {
    background: #f0fdf4 !important;
  }
  .dispatch-table tbody tr.dispatch-inline-row.row-item-returned td.dispatch-inline-td {
    border-left: 1.5px solid #86efac !important;
    border-right: 1.5px solid #86efac !important;
    border-bottom: 1.5px solid #86efac !important;
    border-top: none !important;
    background: #f0fdf4 !important;
  }
  .dispatch-table tbody tr.dispatch-inline-row.row-item-returned .dispatch-inline-clean {
    border: 1.5px solid #86efac !important;
    background: #f0fdf4 !important;
  }

  /* Pending return items */
  .dispatch-table tbody tr.dispatch-row.row-item-pending-return td {
    background: #ffffff !important;
    border-top: 1.5px solid #ef4444 !important;
    border-bottom: 1.5px solid #ef4444 !important;
  }
  .dispatch-table tbody tr.dispatch-row.row-item-pending-return td:first-child {
    border-left: 1.5px solid #ef4444 !important;
  }
  .dispatch-table tbody tr.dispatch-row.row-item-pending-return td:last-child {
    border-right: 1.5px solid #ef4444 !important;
  }
  .dispatch-table tbody tr.dispatch-row.row-item-pending-return.row-expanded td {
    border-bottom: 1px dashed #ef4444 !important;
  }
  .dispatch-table tbody tr.dispatch-inline-row.row-item-pending-return {
    background: #ffffff !important;
  }
  .dispatch-table tbody tr.dispatch-inline-row.row-item-pending-return td.dispatch-inline-td {
    border-left: 1.5px solid #ef4444 !important;
    border-right: 1.5px solid #ef4444 !important;
    border-bottom: 1.5px solid #ef4444 !important;
    border-top: none !important;
    background: #ffffff !important;
  }
  .dispatch-table tbody tr.dispatch-inline-row.row-item-pending-return .dispatch-inline-clean {
    border: 1.5px solid #ef4444 !important;
    background: #ffffff !important;
  }
}

.sn-picked-val {
  color: #15803d;
  font-weight: 600;
  font-family: monospace, sans-serif;
}

.btn-quick-unpick {
  background: transparent;
  border: none;
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: all 0.12s ease;
}

.btn-quick-unpick:hover {
  color: #ef4444;
  background: #fee2e2;
}

.dispatch-row-action-btns {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-dispatch-delete-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  padding: 0;
}

.btn-dispatch-delete-item:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #ef4444;
  transform: translateY(-1px);
}

.btn-dispatch-delete-item:active {
  transform: translateY(0);
}

.badge-sn-waiting {
  font-size: 11.5px;
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-sn-waiting svg {
  color: #f59e0b;
  flex-shrink: 0;
}

.pick-acc-text {
  font-size: 12px;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  display: inline-block;
  vertical-align: middle;
}

.photo-badge-mini {
  font-size: 11px;
  color: #059669;
  font-weight: 600;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 2px 7px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.photo-badge-mini.clickable-photo-badge {
  cursor: pointer;
  transition: all 0.12s ease;
}

.photo-badge-mini.clickable-photo-badge:hover {
  background: #dcfce7;
  border-color: #4ade80;
  transform: scale(1.05);
}

.photo-badge-mini svg {
  color: #059669;
  flex-shrink: 0;
}

.inline-chevron-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.inline-chevron-svg {
  color: #94a3b8;
  transition: transform 0.2s ease, color 0.2s ease;
}

.inline-chevron-svg.open {
  transform: rotate(180deg);
  color: #6366f1;
}

.inline-chevron {
  display: inline-block;
  font-size: 11px;
  color: #94a3b8;
}

.inline-chevron.open {
  color: #6366f1;
}

.dispatch-inline-row {
  background: #f8fafc;
}

.dispatch-inline-td {
  padding: 0 14px 14px 14px !important;
  border-bottom: 1px solid #e2e8f0;
  width: 100% !important;
  box-sizing: border-box !important;
}

.dispatch-inline-clean {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
  width: 100% !important;
  box-sizing: border-box !important;
}

.inline-field-line {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

.inline-field-title {
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
  width: 76px !important;
  min-width: 76px !important;
  max-width: 76px !important;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.inline-field-title svg {
  color: #64748b;
  flex-shrink: 0;
}

.inline-sn-field-line {
  min-height: 38px;
}

.inline-sn-selector-container {
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}

.inline-sn-input-wrap {
  position: relative;
  width: 100%;
  display: block;
  box-sizing: border-box;
}

.inline-sn-picker-input {
  width: 100% !important;
  display: block !important;
  height: 36px !important;
  font-size: 13px !important;
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 8px !important;
  padding-left: 12px !important;
  padding-right: 48px !important;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  box-sizing: border-box !important;
}

.inline-sn-picker-input:focus {
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15) !important;
}

.sn-matched-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 6px;
  padding: 5px 12px;
  box-shadow: 0 1px 2px rgba(22, 163, 74, 0.06);
}

.sn-matched-card.is-unreturned-card {
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: none !important;
}
.sn-matched-card.is-unreturned-card .sn-matched-code {
  color: #334155 !important;
}
.sn-matched-card.is-unreturned-card .sn-matched-tag {
  color: #64748b !important;
  background: #f1f5f9 !important;
}

.sn-matched-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sn-matched-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #16a34a;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.sn-matched-code {
  font-family: monospace, sans-serif;
  font-size: 13.5px;
  color: #14532d;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.sn-matched-tag {
  font-size: 11.5px;
  color: #15803d;
  background: #dcfce7;
  padding: 1px 6px;
  border-radius: 4px;
}

.sn-matched-loc {
  font-size: 11.5px;
  color: #0369a1;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  padding: 1px 6px;
  border-radius: 4px;
}

.sn-matched-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-sn-change-action {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-sn-change-action:hover {
  border-color: #6366f1;
  color: #4f46e5;
  background: #eef2ff;
  transform: translateY(-1px);
}

.btn-sn-unpick-action {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ef4444;
  background: #ffffff;
  border: 1px solid #fecaca;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(239, 68, 68, 0.05);
}

.btn-sn-unpick-action:hover {
  background: #fee2e2;
  border-color: #f87171;
  color: #dc2626;
  transform: translateY(-1px);
}

.model-count-box.count-picked {
  background: #ecfdf5;
  color: #15803d;
  border-color: #86efac;
}

/* ============================================================================
   LIVE CAMERA VIEWFINDER MODAL (Mac / PC / Mobile)
   ============================================================================ */
dialog.modal-camera-dialog {
  width: 540px;
  max-width: 95vw;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #0f172a;
  color: #ffffff;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
  z-index: 100010 !important;
}

dialog.modal-camera-dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

.camera-dialog-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.camera-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
}

.camera-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #f8fafc;
}

.camera-header-title svg {
  color: #818cf8;
}

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

.btn-camera-action {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #475569;
  background: #334155;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-camera-action:hover {
  background: #475569;
  color: #ffffff;
}

.camera-viewfinder-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #000000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#dispatchCameraVideo,
#dispatchCameraCanvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-loading-overlay,
.camera-error-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.88);
  color: #94a3b8;
  font-size: 13px;
  padding: 20px;
  text-align: center;
  z-index: 10;
}

.camera-error-overlay p {
  color: #f87171;
  margin: 0;
}

.camera-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #1e293b;
  border-top: 1px solid #334155;
  min-height: 72px;
}

.camera-shutter-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  background: transparent;
  padding: 3px;
  cursor: pointer;
  transition: transform 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-shutter-btn:active {
  transform: scale(0.92);
}

.shutter-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #ffffff;
  transition: background 0.15s ease;
}

.camera-shutter-btn:hover .shutter-inner {
  background: #f1f5f9;
}

.camera-confirm-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.acc-pill-btn {
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  transition: all 0.12s ease;
  display: inline-flex;
  align-items: center;
  user-select: none;
}

.acc-pill-btn:hover {
  background: #f1f5f9;
}

.acc-pill-btn.active {
  background: #ecfdf5;
  border-color: #86efac;
  color: #065f46;
  font-weight: 600;
}

.acc-pill-btn.active.is-selected {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
  font-weight: 600;
}

.acc-pill-btn.active.is-selected:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* Inline Accessory Container & Search Input */
.inline-acc-container {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
  box-sizing: border-box;
}

.inline-acc-pills-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  width: 100%;
}

.inline-acc-input-wrap {
  position: relative;
  width: 100%;
  display: block;
  box-sizing: border-box;
}

.inline-acc-picker-input {
  width: 100% !important;
  display: block !important;
  height: 33px !important;
  font-size: 12.5px !important;
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 7px !important;
  padding-left: 10px !important;
  padding-right: 48px !important;
  transition: all 0.15s ease;
  font-family: inherit;
  box-sizing: border-box !important;
}

.inline-acc-picker-input:focus {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12) !important;
  outline: none !important;
}

.inline-detail-divider {
  width: 100%;
  height: 1px;
  background: #f1f5f9;
  margin: 3px 0;
}

.inline-photo-field-line {
  min-height: 32px;
}

.inline-photo-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.btn-inline-icon-action {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-inline-icon-action:hover {
  border-color: #6366f1;
  background: #eef2ff;
  color: #4f46e5;
  transform: translateY(-1px);
}

.btn-inline-icon-action svg {
  color: inherit;
}

.mini-photo-thumb {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
}

.mini-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

.btn-del-mini {
  position: absolute;
  top: 0;
  right: 0;
  width: 13px;
  height: 13px;
  background: rgba(15, 23, 42, 0.75);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.btn-del-mini:hover {
  background: #ef4444;
}

.inline-note-field-line {
  min-height: 38px;
  align-items: center;
}

.inline-note-container {
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}

.inline-note-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

.inline-note-input-wrap .note-prefix-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
  transition: color 0.15s ease;
  z-index: 2;
}

.inline-note-input-wrap:focus-within .note-prefix-icon {
  color: #2563eb !important;
}

.inline-note-input-wrap .inline-clean-note-input {
  width: 100% !important;
  box-sizing: border-box !important;
  height: 38px !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
  padding: 6px 34px 6px 33px !important;
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 8px !important;
  color: #1e293b !important;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1) !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03) !important;
}

.inline-note-input-wrap .inline-clean-note-input:hover {
  border-color: #94a3b8 !important;
}

.inline-note-input-wrap .inline-clean-note-input:focus {
  background: #ffffff !important;
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
  outline: none !important;
}

.inline-note-input-wrap .inline-clean-note-input::placeholder {
  color: #94a3b8 !important;
  font-size: 12.5px !important;
}

.inline-note-input-wrap .btn-input-clear {
  position: absolute !important;
  right: 8px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  z-index: 5 !important;
}

.dispatch-hint-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
}

.dispatch-hint-badge.success {
  color: #15803d;
}

.dispatch-hint-badge.pending {
  color: #64748b;
}

/* Responsive Table & In-line Picking Layout */
@media screen and (max-width: 900px) {
  .dispatch-modal-body {
    padding: 14px 16px 28px !important;
    max-width: 100% !important;
  }
}

@media screen and (max-width: 768px) {
  /* 1. Header Bar on Mobile */
  #dispatchDialog .modal-header {
    padding: 6px 12px !important;
    height: 56px !important;
    min-height: 56px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    background: #ffffff !important;
    border-bottom: 1px solid #f1f5f9 !important;
  }

  #dispatchDialog .fullscreen-header-left {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 1 !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }

  #dispatchDialog .btn-back-nav {
    height: 32px !important;
    padding: 0 9px 0 7px !important;
    font-size: 12.5px !important;
    flex-shrink: 0 !important;
    border-radius: 99px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px !important;
  }

  #dispatchDialog .dispatch-title-group {
    flex: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    overflow: hidden !important;
  }

  #dispatchDialog .dispatch-title-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    gap: 2px !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  #dispatchDialog .dispatch-modal-title {
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    color: #0f172a !important;
  }

  #dispatchDialog .dispatch-title-sep {
    display: none !important;
  }

  #dispatchDialog .dispatch-title-loan-id {
    display: none !important;
  }

  #dispatchDialog .dispatch-title-subline {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
    min-width: 0 !important;
    max-width: 100% !important;
    line-height: 1 !important;
    margin-top: 1px !important;
    overflow: hidden !important;
  }

  #dispatchDialog .dispatch-mobile-loan-code {
    display: inline-flex !important;
    align-items: center !important;
    flex-shrink: 0 !important;
  }

  #dispatchDialog .dispatch-mobile-loan-code .doc-link-pill {
    white-space: nowrap !important;
    word-break: keep-all !important;
    flex-shrink: 0 !important;
    padding: 1px 7px !important;
    height: 20px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    line-height: 18px !important;
    box-sizing: border-box !important;
  }

  #dispatchDialog #dispatchStageBadge {
    font-size: 10.5px !important;
    font-weight: 600 !important;
    padding: 1px 7px !important;
    white-space: nowrap !important;
    word-break: keep-all !important;
    flex-shrink: 0 !important;
    line-height: 18px !important;
    height: 20px !important;
    display: inline-flex !important;
    align-items: center !important;
    border-radius: 999px !important;
    box-sizing: border-box !important;
  }

  #dispatchDialog .fullscreen-header-actions,
  .modal-dialog .fullscreen-header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
    margin-left: auto !important;
  }

  #dispatchDialog .btn-header-printpass,
  .modal-dialog .btn-header-printpass {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    padding: 0 !important;
    font-size: 13px !important;
    border-radius: 9px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    color: #334155 !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05) !important;
  }

  #dispatchDialog .btn-header-printpass span,
  .modal-dialog .btn-header-printpass span {
    display: none !important; /* Hide text, keep printer icon on mobile */
  }

  /* 2. Modal Body & Summary Strip */
  .dispatch-modal-body {
    padding: 12px 14px calc(98px + env(safe-area-inset-bottom, 16px)) !important;
    gap: 10px !important;
  }

  #dispatchDialog .dispatch-summary-strip {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 6px 12px !important;
    padding: 10px 12px !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04) !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }

  #dispatchDialog .summary-strip-divider {
    display: none !important;
  }

  #dispatchDialog .summary-strip-item {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    min-width: 0 !important;
  }

  #dispatchDialog .summary-strip-item .strip-label {
    font-size: 11px !important;
    color: #64748b !important;
  }

  #dispatchDialog .summary-strip-item .strip-val {
    font-size: 12.5px !important;
    color: #0f172a !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
  }

  /* 3. Barcode Scanner Minimal Input */
  #dispatchDialog .barcode-scanner-minimal {
    margin-bottom: 4px !important;
    padding: 6px 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  #dispatchDialog .dispatch-barcode-input {
    font-size: 13.5px !important;
    height: 36px !important;
  }

  /* 4. Transform Table into Mobile Picking Cards */
  .dispatch-table-wrap {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
    width: 100% !important;
  }

  .dispatch-table,
  .dispatch-table tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .dispatch-table thead {
    display: none !important;
  }

  .dispatch-table tbody tr.dispatch-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 12px 14px !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04) !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
  }

  .dispatch-table tbody tr.dispatch-row.row-picked {
    background: #f0fdf4 !important;
    border-color: #86efac !important;
  }

  .dispatch-table tbody tr.dispatch-row.row-item-returned {
    background: #f0fdf4 !important;
    border: 1.5px solid #86efac !important;
  }

  .dispatch-table tbody tr.dispatch-row.row-item-pending-return {
    background: #ffffff !important;
    border: 1.5px solid #ef4444 !important;
    box-shadow: none !important;
  }
  .dispatch-table tbody tr.dispatch-row.row-item-pending-return td {
    border: none !important;
  }

  .dispatch-table tbody tr.dispatch-row.row-expanded {
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-bottom: 1px dashed #cbd5e1 !important;
    background: #f8fafc !important;
  }

  .dispatch-table tbody tr.dispatch-row.row-picked.row-expanded,
  .dispatch-table tbody tr.dispatch-row.row-item-returned.row-expanded {
    border: 1.5px solid #86efac !important;
    border-bottom: 1px dashed #86efac !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    background: #f0fdf4 !important;
  }

  .dispatch-table tbody tr.dispatch-row.row-item-pending-return.row-expanded {
    border: 1.5px solid #ef4444 !important;
    border-bottom: 1px dashed #ef4444 !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    background: #ffffff !important;
  }

  /* Item Index (#) */
  .dispatch-table tbody tr.dispatch-row td:nth-child(1) {
    width: 22px !important;
    min-width: 22px !important;
    max-width: 22px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    color: #94a3b8 !important;
    padding: 0 !important;
    border: none !important;
    text-align: left !important;
    flex-shrink: 0 !important;
  }

  /* Return QC Row on Mobile: Stack cleanly into a card */
  .dispatch-table tbody tr.dispatch-row.return-qc-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 14px !important;
  }

  .dispatch-table tbody tr.dispatch-row.return-qc-row td {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    border: none !important;
  }

  .dispatch-table tbody tr.dispatch-row.return-qc-row td:nth-child(1) {
    display: none !important;
  }

  /* Model & Location */
  .dispatch-table tbody tr.dispatch-row td:nth-child(2) {
    flex: 1 !important;
    width: auto !important;
    min-width: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: visible !important;
  }

  .dispatch-model-name {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    line-height: 1.3 !important;
    display: block !important;
  }

  .dispatch-model-sub {
    margin-top: 4px !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-wrap: wrap !important;
  }

  /* S/N Status Badge */
  .dispatch-table tbody tr.dispatch-row td:nth-child(3) {
    width: auto !important;
    padding: 0 !important;
    border: none !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
  }

  /* Hide Desktop Accessories preview column on mobile */
  .dispatch-table tbody tr.dispatch-row td:nth-child(4) {
    display: none !important;
  }

  /* Photo badge in row */
  .dispatch-table tbody tr.dispatch-row td:nth-child(5) {
    width: auto !important;
    padding: 0 !important;
    border: none !important;
    flex-shrink: 0 !important;
  }

  /* Chevron */
  .dispatch-table tbody tr.dispatch-row td:nth-child(6) {
    width: 20px !important;
    min-width: 20px !important;
    max-width: 20px !important;
    padding: 0 !important;
    border: none !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* 5. In-line Expanded Detail Section on Mobile */
  .dispatch-inline-row {
    display: block !important;
    width: 100% !important;
    margin-top: -10px !important;
    margin-bottom: 4px !important;
    background: transparent !important;
  }

  .dispatch-inline-td {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    border: none !important;
    box-sizing: border-box !important;
  }

  .dispatch-inline-clean {
    border: 1px solid #e2e8f0;
    border-top: none !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    border-radius: 0 0 12px 12px !important;
    padding: 12px 14px !important;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05) !important;
    gap: 12px !important;
  }

  .dispatch-inline-row.row-picked .dispatch-inline-clean,
  .dispatch-inline-row.row-item-returned .dispatch-inline-clean {
    border-left: 1.5px solid #86efac !important;
    border-right: 1.5px solid #86efac !important;
    border-bottom: 1.5px solid #86efac !important;
    border-top: none !important;
    background: #f0fdf4 !important;
  }

  .dispatch-inline-row.row-item-pending-return .dispatch-inline-clean {
    border-left: 1.5px solid #ef4444 !important;
    border-right: 1.5px solid #ef4444 !important;
    border-bottom: 1.5px solid #ef4444 !important;
    border-top: none !important;
    background: #ffffff !important;
  }

  .inline-field-line {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .inline-field-title {
    width: auto !important;
    min-width: 0 !important;
    font-size: 11.5px !important;
    color: #475569 !important;
  }

  .inline-sn-selector-container {
    width: 100% !important;
  }

  .inline-acc-pills-wrap {
    width: 100% !important;
  }

  .inline-detail-divider {
    margin: 4px 0 !important;
  }

  .inline-photo-field-line,
  .inline-note-field-line {
    width: 100% !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
  }

  .inline-photo-controls {
    width: 100% !important;
  }

  .inline-note-container,
  .inline-note-input-wrap {
    width: 100% !important;
  }

  .inline-note-input-wrap .inline-clean-note-input {
    width: 100% !important;
    height: 38px !important;
    font-size: 13px !important;
  }

  /* 6. Mobile Footer */
  #dispatchDialog .dispatch-footer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 52px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 8px)) !important;
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(16px) !important;
    border-top: 1px solid #e2e8f0 !important;
    gap: 6px !important;
    box-sizing: border-box !important;
    z-index: 1000 !important;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06) !important;
  }

  #dispatchDialog .dispatch-footer-meta {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    width: 100% !important;
    min-height: 24px !important;
  }

  #dispatchDialog .dispatch-footer-meta:empty {
    display: none !important;
  }

  #dispatchDialog #dispatchStatusHint {
    font-size: 12px !important;
    white-space: nowrap !important;
    flex: 0 1 auto !important;
    min-width: 0 !important;
    color: #475569 !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    margin: 0 !important;
  }

  #dispatchDialog .btn-cancel-loan-action {
    margin-left: auto !important;
    padding: 2px 8px !important;
    height: 26px !important;
    font-size: 11.5px !important;
    color: #ef4444 !important;
    background: #fef2f2 !important;
    border: 1px solid #fee2e2 !important;
    border-radius: 6px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px !important;
    cursor: pointer !important;
    white-space: nowrap !important;
  }

  #dispatchDialog .btn-cancel-loan-action.hidden,
  .btn-cancel-loan-action.hidden {
    display: none !important;
  }

  #dispatchDialog .btn-cancel-loan-action:active {
    background: #fee2e2 !important;
  }

  #dispatchDialog .dispatch-footer-actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
  }

  #dispatchDialog .btn-dispatch-dismiss {
    padding: 0 14px !important;
    font-size: 13px !important;
    color: #475569 !important;
    flex-shrink: 0 !important;
    height: 38px !important;
    line-height: 38px !important;
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    cursor: pointer !important;
    font-weight: 600 !important;
  }

  #dispatchDialog .footer-right-btns {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    gap: 6px !important;
    margin-left: 0 !important;
    flex: 1 1 auto !important;
    width: auto !important;
  }

  #dispatchDialog .btn-dispatch-return {
    height: 38px !important;
    padding: 0 14px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    background: #16a34a !important;
    border: 1px solid #15803d !important;
    color: #ffffff !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    white-space: nowrap !important;
    box-shadow: 0 1px 3px rgba(22, 163, 74, 0.25) !important;
    flex: 1 1 auto !important;
    width: 100% !important;
  }

  #dispatchDialog .btn-save-dispatch {
    height: 38px !important;
    padding: 0 12px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    width: 100% !important;
    flex: 1 1 auto !important;
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
  }
}

.dispatch-model-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dispatch-model-name {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.dispatch-model-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Row Embedded Photo Trigger Button */
.btn-row-photo-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-row-photo-trigger.empty {
  background: #ffffff;
  color: #64748b;
  border: 1px dashed #cbd5e1;
}

.btn-row-photo-trigger.empty:hover {
  background: #eef2ff;
  color: #6366f1;
  border-color: #6366f1;
}

.btn-row-photo-trigger.has-photos {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  font-weight: 700;
}

.btn-row-photo-trigger.has-photos:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
}

/* Item Photo Sheet Modal */
.modal-item-photo-sheet {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: 520px;
  width: 92vw;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.25);
  background: #ffffff;
  overflow: hidden;
}

.modal-item-photo-sheet::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.item-photo-modal-content {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
}

.item-photo-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.item-photo-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.item-photo-sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: #64748b;
}

.item-photo-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
}

.item-photos-grid-wrap {
  min-height: 140px;
  max-height: 280px;
  overflow-y: auto;
  padding: 14px 0;
}

.item-photos-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 10px;
  text-align: center;
  color: #94a3b8;
  gap: 6px;
  font-size: 13px;
}

.item-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
}

.item-photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.item-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

.btn-rm-item-photo {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.75);
  color: #ffffff;
  border: none;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.12s ease;
}

.btn-rm-item-photo:hover {
  background: #ef4444;
}

.item-photo-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid #f1f5f9;
  padding-top: 14px;
}

.footer-center-hint {
  font-size: 12.5px;
  color: #64748b;
  font-weight: 600;
}

/* ==========================================================================
   FLOATING ACTION BUTTON (FAB) & DELIVERY MODAL (รอส่งมอบ -> ส่งมอบสินค้า)
   ========================================================================== */

.fab-delivery-btn {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 1060;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 24px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 10px 25px -4px rgba(37, 99, 235, 0.45), 0 6px 12px -4px rgba(37, 99, 235, 0.35);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  user-select: none;
}

.fab-delivery-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 14px 28px -4px rgba(37, 99, 235, 0.55), 0 8px 16px -4px rgba(37, 99, 235, 0.4);
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

.fab-delivery-btn:active {
  transform: translateY(0) scale(0.98);
}

.fab-delivery-btn .fab-icon {
  font-size: 19px;
  line-height: 1;
}

.fab-delivery-btn .fab-text {
  letter-spacing: -0.2px;
}

@media (max-width: 640px) {
  .fab-delivery-btn {
    bottom: 78px;
    right: 18px;
    padding: 11px 18px;
    font-size: 14px;
  }
  .fab-delivery-btn .fab-icon {
    font-size: 17px;
  }
}

/* Delivery Modal Styling */
.modal-delivery {
  width: 94%;
  max-width: 580px;
  max-height: 90vh;
  border-radius: 16px;
  border: none;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  padding: 0;
  background: #ffffff;
  overflow: hidden;
}

.delivery-modal-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 90vh;
}

.delivery-modal-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.delivery-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
}

.modal-delivery .form-group {
  margin-bottom: 14px;
}

.modal-delivery .form-group:last-child {
  margin-bottom: 0;
}

.modal-delivery .form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
  display: block;
}

.modal-delivery .form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: #1e293b;
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.modal-delivery .form-control:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.modal-delivery .grid-2-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 640px) {
  .modal-delivery .grid-2-col {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.delivery-modal-card {
  display: flex;
  flex-direction: column;
}

.delivery-modal-body {
  padding: 20px 24px;
  max-height: calc(85vh - 130px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.photo-upload-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.photo-count-badge {
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 12px;
}

.delivery-photo-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.delivery-photo-actions .btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
}

.delivery-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  min-height: 20px;
}

.delivery-photo-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.delivery-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.btn-del-photo-rm {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.75);
  color: #ffffff;
  border: none;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.12s ease;
}

.btn-del-photo-rm:hover {
  background: #ef4444;
}

/* Delivery Meta Card: GPS & Timestamp */
.delivery-meta-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 16px;
  margin: 16px 0;
}

.delivery-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.delivery-meta-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.delivery-meta-info {
  flex: 1;
  min-width: 0;
}

.delivery-meta-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 2px;
}

.delivery-meta-value {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  word-break: break-all;
}

.delivery-meta-value a {
  color: #2563eb;
  text-decoration: underline;
}

.btn-refresh-gps {
  flex-shrink: 0;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.delivery-meta-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 10px 0;
}

.delivery-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid #f1f5f9;
  background: #fafafa;
  border-radius: 0 0 16px 16px;
}

.btn-confirm-delivery {
  font-weight: 700;
}

/* ==========================================================================
   DISPATCH MODAL READ-ONLY & ON-SITE EDIT STYLES
   ========================================================================== */
.sn-matched-card.readonly-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  cursor: default;
}

.readonly-acc-pills-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge-subtle-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
}

.badge-subtle-pill .badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #3b82f6;
  flex-shrink: 0;
}

.readonly-photo-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.readonly-note-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  color: #334155;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  min-height: 34px;
  width: 100%;
  box-sizing: border-box;
}

.readonly-note-box .note-quote-icon {
  font-size: 12px;
  opacity: 0.7;
}

.text-muted-empty {
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
}

/* Dispatch Footer Action Buttons */
.btn-onsite-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-onsite-edit:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-borrower-sig {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-borrower-sig:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-borrower-sig.is-signed {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.btn-borrower-sig.is-signed:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
}

.btn-dispatch-deliver {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 13px;
  height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  background: #2563eb;
  border: 1px solid #1d4ed8;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
}

.btn-dispatch-deliver:hover {
  background: #1d4ed8;
}

/* Dispatch footer layout: Desktop & Mobile */
#dispatchDialog .dispatch-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
}

#dispatchDialog .dispatch-footer-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

#dispatchDialog .btn-cancel-loan-action {
  padding: 4px 10px;
  height: 32px;
  font-size: 12.5px;
  color: #ef4444;
  background: #fef2f2;
  border: 1px solid #fee2e2;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

#dispatchDialog .btn-cancel-loan-action:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

#dispatchDialog .btn-cancel-loan-action.hidden {
  display: none !important;
}

#dispatchDialog .dispatch-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#dispatchDialog .btn-dispatch-dismiss {
  font-size: 13px;
  color: #475569;
  height: 38px;
  padding: 0 14px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-weight: 600;
}

#dispatchDialog .footer-right-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 640px) {
  /* In delivery mode with 3 buttons (onsite edit, borrower sig, deliver), hide dismiss on row 2 so buttons get 100% width */
  #dispatchDialog .dispatch-footer:has(.btn-dispatch-deliver) .btn-dispatch-dismiss {
    display: none !important;
  }

  #dispatchDialog .dispatch-footer:has(.btn-dispatch-deliver) .footer-right-btns,
  #dispatchDialog .dispatch-footer:has(#btnSubmitReturn) .footer-right-btns {
    width: 100% !important;
    margin-left: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    gap: 6px !important;
  }

  #dispatchDialog .btn-onsite-edit,
  #dispatchDialog .btn-borrower-sig {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    height: 38px !important;
    padding: 0 4px !important;
    font-size: 12px !important;
    gap: 4px !important;
    justify-content: center !important;
  }

  #dispatchDialog .btn-dispatch-deliver {
    flex: 1.25 1 0 !important;
    min-width: 0 !important;
    height: 38px !important;
    padding: 0 6px !important;
    font-size: 12.5px !important;
    gap: 4px !important;
    justify-content: center !important;
  }

  #dispatchDialog #btnCancelOnsiteEdit,
  #dispatchDialog #btnCancelReturnMode {
    flex: 0 0 auto !important;
    height: 38px !important;
    font-size: 13px !important;
    padding: 0 12px !important;
  }

  #dispatchDialog #btnSubmitReturn {
    flex: 1 !important;
    height: 38px !important;
    font-size: 13px !important;
    white-space: nowrap !important;
  }

  #dispatchDialog .btn-save-dispatch {
    flex: 2 !important;
    height: 38px !important;
    font-size: 13px !important;
  }
}

/* ==========================================================================
   RETURN MODE & LOAN-LEVEL RETURN PROOF IN DISPATCH DIALOG
   ========================================================================== */
.btn-dispatch-return {
  background: #16a34a !important;
  color: #fff !important;
  border: none !important;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-dispatch-return:hover {
  background: #15803d !important;
}

.btn-submit-return {
  background: #16a34a !important;
  color: #fff !important;
  border: none !important;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-submit-return:hover {
  background: #15803d !important;
}

.dispatch-return-proof-section {
  padding: 12px 18px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  margin-top: 10px;
}

.return-proof-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.return-proof-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #1e293b;
}

.return-qc-row.row-ret-checked {
  background-color: #f0fdf4 !important;
}

.return-qc-row.row-ret-pending {
  background-color: #fafaf9 !important;
}

.ret-status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}

.ret-status-badge.badge-returned {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.ret-status-badge.badge-pending {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.acc-pill-btn.is-missing {
  background: #fee2e2 !important;
  color: #b91c1c !important;
  border-color: #fecaca !important;
}

/* Modern iOS-style Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-switch .toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
}

.toggle-switch .toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.toggle-switch:hover .toggle-slider {
  background-color: #94a3b8;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #16a34a;
}

.toggle-switch:hover input:checked + .toggle-slider {
  background-color: #15803d;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: #86efac;
}

.btn-submit-return.is-disabled,
.btn-submit-return:disabled {
  background: #f1f5f9 !important;
  color: #94a3b8 !important;
  border-color: #e2e8f0 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  box-shadow: none !important;
}

.return-qc-row.row-ret-completed {
  background-color: #f8fafc !important;
  opacity: 0.75;
}

.ret-row-scan-input:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
  background: #ffffff !important;
}

.ret-row-scan-input.is-matched {
  border-color: #16a34a !important;
  background-color: #f0fdf4 !important;
  color: #15803d !important;
}

/* ==========================================================================
   CAMERA BARCODE SCANNER MODAL FOR TOP SEARCH BAR
   ========================================================================== */
dialog.modal-camera-scanner {
  max-width: 440px;
  width: min(440px, 94vw);
  border-radius: 18px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  background: #0f172a;
  color: #ffffff;
  padding: 0;
  overflow: hidden;
  margin: auto;
}

dialog.modal-camera-scanner::backdrop {
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
}

.scanner-modal-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 85vh;
}

.scanner-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: #0f172a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.scanner-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.scanner-header-icon-badge {
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.scanner-header-text h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #f8fafc;
}

.scanner-header-sub {
  font-size: 11px;
  color: #94a3b8;
  display: block;
}

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

.btn-scanner-action {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-scanner-action:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-scanner-close {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-scanner-close:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ef4444;
}

.scanner-viewfinder-body {
  position: relative;
  background: #000000;
  min-height: 320px;
  height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.scanner-reader-mount {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
}

.scanner-reader-mount video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

.scanner-overlay-reticle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
}

.reticle-box {
  position: relative;
  width: 250px;
  height: 180px;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
}

.reticle-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: #38bdf8;
  border-style: solid;
}

.corner-tl { top: -2px; left: -2px; border-width: 3.5px 0 0 3.5px; border-top-left-radius: 10px; }
.corner-tr { top: -2px; right: -2px; border-width: 3.5px 3.5px 0 0; border-top-right-radius: 10px; }
.corner-bl { bottom: -2px; left: -2px; border-width: 0 0 3.5px 3.5px; border-bottom-left-radius: 10px; }
.corner-br { bottom: -2px; right: -2px; border-width: 0 3.5px 3.5px 0; border-bottom-right-radius: 10px; }

.reticle-laser-line {
  position: absolute;
  left: 6px;
  right: 6px;
  height: 2px;
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8, 0 0 16px #0284c7;
  animation: laserScan 2s ease-in-out infinite alternate;
}

@keyframes laserScan {
  0% { top: 12px; opacity: 0.8; }
  100% { top: calc(100% - 14px); opacity: 0.8; }
}

.reticle-guide-text {
  margin-top: 18px;
  font-size: 12px;
  color: #e2e8f0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  font-weight: 500;
  letter-spacing: 0.2px;
}

.scanner-loading-indicator {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #cbd5e1;
  font-size: 13px;
  z-index: 5;
}

.scanner-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.scanner-error-box {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #fca5a5;
  font-size: 13px;
  text-align: center;
  padding: 20px;
  z-index: 15;
  background: rgba(15, 23, 42, 0.95);
  border-radius: 12px;
  margin: 16px;
}

.scanner-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #0f172a;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-scanner-upload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 7px;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-scanner-upload:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

/* ==========================================================================
   User Profile Pill & Dropdown in App Header
   ========================================================================== */
.user-profile-menu-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.btn-user-profile-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 5px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
  outline: none;
}

.btn-user-profile-pill:hover,
.btn-user-profile-pill:focus-visible {
  background: #f1f5f9;
  border-color: #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.user-avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e0e7ff;
  color: #4338ca;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  flex-shrink: 0;
}

.user-avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-nav-name {
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.user-nav-caret {
  font-size: 10px;
  color: #94a3b8;
  margin-left: 1px;
}

.user-dropdown-card {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.04);
  padding: 12px;
  z-index: 1050;
  animation: dropdownFadeIn 0.15s ease-out;
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 10px;
}

.user-dropdown-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #eff6ff;
  color: #1d4ed8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid #dbeafe;
}

.user-dropdown-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-dropdown-info {
  flex: 1;
  min-width: 0;
}

.user-dropdown-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown-email {
  font-size: 11.5px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.user-dropdown-badge {
  display: inline-block;
  padding: 2px 7px;
  background: #eff6ff;
  color: #2563eb;
  border-radius: 9999px;
  font-size: 10.5px;
  font-weight: 600;
  margin-top: 4px;
}

.user-dropdown-divider {
  height: 1px;
  background: #f1f5f9;
  margin: 6px 0 8px;
}

.user-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.user-dropdown-item:hover {
  background: #f8fafc;
  color: #0f172a;
}

.user-dropdown-item.text-danger {
  color: #ef4444;
}

.user-dropdown-item.text-danger:hover {
  background: #fef2f2;
  color: #dc2626;
}

/* ==========================================================================
   Login Screen Overlay (Google Workspace & Corporate Authentication)
   ========================================================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 20%, rgba(37, 99, 235, 0.12) 0%, rgba(15, 23, 42, 0.75) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.login-card-container {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 440px;
  margin: auto;
}

.login-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.25), 0 0 1px 1px rgba(15, 23, 42, 0.05);
  border: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  flex-direction: column;
}

.login-brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.login-brand-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-radius: 12px;
  color: #ffffff;
  font-size: 26px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  flex-shrink: 0;
}

.login-brand-titles {
  flex: 1;
}

.login-app-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-app-sub {
  margin: 3px 0 0;
  font-size: 13px;
  color: #64748b;
}

.login-domain-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  margin-bottom: 16px;
}

.login-domain-badge strong {
  font-weight: 700;
  color: #1d4ed8;
}

.login-alert-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  margin-bottom: 16px;
  line-height: 1.4;
  animation: shakeAlert 0.25s ease-in-out;
}

@keyframes shakeAlert {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.btn-google-workspace {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 18px;
  background: #ffffff;
  border: 1.5px solid #dadce0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #3c4043;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.08);
}

.btn-google-workspace:hover {
  background: #f8fafc;
  border-color: #c4c7cc;
  box-shadow: 0 2px 6px rgba(60, 64, 67, 0.15);
}

.btn-google-workspace:active {
  background: #f1f3f4;
  transform: scale(0.99);
}

.login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 18px 0;
  color: #94a3b8;
  font-size: 12px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #e2e8f0;
}

.login-divider span {
  padding: 0 12px;
}

.login-email-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-email-form .form-group {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.login-email-form .form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0;
}

.login-email-form .form-control {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  border-radius: 9px;
  border: 1.5px solid #cbd5e1;
  font-family: inherit;
  font-size: 13.5px;
  color: #0f172a;
  background: #ffffff;
  transition: all 0.15s ease;
}

.login-email-form .form-control:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-login-submit {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  font-size: 14.5px;
  font-weight: 600;
  border-radius: 10px;
  margin-top: 4px;
}

.login-quick-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed #e2e8f0;
}

.quick-title {
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 9px;
}

.quick-user-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.btn-quick-user {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  font-family: inherit;
  font-size: 12px;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-quick-user:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
  transform: translateY(-1px);
}

.login-footer-hint {
  margin-top: 18px;
  text-align: center;
  font-size: 11.5px;
  color: #94a3b8;
}

@media (max-width: 640px) {
  .user-nav-name {
    display: none;
  }
  .btn-user-profile-pill {
    padding: 3px 5px;
  }
  .login-card {
    padding: 24px 18px;
  }
  .login-app-title {
    font-size: 20px;
  }
}

/* ==========================================================================
   Roles & Permissions Management UI (Column Matrix Layout)
   ========================================================================== */
.roles-tab-fullscreen-container {
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-sizing: border-box;
}

.roles-matrix-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: transparent;
  border-bottom: 1px solid #f1f5f9;
  padding: 4px 0 14px 0;
}

.roles-matrix-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 2px;
}

.roles-matrix-sub {
  font-size: 12.5px;
  color: #64748b;
}

.roles-matrix-scroll-wrap {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.03);
  overflow-x: auto;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.roles-matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 820px;
}

/* Feature column sticky on left */
.roles-matrix-table th.col-feature-sticky,
.roles-matrix-table td.col-feature-sticky {
  position: sticky;
  left: 0;
  background: #ffffff;
  z-index: 5;
  width: 260px;
  min-width: 250px;
  max-width: 300px;
  border-right: 1.5px solid #e2e8f0;
  box-shadow: 2px 0 5px rgba(15, 23, 42, 0.02);
}

.roles-matrix-table thead tr th.col-feature-sticky {
  background: #f8fafc;
  z-index: 15;
}

.feature-head-minimal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
}

.feature-head-title {
  font-size: 13px;
  font-weight: 650;
  color: #0f172a;
}

.feature-head-count {
  font-size: 10.5px;
  font-weight: 600;
  color: #64748b;
  background: #ffffff;
  padding: 1px 6px;
  border-radius: 99px;
  border: 1px solid #e2e8f0;
}

.roles-matrix-table thead th {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 12px;
  vertical-align: middle;
  text-align: left;
}

/* Role Column Headers (Ultra-Minimal) */
.roles-matrix-table th.col-role-header {
  min-width: 195px;
  border-right: 1px solid #f1f5f9;
  padding: 8px 14px;
}

.role-col-minimal-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.role-col-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.role-col-identity {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.role-col-icon {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

.role-col-name {
  font-size: 13px;
  font-weight: 650;
  color: #0f172a;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-col-user-count {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  background: #ffffff;
  padding: 1px 5px;
  border-radius: 99px;
  border: 1px solid #e2e8f0;
  line-height: 1.3;
  flex-shrink: 0;
}

.role-col-ghost-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.btn-role-ghost-action {
  background: none;
  border: none;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.65;
  line-height: 1;
  transition: all 0.15s ease;
}

.btn-role-ghost-action:hover {
  opacity: 1;
  background: #e2e8f0;
}

.btn-role-ghost-action.danger {
  color: #ef4444;
}

.btn-role-ghost-action.danger:hover {
  background: #fee2e2;
  opacity: 1;
}

.role-col-bot-row {
  display: flex;
  align-items: center;
  min-height: 18px;
}

.role-col-toggles-minimal {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
}

.btn-role-toggle-text {
  background: none;
  border: none;
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  line-height: 1.3;
  transition: color 0.15s ease;
}

.btn-role-toggle-text:hover {
  color: #2563eb;
  text-decoration: underline;
}

.role-toggle-sep {
  color: #cbd5e1;
  font-size: 11px;
  user-select: none;
}

.role-col-full-perm-minimal {
  font-size: 11px;
  font-weight: 600;
  color: #16a34a;
  line-height: 1.3;
}

/* In-line Role Rename Card */
.role-inline-rename-card {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #ffffff;
  border: 1px solid #3b82f6;
  border-radius: 6px;
  padding: 3px 6px;
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.15);
}

.input-inline-rename {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  color: #0f172a;
  outline: none;
  padding: 2px 0;
}

/* Add Role Column at end of table header (In-line Mode) */
.roles-matrix-table th.col-add-role-header {
  min-width: 185px;
  background: #fcfcfc;
  vertical-align: middle;
  border-left: 1.5px dashed #cbd5e1;
  padding: 6px 10px;
}

.roles-matrix-table th.col-add-role-header.active-inline-add {
  background: #ffffff;
  border-left: 2px solid #3b82f6;
}

.btn-add-role-minimal {
  width: 100%;
  min-width: 140px;
  height: 38px;
  border: 1px dashed #cbd5e1;
  background: #ffffff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #475569;
  cursor: pointer;
  transition: all 0.18s ease;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.btn-add-role-minimal:hover {
  border-color: #3b82f6;
  color: #2563eb;
  background: #eff6ff;
}

.btn-add-role-icon {
  font-size: 12px;
}

/* Active Inline Add Card */
.inline-role-add-card {
  background: #ffffff;
  border: 1.5px solid #3b82f6;
  border-radius: 6px;
  padding: 5px 8px;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.12);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inline-role-input-line {
  display: flex;
  align-items: center;
  gap: 5px;
}

.inline-role-lead-icon {
  font-size: 13px;
  flex-shrink: 0;
}

.input-inline-new-role {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  color: #0f172a;
  outline: none;
  font-family: inherit;
  padding: 2px 0;
}

.input-inline-new-role::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

.inline-role-actions-group {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.btn-inline-action {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  font-family: inherit;
  padding: 0;
}

.btn-inline-action.save {
  background: #2563eb;
  color: #ffffff;
}

.btn-inline-action.save:hover {
  background: #1d4ed8;
}

.btn-inline-action.cancel {
  background: #f1f5f9;
  color: #64748b;
}

.btn-inline-action.cancel:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.inline-role-bottom-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 10.5px;
  padding-top: 1px;
}

.inline-role-toggles {
  display: flex;
  align-items: center;
  gap: 4px;
}

.inline-role-hint-text {
  font-size: 10px;
  color: #94a3b8;
  white-space: nowrap;
}

/* Col Add Role Cell (Empty vs Draft) */
.roles-matrix-table td.col-add-role-cell {
  border-left: 1.5px dashed #cbd5e1;
  text-align: center;
  vertical-align: middle;
}

.roles-matrix-table td.col-add-role-cell.empty-col {
  background: #fafafa;
}

.roles-matrix-table td.col-add-role-cell.active-draft {
  background: #f8fafc;
  border-left: 2px solid #3b82f6;
}

/* Group Rows */
.roles-matrix-table tr.row-perm-group td {
  background: #f1f5f9;
  padding: 9px 18px;
  font-weight: 700;
  font-size: 13px;
  color: #1e293b;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}

/* Permission Item Rows */
.roles-matrix-table tr.row-perm-item td {
  padding: 13px 18px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.roles-matrix-table tr.row-perm-item:hover td {
  background: #fbfcfe;
}

.roles-matrix-table tr.row-perm-item:hover td.col-feature-sticky {
  background: #f8fafc;
}

.perm-cell-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.perm-cell-title {
  font-weight: 650;
  color: #0f172a;
  font-size: 13.5px;
}

.perm-cell-desc {
  font-size: 11.5px;
  color: #64748b;
  line-height: 1.35;
}

.roles-matrix-table td.col-role-cell {
  text-align: center;
  border-right: 1px solid #f1f5f9;
}

.roles-matrix-table td.col-role-cell .switch-toggle-wrap {
  margin: 0 auto;
}

/* Users Assignment Section */
.roles-users-assign-section {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px 24px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.roles-users-assign-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.roles-users-assign-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 2px;
}

.roles-users-assign-sub {
  font-size: 13px;
  color: #64748b;
}

.roles-users-search-box {
  min-width: 280px;
}

/* Company Settings & Modal Universal Form Controls */
.modal-company-settings .form-control,
.company-settings-inner .form-control,
.settings-section .form-control,
.roles-users-assign-section .form-control {
  width: 100%;
  height: 38px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: #0f172a;
  background: #ffffff;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.modal-company-settings .form-control:focus,
.company-settings-inner .form-control:focus,
.settings-section .form-control:focus,
.roles-users-assign-section .form-control:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.modal-company-settings .form-control::placeholder,
.company-settings-inner .form-control::placeholder,
.settings-section .form-control::placeholder,
.roles-users-assign-section .form-control::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

/* Users & Roles List (Enterprise Clean Layout - GitHub / Linear / Stripe Standard) */
.roles-users-assign-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.roles-badge-count {
  font-size: 11px;
  font-weight: 700;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 1px 7px;
  border-radius: 99px;
  line-height: 1.3;
}

.users-roles-table-wrap {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: visible;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.users-roles-list {
  display: flex;
  flex-direction: column;
}

.user-role-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.12s ease;
}

.user-role-row:first-child {
  border-top-left-radius: 11px;
  border-top-right-radius: 11px;
}

.user-role-row:last-child {
  border-bottom: none;
  border-bottom-left-radius: 11px;
  border-bottom-right-radius: 11px;
}

.user-role-row:hover {
  background: #f8fafc;
}

.user-role-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.user-row-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #eff6ff;
  color: #2563eb;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #dbeafe;
}

.user-row-names {
  min-width: 0;
}

.user-row-fullname {
  font-size: 13.5px;
  font-weight: 650;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-row-email {
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.user-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.user-role-selector-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Status Pill in name */
.user-status-pill.is-disabled {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.user-self-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.user-role-row.is-disabled {
  background: #fcfcfd;
}

.user-role-row.is-disabled .user-row-fullname {
  color: #64748b;
}

.user-role-row.is-disabled .user-row-avatar {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #94a3b8;
}

/* Status Toggle Button */
.btn-user-status-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  height: 34px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  white-space: nowrap;
}

.btn-user-status-toggle.is-active {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.btn-user-status-toggle.is-active:hover {
  background: #dcfce7;
  border-color: #86efac;
}

.btn-user-status-toggle.is-disabled {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.btn-user-status-toggle.is-disabled:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.btn-user-status-toggle:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.dot-green {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.status-dot.dot-red {
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* User Delete Button */
.btn-user-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-user-delete:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
  transform: translateY(-1px);
}

.btn-user-delete:active {
  transform: translateY(0);
}

.btn-user-delete:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #94a3b8;
}

/* Single Role Dropdown Button (Matches GEMINI.md Rule 1) */
.btn-user-role-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 14px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  min-width: 175px;
  justify-content: space-between;
}

.btn-user-role-dropdown-trigger:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-user-role-dropdown-trigger:focus,
.btn-user-role-dropdown-trigger.is-open {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

.btn-user-role-dropdown-trigger.is-admin {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.btn-user-role-dropdown-trigger.is-admin:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.role-badge-icon {
  font-size: 14px;
  line-height: 1;
}

.role-badge-name {
  flex: 1;
  text-align: left;
}

.role-badge-arrow {
  color: #94a3b8;
  font-size: 12px;
  transition: transform 0.15s ease;
}

.btn-user-role-dropdown-trigger.is-open .role-badge-arrow {
  transform: rotate(180deg);
}

/* Role Dropdown Menu Popover (GEMINI.md Rule 1) */
.user-role-popover {
  width: 290px;
  z-index: 99999;
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(226, 232, 240, 0.95);
  padding: 0;
  overflow: hidden;
  border: none;
}

.user-role-popover .model-dropdown-header {
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
}

.user-role-popover .dropdown-scroll-list {
  max-height: 250px;
  overflow-y: auto;
  padding: 4px;
}

.user-role-popover .model-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease;
  margin-bottom: 2px;
}

.user-role-popover .model-dropdown-item:last-child {
  margin-bottom: 0;
}

.user-role-popover .model-dropdown-item:hover {
  background: #f1f5f9;
}

.user-role-popover .model-dropdown-item.is-selected {
  background: #eff6ff;
}

.user-role-popover .model-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.user-role-popover .model-item-name {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
}

.user-role-popover .model-dropdown-item.is-selected .model-item-name {
  color: #1d4ed8;
  font-weight: 700;
}

.user-role-popover .model-item-sub {
  font-size: 11px;
  color: #64748b;
  line-height: 1.3;
}

.user-role-popover .model-item-end {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.user-role-popover .model-item-check {
  font-size: 13px;
  font-weight: 700;
  color: #2563eb;
}

/* Role Editor Dialog & Permissions Matrix */
.modal-dialog.modal-card-sheet {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 620px;
  width: calc(100% - 32px);
  margin: auto;
}

.modal-dialog.modal-card-sheet::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.role-editor-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.role-editor-body {
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.permissions-matrix-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 4px;
}

.permissions-matrix-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.matrix-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
}

.matrix-quick-actions {
  display: flex;
  gap: 6px;
}

.permissions-groups-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.permissions-group-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  overflow: hidden;
}

.perm-group-header {
  background: #f1f5f9;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.perm-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid #f8fafc;
  gap: 12px;
}

.perm-toggle-row:last-child {
  border-bottom: none;
}

.perm-toggle-info {
  flex: 1;
  min-width: 0;
}

.perm-toggle-label {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
}

.perm-toggle-desc {
  font-size: 11.5px;
  color: #64748b;
  margin-top: 1px;
}

/* Switch Toggle Component */
.switch-toggle-wrap {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.switch-toggle-wrap input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cbd5e1;
  transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.switch-toggle-wrap input:checked + .switch-slider {
  background-color: #2563eb;
}

.switch-toggle-wrap input:checked + .switch-slider:before {
  transform: translateX(18px);
}














/* ============================================================================
   ASSET DISPOSITION & REACTIVATION STYLES (จำหน่ายออก & นำกลับเข้าคลัง)
   ============================================================================ */
.asset-status-pill.disposed {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.asset-status-pill .status-indicator-dot.gray {
  background: #94a3b8;
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.2);
}

.asset-status-badge.disposed {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.status-dot.gray {
  background: #94a3b8;
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.2);
}

.status-dot.red {
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.asset-stock-card.is-disposed {
  opacity: 0.92;
  background: #fbfcfd;
  border-color: #e2e8f0;
}

.asset-stock-card.is-disposed:hover {
  opacity: 1;
  border-color: #cbd5e1;
}

.asset-disposed-minimal-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11.5px;
  color: #64748b;
  margin-top: 4px;
}

.asset-disposed-minimal-bar strong {
  color: #334155;
}

.quick-stat-pill.disposed {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.quick-stat-pill.disposed:hover {
  background: #f1f5f9;
}

/* Detail Modal Disposed Callout */
.asset-detail-disposed-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-left: 4px solid #94a3b8;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-disposed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-disposed-badge {
  font-size: 13px;
  font-weight: 700;
  color: #475569;
}

.detail-disposed-date {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  background: #ffffff;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.detail-disposed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  background: #ffffff;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.detail-disposed-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-disposed-item .item-label {
  font-size: 11px;
  color: #64748b;
}

.detail-disposed-item .item-val {
  font-size: 12.5px;
  color: #1e293b;
}

.detail-disposed-footer-action {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

/* Disposition Dialogs (Modern Minimal Standard) */
.dispose-asset-card,
.reactivate-asset-card {
  max-width: 500px;
  width: 95vw;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.16);
  border: 1px solid #e2e8f0;
  overflow: visible;
}

.dispose-asset-card .modal-header,
.reactivate-asset-card .modal-header {
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.dispose-asset-card .modal-footer,
.reactivate-asset-card .modal-footer {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}

.dispose-asset-banner {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.dispose-asset-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.dispose-asset-top-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dispose-asset-model {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.2px;
}

.dispose-asset-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11.5px;
}

.dispose-warning-callout {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fffbeb;
  border: 1px solid #fef08a;
  color: #854d0e;
  font-size: 12px;
  line-height: 1.45;
  padding: 9px 12px;
  border-radius: 8px;
  margin-top: 6px;
}

.dispose-warning-callout .callout-icon {
  font-size: 14px;
  line-height: 1.2;
  flex-shrink: 0;
}

.reactivate-info-callout {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-size: 12px;
  line-height: 1.45;
  padding: 9px 12px;
  border-radius: 8px;
  margin-top: 6px;
}

.reactivate-info-callout .callout-icon {
  font-size: 14px;
  line-height: 1.2;
  flex-shrink: 0;
}

.lib-row-disposition.row-dispose td {
  background: #fffaf0 !important;
}

.lib-row-disposition.row-reactivate td {
  background: #f0fdf4 !important;
}

/* ============================================================================
   MINIMAL LIST VIEW STYLES (ตารางใบยืมแบบ Minimal เรียบหรู)
   ============================================================================ */
.minimal-list-section {
  width: 100%;
  padding: 0 20px 32px 20px;
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  box-sizing: border-box;
}

.minimal-list-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.03);
  margin-top: 16px;
  overflow: visible;
}

.minimal-table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 900px) {
  .minimal-table-responsive {
    overflow-x: visible;
  }
}

.minimal-list-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  min-width: 900px;
}

.minimal-list-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 11px 16px;
  vertical-align: middle;
  box-shadow: 0 1px 0 #e2e8f0;
}

.minimal-list-table thead tr th:first-child {
  border-top-left-radius: 11px;
}

.minimal-list-table thead tr th:last-child {
  border-top-right-radius: 11px;
}

.minimal-list-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.12s ease;
}

.minimal-list-table tbody tr.clickable-row {
  cursor: pointer;
}

.minimal-list-table tbody tr:last-child {
  border-bottom: none;
}

.minimal-list-table tbody tr:hover {
  background: #f8fafc;
}

.minimal-list-table tbody tr.clickable-row:hover {
  background: #f1f5f9;
}

.minimal-list-table tbody tr.clickable-row:active {
  background: #e2e8f0;
}

.minimal-list-table tbody tr.clickable-row:hover .list-doc-pill {
  border-color: #93c5fd;
  background: #dbeafe;
}

.minimal-list-table tbody tr.row-overdue {
  background: #fffcfc;
}

.minimal-list-table tbody tr.row-overdue:hover {
  background: #fff5f5;
}

.minimal-list-table tbody tr.clickable-row.row-overdue:hover {
  background: #fee2e2;
}

.minimal-list-table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  font-size: 13px;
  color: #1e293b;
}

/* Empty State */
.min-empty-cell {
  padding: 48px 16px !important;
  text-align: center;
}

.min-empty-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 500;
}

.min-empty-wrap span:first-child {
  font-size: 32px;
}

/* Customer & Borrower Cell */
.min-customer-cell {
  display: flex;
  flex-direction: column;
  gap: 2.5px;
  min-width: 0;
}

.min-company-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
}

.min-customer-sub {
  font-size: 11.5px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
}

.min-customer-sub strong {
  color: #334155;
}

.min-customer-sub .sub-sep {
  color: #cbd5e1;
}

/* Items Wrap & Chips */
.min-items-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.min-item-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 7px;
  border-radius: 6px;
  font-size: 11.5px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #334155;
  transition: all 0.15s ease;
  cursor: default;
}

.min-item-chip:hover {
  border-color: #cbd5e1;
  background: #e2e8f0;
}

.min-item-chip.is-returned {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}

.min-item-name {
  font-weight: 600;
}

.min-item-sn {
  font-size: 10.5px;
  font-weight: 600;
  color: #0f172a;
  background: #ffffff;
  padding: 0 4px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  line-height: 1.4;
}

.min-item-wait {
  font-size: 10px;
  font-weight: 600;
  color: #d97706;
  background: #fef3c7;
  padding: 0 4px;
  border-radius: 4px;
  line-height: 1.4;
}

.min-item-check {
  font-size: 10px;
  font-weight: 800;
  color: #16a34a;
}

/* Status Badges */
.min-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2.5px 9px;
  border-radius: 99px;
  white-space: nowrap;
  letter-spacing: 0.1px;
}

.min-status-badge.requested {
  background: #fefce8;
  color: #854d0e;
  border: 1px solid #fef08a;
}

.min-status-badge.dispatching {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.min-status-badge.dispatched {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.min-status-badge.delivered {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.min-status-badge.partial {
  background: #faf5ff;
  color: #7e22ce;
  border: 1px solid #e9d5ff;
}

.min-status-badge.overdue {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.min-status-badge.returned {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* Due Date & Progress Cell */
.min-due-cell {
  display: flex;
  flex-direction: column;
  gap: 3.5px;
}

.min-due-date-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
}

.due-date-text {
  color: #334155;
}

.due-date-text strong {
  color: #0f172a;
}

.due-tag.overdue {
  font-size: 11.5px;
  font-weight: 700;
  color: #b91c1c;
  background: #fee2e2;
  padding: 1.5px 7px;
  border-radius: 4px;
  border: 1px solid #fca5a5;
  white-space: nowrap;
}

.min-progress-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #64748b;
}

.min-progress-track {
  width: 40px;
  height: 5px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
  display: inline-block;
  flex-shrink: 0;
}

.min-progress-bar {
  height: 100%;
  background: #22c55e;
  border-radius: 99px;
  display: block;
}

/* Actions Toolbar */
.min-actions-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.btn-min-tool {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.btn-min-tool:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

.btn-min-tool.danger {
  color: #ef4444;
}

.btn-min-tool.danger:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.btn-min-return {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid #86efac;
  background: #f0fdf4;
  color: #15803d;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-min-return:hover {
  background: #dcfce7;
  border-color: #4ade80;
}

.btn-min-deliver {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-min-deliver:hover {
  background: #dbeafe;
  border-color: #60a5fa;
}

/* ============================================================================
   RESPONSIVE MOBILE LIST VIEW (CARD VIEW FOR SCREENS <= 768px)
   ============================================================================ */
@media (max-width: 768px) {
  .minimal-list-section {
    padding: 8px 10px 85px 10px !important;
  }

  .minimal-list-card {
    margin-top: 6px !important;
    border-radius: 12px !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04) !important;
    background: #ffffff !important;
    overflow: hidden !important;
  }

  .minimal-table-responsive {
    overflow-x: visible !important;
    width: 100% !important;
  }

  .minimal-list-table {
    min-width: 0 !important;
    width: 100% !important;
    display: block !important;
    border-collapse: separate !important;
  }

  .minimal-list-table thead {
    display: none !important;
  }

  .minimal-list-table tbody {
    display: block !important;
    width: 100% !important;
  }

  .minimal-list-table tbody tr.min-table-row {
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    grid-template-areas:
      "doc status"
      "customer customer"
      "items items"
      "due actions" !important;
    gap: 8px 10px !important;
    align-items: center !important;
    padding: 12px 14px !important;
    border-bottom: 1px solid #f1f5f9 !important;
    background: #ffffff !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .minimal-list-table tbody tr.min-table-row.clickable-row:active {
    background: #f8fafc !important;
  }

  .minimal-list-table tbody tr.min-table-row:last-child {
    border-bottom: none !important;
  }

  .minimal-list-table tbody tr.min-table-row > td {
    padding: 0 !important;
    border: none !important;
    display: block !important;
    min-width: 0 !important;
  }

  .minimal-list-table tbody tr.min-table-row > td:nth-child(1) {
    grid-area: doc !important;
    justify-self: start !important;
  }

  .minimal-list-table tbody tr.min-table-row > td:nth-child(2) {
    grid-area: customer !important;
    width: 100% !important;
  }

  .minimal-list-table tbody tr.min-table-row > td:nth-child(3) {
    grid-area: items !important;
    width: 100% !important;
  }

  .minimal-list-table tbody tr.min-table-row > td:nth-child(4) {
    grid-area: status !important;
    justify-self: end !important;
    text-align: right !important;
  }

  .minimal-list-table tbody tr.min-table-row > td:nth-child(5) {
    grid-area: due !important;
  }

  .minimal-list-table tbody tr.min-table-row > td:nth-child(6) {
    grid-area: actions !important;
    justify-self: end !important;
    text-align: right !important;
  }

  .min-customer-cell {
    width: 100% !important;
  }

  .min-company-name {
    max-width: 100% !important;
    white-space: normal !important;
    font-size: 14px !important;
    line-height: 1.35 !important;
    word-break: break-word !important;
  }

  .min-customer-sub {
    max-width: 100% !important;
    white-space: normal !important;
    font-size: 12px !important;
    flex-wrap: wrap !important;
    margin-top: 3px !important;
    gap: 4px 6px !important;
  }

  .min-items-wrap {
    gap: 4px !important;
    margin-top: 2px !important;
  }

  .min-item-chip {
    padding: 3px 7px !important;
    font-size: 11.5px !important;
  }

  .min-due-cell {
    gap: 3px !important;
  }

  .min-due-date-row {
    font-size: 12px !important;
  }

  .min-progress-row {
    font-size: 11px !important;
  }

  .min-actions-toolbar {
    gap: 5px !important;
  }

  .btn-min-tool {
    width: 32px !important;
    height: 32px !important;
    font-size: 13px !important;
  }

  .btn-min-return,
  .btn-min-deliver {
    height: 32px !important;
    padding: 0 10px !important;
    font-size: 12px !important;
  }

  /* --------------------------------------------------------------------------
     TAB 5: USERS & ROLES ASSIGNMENT MOBILE CARD STYLES
     -------------------------------------------------------------------------- */
  .roles-users-assign-section {
    padding: 4px 0 !important;
  }

  .roles-users-assign-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .roles-users-assign-title {
    font-size: 14px !important;
  }

  .roles-users-assign-sub {
    font-size: 12px !important;
    line-height: 1.4 !important;
  }

  .roles-users-search-box {
    min-width: 0 !important;
    width: 100% !important;
  }

  .user-role-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px 14px !important;
  }

  .user-role-info {
    width: 100% !important;
    min-width: 0 !important;
    gap: 12px !important;
  }

  .user-row-avatar {
    width: 36px !important;
    height: 36px !important;
    font-size: 14px !important;
    flex-shrink: 0 !important;
  }

  .user-row-names {
    flex: 1 !important;
    min-width: 0 !important;
  }

  .user-row-fullname {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.3 !important;
  }

  .user-row-email {
    font-size: 12px !important;
    color: #64748b !important;
    white-space: normal !important;
    word-break: break-all !important;
    margin-top: 2px !important;
  }

  .user-row-actions {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .user-role-selector-wrap {
    flex: 1 !important;
    min-width: 0 !important;
    width: auto !important;
  }

  .btn-user-role-dropdown-trigger {
    width: 100% !important;
    min-width: 0 !important;
  }

  .btn-user-status-toggle {
    flex-shrink: 0 !important;
  }

  .btn-user-delete {
    flex-shrink: 0 !important;
  }

  .user-role-chips-group {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    justify-content: flex-start !important;
  }

  .user-role-chip {
    flex: 1 1 calc(50% - 6px) !important;
    min-width: 125px !important;
    justify-content: center !important;
    padding: 7px 10px !important;
    font-size: 12px !important;
    box-sizing: border-box !important;
  }

  /* --------------------------------------------------------------------------
     TAB 4: ROLES MATRIX MOBILE COMPACT RESPONSIVENESS
     -------------------------------------------------------------------------- */
  .roles-tab-fullscreen-container {
    padding: 4px 0 !important;
  }

  .roles-matrix-title {
    font-size: 14px !important;
  }

  .roles-matrix-sub {
    font-size: 12px !important;
    line-height: 1.4 !important;
  }

  .roles-matrix-scroll-wrap {
    border-radius: 10px !important;
    margin-top: 6px !important;
    max-width: 100% !important;
  }

  .roles-matrix-table {
    min-width: 580px !important;
  }

  .roles-matrix-table th.col-feature-sticky,
  .roles-matrix-table td.col-feature-sticky {
    width: 145px !important;
    min-width: 140px !important;
    max-width: 155px !important;
    padding: 9px 8px !important;
    box-shadow: 2px 0 6px rgba(15, 23, 42, 0.06) !important;
  }

  .feature-head-title {
    font-size: 11.5px !important;
    font-weight: 700 !important;
  }

  .feature-head-count {
    display: none !important;
  }

  .perm-item-title {
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    color: #0f172a !important;
    word-break: break-word !important;
  }

  .perm-item-desc {
    display: none !important;
  }

  .roles-matrix-table th.role-col-header,
  .roles-matrix-table td.role-perm-cell {
    width: 125px !important;
    min-width: 115px !important;
    padding: 8px 6px !important;
  }

  .role-head-card {
    padding: 6px 8px !important;
  }

  .role-head-name {
    font-size: 12px !important;
    white-space: normal !important;
    line-height: 1.25 !important;
  }

  .role-head-desc {
    display: none !important;
  }

  .role-head-actions {
    gap: 3px !important;
    margin-top: 4px !important;
  }

  .btn-role-action {
    padding: 2px 6px !important;
    font-size: 10.5px !important;
  }
}
