  /* Premium Flatpickr overrides */
  .flatpickr-calendar {

    border: 1px solid var(--bd) !important;
    border-radius: 12px !important;
  }

  .flatpickr-day.selected {
    background: var(--p) !important;
    border-color: var(--p) !important;
  }

  .pwd-mask {
    -webkit-text-security: disc;
  }

  :root {
    --p: #4f46e5;
    --p-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --pl: rgba(79, 70, 229, 0.08);
    --ok: #059669;
    --err: #dc2626;
    --warn: #ea580c;
    --bg: #f4f7f9;
    /* Softer, slightly cool background */
    --bd: #cbd5e1;
    /* Darkened border for better contrast against background */
    --bd-light: #e2e8f0;
    --sub: #64748b;
    --text: #1e293b;
    --card-shadow: 0 12px 36px rgba(0, 0, 0, 0.04);
  }

  * {
    box-sizing: border-box;
  }

  body {
    font-family: 'Sarabun', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    margin: 0;
    display: flex;
    overflow: hidden;
  }

  /* ── LOADER ── */
  #loader {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 40000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
  }

  .spin {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bd);
    border-top-color: var(--p);
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }

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

  /* ── LOGIN ── */
  #login-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(30, 41, 59, 0.7);
    z-index: 30000;
    backdrop-filter: blur(6px);
  }

  .card {
    background: #ffffff;
    padding: 32px;
    border-radius: 20px;
    text-align: center;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--bd);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    /* Added default shadow */
    margin: 16px;
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }

  .card:hover {
    transform: translateY(-2px);

  }

  /* ── SWAL MODAL ── */
  #swal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 41, 59, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 30000;
    backdrop-filter: blur(8px);
    padding: 20px;
  }

  .swal-box {
    background: #ffffff;
    padding: 36px;
    border-radius: 24px;
    text-align: center;
    width: 100%;
    max-width: 400px;
    border: none;

    animation: pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  @keyframes pop {
    from {
      transform: scale(0.8);
      opacity: 0;
    }

    to {
      transform: scale(1);
      opacity: 1;
    }
  }

  .swal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 20px;
  }

  .sw-succ {
    background: #ecfdf5;
    color: #10b981;
  }

  .sw-err {
    background: #fef2f2;
    color: #ef4444;
  }

  .sw-warn {
    background: #fffbeb;
    color: #f59e0b;
  }

  .sw-info {
    background: #eff6ff;
    color: #3b82f6;
  }

  .fi-wrap {
    position: relative;
    margin-bottom: 16px;
    text-align: left;
  }

  .fi-wrap>i {
    position: absolute;
    left: 14px;
    top: 38px;
    color: var(--sub);
  }

  .fi-wrap label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
  }

  .fi-wrap input,
  .fi-wrap select,
  .fi-wrap textarea {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid var(--bd);
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    background: #ffffff;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
    /* Slight inner shadow to separate from bg */
  }

  .fi-wrap input.no-icon,
  .fi-wrap select.no-icon,
  .fi-wrap textarea.no-icon {
    padding-left: 12px;
  }

  .hpc-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--bd);
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
  }

  .hpc-input:focus {
    border-color: var(--p);
  }

  .btn {
    width: 100%;
    padding: 12px 18px;
    background: var(--p-grad);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  }

  .btn:hover {
    transform: translateY(-2px);

  }

  .btn:active {
    transform: translateY(1px);

  }

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

  /* ── STANDARD TYPOGRAPHY, BADGES & FORMS (PHASE 3 REFACTOR) ── */
  .hpc-title-h3 {
    margin: 0 0 16px 0;
    font-weight: 700;
    color: var(--text);
  }

  .hpc-title-h3.no-margin {
    margin: 0;
  }

  .hpc-title-h3.text-warn {
    color: #b45309;
  }

  .hpc-label {
    margin: 0;
    font-weight: 600;
    color: var(--text);
    font-size: 0.85rem;
  }

  .hpc-label.text-danger {
    color: #9f1239;
  }

  .hpc-label.text-warn {
    color: #92400e;
  }

  .hpc-label.text-primary {
    color: #0369a1;
  }

  .hpc-radio-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
  }

  .hpc-radio-label.flex-start {
    justify-content: flex-start;
  }

  .hpc-text {
    color: var(--text);
    font-weight: 600;
  }

  .hpc-text.text-primary {
    color: var(--p);
  }

  .hpc-text.bold {
    font-weight: 700;
  }
  
  .hpc-text.extra-bold {
    font-weight: 800;
  }

  .hpc-text.block {
    display: block;
  }

  .hpc-text-muted {
    font-size: 0.9rem;
    color: var(--sub);
    font-weight: 600;
  }

  .hpc-text-danger {
    color: #ef4444;
    font-weight: 600;
  }

  .hpc-text-warn {
    color: #ea580c;
    font-weight: 700;
  }

  .hpc-badge-danger {
    color: #ef4444;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fef2f2;
    padding: 2px 8px;
    border-radius: 4px;
  }

  .hpc-badge-primary {
    color: var(--p);
    font-weight: 800;
  }

  .hpc-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: background 0.3s;
  }

  /* --- Layout & Structure (Phase 4) --- */
  .hpc-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--bd);
  }

  .hpc-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
  }

  .hpc-divider {
    width: 1px;
    height: 24px;
    background: var(--bd);
    margin: 0 4px;
  }

  .hpc-chart-container {
    height: 250px;
  }

  .flex-1 {
    flex: 1;
  }

  .flex-row-gap10 {
    display: flex;
    gap: 10px;
  }

  .flex-row-sb {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  /* ── STANDARD BUTTON CLASSES (PHASE 1 REFACTOR) ── */
  .hpc-btn {
    width: auto;
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    background: transparent;
  }

  .hpc-btn:hover {
    transform: translateY(-2px);
  }

  .hpc-btn:active {
    transform: translateY(1px);
  }

  .hpc-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
  }

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

  .hpc-btn-outline-warning {
    background: #fff7ed;
    color: #ea580c;
    border: 1px solid #fdba74;
  }
  
  .hpc-btn-secondary {
    background: #f1f5f9;
    color: var(--text);
    border: 1px solid var(--bd);
  }

  .hpc-btn-success {
    background: #10b981;
    color: #fff;
  }

  .hpc-btn-warning {
    background: #fef08a;
    color: #854d0e;
    border: 1px solid #fde047;
  }

  .hpc-btn-danger {
    background: #e11d48;
    color: #fff;
  }

  .hpc-btn-indigo {
    background: #4f46e5;
    color: #fff;
  }

  .hpc-btn-icon {
    flex: 1;
    padding: 4px 12px;
    justify-content: center;
  }

  .hpc-btn-icon-primary {
    background: var(--p);
    color: #fff;
  }

  .hpc-btn-icon-transparent {
    background: transparent;
    color: var(--sub);
  }

  /* ── PIN PULSE ── */
  .pin-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    animation: pinPulse 2s cubic-bezier(0, 0, 0.2, 1) infinite;
    pointer-events: none;
    border: 4px solid currentColor;
    background: transparent;
  }

  @keyframes pinPulse {
    0% {
      transform: translate(-50%, -50%) scale(1);
      opacity: 1;
    }

    100% {
      transform: translate(-50%, -50%) scale(5.5);
      opacity: 0;
    }
  }

  /* ── ADMIN ONLY ── */
  body:not(.logged-in) .admin-disabled-if-logout {
    opacity: 0.5 !important;
    filter: grayscale(100%);
  }

  body:not(.logged-in) .admin-only {
    display: none !important;
  }

  body.history-mode .admin-only:not(.allow-in-history) {
    display: none !important;
  }

  body.history-mode .action-btn {
    display: none !important;
  }

  body.logged-in .user-only {
    display: none !important;
  }

  /* ── LAYOUT ── */
  #app {
    display: flex;
    flex-direction: column;
    /* Stack top-to-bottom */
    width: 100%;
    height: 100%;
  }

  .sb {
    position: fixed;
    bottom: 20px;
    left: 50%;
    /* จัดกึ่งกลางจอ */
    width: max-content;
    /* ขนาดบาร์พอดีกับเมนูที่มี (Dynamic) */
    max-width: 95vw;
    height: 64px;
    background: var(--p-grad);
    /* ใช้สีเดียวกับ Head บน */
    border: none;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(79, 70, 229, 0.3);
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0 10px;
    z-index: 15000;
    user-select: none;
    /* Prevent accidental text highlighting */
    -webkit-user-select: none;


    /* Ghost State (Auto-hide) */
    transform: translateX(-50%) translateY(calc(100% + 20px - 4px));
    opacity: 0.35;
    /* เมื่อเอาเมาส์ออก ให้รอ 0.8 วินาที (0.8s delay) ค่อยยุบลงไป */
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.8s;
  }

  /* Invisible hover trigger area (Top) */
  .sb::before {
    content: '';
    position: absolute;
    top: -50px;
    /* ขยายพื้นที่รับเมาส์ด้านบน */
    left: -20px;
    right: -20px;
    height: 50px;
    background: transparent;
  }

  /* Invisible hover trigger area (Bottom) 
     สำคัญมาก! ป้องกันบั๊กเมาส์หลุดตอนบาร์เด้งขึ้น ทำให้บาร์ยุบๆพองๆรัวๆ */
  .sb::after {
    content: '';
    position: absolute;
    bottom: -100px;
    /* ขยายพื้นที่รับเมาส์ด้านล่าง ปิดช่องโหว่ใต้บาร์ */
    left: -20px;
    right: -20px;
    height: 100px;
    background: transparent;
  }

  /* Wake State (Hover or Start Menu Open) */
  .sb:hover,
  body:has(.start-menu.show) .sb {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    /* เมื่อเอาเมาส์เข้า ให้เด้งขึ้นมาทันที (0s delay) */
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0s;
  }

  /* Pinned State (ตรึงค้างไว้) */
  .sb.pinned {
    transform: translateX(-50%) translateY(0) !important;
    opacity: 1 !important;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0s !important;
  }

  .sb.collapsed {
    width: 80px;
  }



  .sb-top {
    position: relative;
    z-index: 100;
    cursor: pointer;
    margin-left: 12px;
    margin-right: 18px;
    /* Extra space for the divider */
    display: flex;
    align-items: center;
  }

  /* Divider line next to Start Button */
  .sb-top::after {
    content: '';
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 24px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
  }



  .sb-ico {
    background: #ffffff;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -16px;
    /* Break out of the dock top boundary */
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
  }

  .sb-top:hover .sb-ico {
    transform: translateY(-4px) scale(1.05);
  }

  .sb-top.act .sb-ico {
    background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
    box-shadow: 0 4px 15px rgba(0, 114, 255, 0.4);
    transform: translateY(-2px) scale(0.95);
  }

  .sb-ico i {
    font-size: 1.6rem;
    background: var(--p-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
  }

  .sb-top.act .sb-ico i {
    background: #ffffff;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  }

  .sb-txt {
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.2;
    transition: opacity 0.2s;
    color: #f8fafc;
  }

  .sb.collapsed .sb-txt {
    opacity: 0;
    pointer-events: none;
  }

  .sb-txt span {
    display: block;
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 400;
  }

  .toggle-btn {
    position: absolute;
    right: -15px;
    top: 25px;
    width: 30px;
    height: 30px;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;

    color: #94a3b8;
  }

  .sb.collapsed .toggle-btn i {
    transform: rotate(180deg);
  }

  nav {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0 16px;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    /* Hide scrollbar for clean look */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
  }

  nav::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
  }

  .nav-divider {
    width: 2px;
    height: 24px;
    background: rgba(255, 255, 255, 0.25);
    margin: 0 6px;
    border-radius: 2px;
    flex-shrink: 0;
  }

  .ni {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-direction: row;
    gap: 0;
    padding: 10px 12px;
    height: 44px;
    min-width: 44px;
    border-radius: 22px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    text-align: center;
    margin-bottom: 0;
    /* overflow: hidden; Removed to allow tooltip overflow */
    white-space: nowrap;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .ni span {
    max-width: 0;
    opacity: 0;
    transform: translateX(-10px);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .ni:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
  }

  .ni.act {
    background: #ffffff;
    color: var(--p);
    font-weight: 600;
    gap: 10px;
    padding: 10px 18px 10px 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);

  }

  .ni.act span {
    max-width: 120px;
    opacity: 1;
    transform: translateX(0);
  }

  .ni i {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
    line-height: 1;
  }



  .sb.collapsed .ni span {
    opacity: 0;
    pointer-events: none;
  }

  .sb-user {
    padding: 0 16px;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    height: 100%;
  }

  .u-av {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .sb.collapsed .u-info,
  .sb.collapsed .u-av {
    display: none;
  }

  .sb.collapsed .sb-user {
    flex-direction: column;
    padding: 16px 0;
    gap: 12px;
  }

  /* ── START MENU FLYOUT ── */
  .start-menu {
    position: absolute;
    bottom: calc(100% + 15px);
    /* ลอยเหนือปุ่ม Start 15px */
    left: 10px;
    /* ขยับจากขอบซ้ายของบาร์เข้ามา 10px ให้ตรงกับปุ่ม */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;

    z-index: 20000;
    display: none;
    flex-direction: column;
    width: 280px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    user-select: none;
    -webkit-user-select: none;
  }

  .start-menu.show {
    display: flex;
    animation: startMenuSlideUp 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.2) forwards;
    transform-origin: bottom left;
  }

  @keyframes startMenuSlideUp {
    0% {
      opacity: 0;
      transform: translateY(40px) scale(0.9);
    }

    100% {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

  .ni-start {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
  }

  .ni-start:hover {
    background: var(--bg);
    color: var(--p);
  }

  .ni-start i {
    font-size: 1.1rem;
    color: var(--sub);
    width: 24px;
    text-align: center;
  }

  .ni-start:hover i {
    color: var(--p);
  }

  .main {
    order: 1;
    /* Move to top */
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
  }

  .topbar {
    height: 52px;
    background: #0f172a;
    /* Dark background as requested */
    color: #ffffff;
    border-bottom: 1px solid #1e293b;

    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 30;
    flex-shrink: 0;
  }

  .pg {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    /* ยอมให้หน้าเพจเลื่อนแนวนอนได้ทั้งหมด */
    padding: 0 30px 100px;
    /* เปลี่ยน padding-top เป็น 0 เพื่อให้ sticky แนบสนิทกับ topbar */
    display: none;
  }
  
  .pg::before {
    content: '';
    display: block;
    height: 24px;
    flex-shrink: 0;
    /* ทำหน้าที่แทน padding-top เพื่อให้มีระยะห่างเริ่มต้น แต่ยอมให้ sticky ไถลทับได้ */
  }

  .pg.act {
    display: block;
  }

  /* ── COMPONENTS ── */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
  }

  @media (max-width: 900px) {
    .stats-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  @media (max-width: 500px) {
    .stats-grid {
      grid-template-columns: 1fr;
    }
  }

  .stat-card {
    background: #fff;
    padding: 22px;
    border-radius: 16px;
    border: 2px solid #e2e8f0;

    transition: transform 0.2s, box-shadow 0.2s;
    cursor: default;
    text-align: center;
  }

  .stat-card.waiting {
    border-color: #fbbf24;
    background: #fffbeb;
  }

  .stat-card.prog {
    border-color: #6366f1;
    background: #eef2ff;
  }

  .stat-card.done {
    border-color: #10b981;
    background: #ecfdf5;
  }

  .stat-card.in-sh {
    border-color: #06b6d4;
    background: #ecfeff;
  }

  .stat-card.moved {
    border-color: #f59e0b;
    background: #fff7ed;
  }

  .stat-card:hover {
    transform: translateY(-2px);

  }

  .stat-num {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 8px;
  }

  /* ── PREMIUM DASH CARD ── */
  .dash-card {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px 18px;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;

    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .dash-card:hover {
    transform: translateY(-2px);

  }

  .dash-card .dc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
  }

  .dash-card .dc-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dash-card .dc-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 0 -18px;
  }

  .dash-card .dc-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--sub);
  }

  .dash-card.highlight-glow {
    border-color: var(--p) !important;

  }

  /* ── INCIDENT CARD ── */
  .inc-card {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px 18px;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s;

  }

  .inc-card:hover {
    transform: translateY(-1px);

  }

  .inc-card.highlight-glow {
    border-color: var(--p) !important;

  }

  /* ── BADGES & STATUS TAGS (Central Standard) ── */
  .badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
    text-align: center;
    border: 1.5px solid transparent;
    transition: all 0.2s ease;
  }

  /* Status Colors */
  .badge-ok {
    background: #ecfdf5;
    color: var(--ok);
    border-color: #a7f3d0;
  }

  .badge-warn {
    background: #fffbeb;
    color: var(--warn);
    border-color: #fde68a;
  }

  .badge-err {
    background: #fef2f2;
    color: var(--err);
    border-color: #fecaca;
  }

  .badge-info {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
  }

  .badge-primary {
    background: var(--pl);
    color: var(--p);
    border-color: rgba(79, 70, 229, 0.2);
  }

  .badge-neutral {
    background: #f1f5f9;
    color: var(--sub);
    border-color: var(--bd);
  }

  /* Specific Event Badges */
  .badge-walkin {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
  }

  .badge-incident {
    background: #f5f3ff;
    color: #3730a3;
    border-color: #ddd6fe;
  }

  .badge-vul {
    background: #fdf4ff;
    color: #86198f;
    border-color: #f5d0fe;
  }

  .st-wait {
    background: #fef3c7;
    color: #b45309;
  }

  .st-prog {
    background: var(--pl);
    color: var(--p);
  }

  .st-done {
    background: #d1fae5;
    color: #047857;
  }

  .st-cancel {
    background: #fee2e2;
    color: #b91c1c;
  }

  table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 24px;
    background: transparent;
  }

  th,
  td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--bd);
  }

  th {
    padding: 14px 12px;
    background: #f8fafc;
    color: var(--sub);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
  }

  /* ทำให้มุมบนของหัวตารางโค้งรับกับกรอบตาราง */
  table th:first-child {
    border-top-left-radius: 12px;
  }

  table th:last-child {
    border-top-right-radius: 12px;
  }

  /* ── MODALS ── */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 20000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }

  .modal-box {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;

  }

  .modal-head {
    padding: 18px 24px;
    background: linear-gradient(135deg, var(--p) 0%, #3b82f6 100%);
    color: white;
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .modal-head h2,
  .modal-head h3,
  .modal-head h4 {
    color: white;
    margin: 0;
  }

  /* Uniform Circular Close Button for all modals */
  .modal-head i.fa-times {
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    border: none !important;
    font-size: 1.1rem !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .modal-head i.fa-times:hover {
    background: rgba(255, 255, 255, 0.35) !important;
    transform: scale(1.05) !important;
  }

  /* Reset wrapper button if any */
  .modal-head button {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: none !important;
  }

  .modal-body {
    padding: 24px;
    overflow-y: auto;
  }

  .modal-foot {
    padding: 16px 24px;
    border-top: 1px solid var(--bd);
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
  }

  /* Map Expandable */
  details {
    margin-bottom: 20px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--bd);
    overflow: hidden;
  }

  summary {
    padding: 16px 20px;
    font-weight: 600;
    cursor: pointer;
    background: #f8fafc;
    border-bottom: 1px solid var(--bd);
    outline: none;
    user-select: none;
  }

  .map-container {
    height: 100%;
    width: 100%;
    border-radius: 12px;
    background: #e2e8f0;
  }

  /* Tags */
  .tag {
    display: inline-block;
    padding: 6px 12px;
    background: var(--bg);
    border: 1px solid var(--bd);
    border-radius: 20px;
    font-size: 0.85rem;
    margin: 4px 4px 0 0;
    cursor: pointer;
    user-select: none;
  }

  .tag.sel {
    background: var(--pl);
    border-color: var(--p);
    color: var(--p);
    font-weight: 600;
  }

  /* Highlights for Shelters */
  .highlight-yellow {
    background-color: #fef08a !important;
    border-color: #eab308 !important;
  }

  /* Custom Pin Markers */
  .c-pin {
    background: none !important;
    border: none !important;
  }

  .pin-wrap {
    position: relative;
    width: 22px;
    height: 22px;
    transform: translate(4px, -0.34px);
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.3));
  }

  .pin-head {
    width: 22px;
    height: 22px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 2px solid #fff;
  }

  .pin-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    animation: pin-pulse-ani 1.5s infinite;
  }

  @keyframes pin-pulse-ani {
    0% {
      transform: translate(-50%, -50%) scale(1);
      opacity: 1;
    }

    100% {
      transform: translate(-50%, -50%) scale(3.5);
      opacity: 0;
    }
  }



  .inc-tag {
    font-size: 0.72rem;
    color: #4f46e5;
    background: #f5f3ff;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1.5px solid #ddd6fe;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .tag-scroll {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    cursor: grab;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .tag-scroll::-webkit-scrollbar {
    display: none;
  }

  /* ── AI ASSISTANT ── */
  #ai-balloon {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 8000;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;

    transition: right 0.3s ease, transform 0.2s, box-shadow 0.2s;
    animation: ai-float 3s ease-in-out infinite;
  }

  body.rm-preview-open #ai-balloon {
    right: 574px !important;
  }

  #ai-balloon:hover {
    transform: scale(1.1);

  }

  @keyframes ai-float {

    0%,
    100% {
      transform: translateY(0);
    }

    50% {
      transform: translateY(-6px);
    }
  }

  #ai-chat-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 8001;
    width: 380px;
    height: 520px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    background: #fff;
    border-radius: 20px;
    display: none;
    flex-direction: column;

    border: 1px solid #e2e8f0;
    transition: right 0.3s ease, width 0.15s, height 0.15s;
    /* overflow: hidden; Removed so resize handles can be grabbed outside the border */
  }

  body.rm-preview-open #ai-chat-window {
    right: 574px !important;
  }

  /* ── Resize Handles ── */
  .ai-resize-handle {
    position: absolute;
    background: transparent;
    z-index: 10;
  }

  .ai-resize-handle[data-resize="t"] {
    top: -4px;
    left: 10px;
    right: 10px;
    height: 8px;
    cursor: n-resize;
  }

  .ai-resize-handle[data-resize="r"] {
    top: 10px;
    bottom: 10px;
    right: -4px;
    width: 8px;
    cursor: e-resize;
  }

  .ai-resize-handle[data-resize="b"] {
    bottom: -4px;
    left: 10px;
    right: 10px;
    height: 8px;
    cursor: s-resize;
  }

  .ai-resize-handle[data-resize="l"] {
    top: 10px;
    bottom: 10px;
    left: -4px;
    width: 8px;
    cursor: w-resize;
  }

  .ai-resize-handle.corner {
    width: 12px;
    height: 12px;
  }

  .ai-resize-handle[data-resize="tr"] {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
  }

  .ai-resize-handle[data-resize="br"] {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
  }

  .ai-resize-handle[data-resize="bl"] {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
  }

  .ai-resize-handle[data-resize="tl"] {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
  }

  /* Ensure child containers respect rounded corners since overflow:hidden is removed */
  .ai-chat-header {
    border-radius: 19px 19px 0 0;
  }

  .ai-chat-footer {
    border-radius: 0 0 19px 19px;
  }

  .ai-chat-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
  }

  .ai-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
  }

  .ai-chat-header-info {
    flex: 1;
  }

  .ai-chat-header-info div:first-child {
    font-weight: 700;
    font-size: 0.95rem;
  }

  .ai-chat-header-info div:last-child {
    font-size: 0.72rem;
    opacity: 0.8;
  }

  .ai-chat-header button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
  }

  .ai-chat-header button:hover {
    background: rgba(255, 255, 255, 0.3);
  }

  #ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
  }

  .ai-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
  }

  .ai-msg.user {
    flex-direction: row-reverse;
  }

  .ai-msg-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
  }

  .ai-msg.ai .ai-msg-icon {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
  }

  .ai-msg.user .ai-msg-icon {
    background: #e2e8f0;
    color: #64748b;
  }

  .ai-msg-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.6;
    word-break: break-word;
  }

  .ai-msg.ai .ai-msg-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-top-left-radius: 4px;
  }

  .ai-msg.user .ai-msg-bubble {
    background: var(--p);
    color: #fff;
    border-top-right-radius: 4px;
  }

  .ai-typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
  }

  .ai-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: ai-dot 1.4s infinite;
  }

  .ai-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
  }

  .ai-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
  }

  @keyframes ai-dot {

    0%,
    80%,
    100% {
      opacity: 0.3;
      transform: scale(0.8);
    }

    40% {
      opacity: 1;
      transform: scale(1.2);
    }
  }

  .ai-chat-footer {
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    background: #fff;
    flex-shrink: 0;
  }

  #ai-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    resize: none;
  }

  #ai-chat-input:focus {
    border-color: var(--p);
  }

  #ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: var(--p);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background 0.2s;
  }

  #ai-send-btn:hover {
    background: #4338ca;
  }

  #ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .ai-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1.5px solid var(--p);
    background: var(--pl);
    color: var(--p);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    margin: 4px 2px;
    font-family: inherit;
    transition: all 0.2s;
  }

  .ai-action-btn:hover {
    background: var(--p);
    color: #fff;
  }

  .ai-external-link {
    color: var(--p);
    text-decoration: underline;
    font-weight: 600;
  }

  body.dash-fs .main {
    overflow: hidden !important;
  }

  /* 🟢 FULLSCREEN INCIDENTS 🟢 */
  #pg-incidents.is-fullscreen {
    display: grid !important;
    grid-template-columns: 1fr 400px;
    grid-template-rows: 1fr;
    gap: 20px;
    box-sizing: border-box;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    margin-bottom: 20px;
  }

  #pg-incidents.is-fullscreen>#inc-map-detail {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    height: 100%;
    display: block;
    margin-bottom: 0 !important;
  }

  #pg-incidents.is-fullscreen #map-ph-inc {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: auto !important;
    display: flex !important;
    flex-direction: column;
    border-radius: 12px;
    overflow: hidden;
  }

  #pg-incidents.is-fullscreen #map-ph-inc>#map-view-wrapper {
    flex: 1;
    display: flex !important;
    flex-direction: column;
    height: auto !important;
    min-height: 0;
  }

  #pg-incidents.is-fullscreen #map-view {
    flex: 1;
    min-height: 0 !important;
    height: auto !important;
  }

  #pg-incidents.is-fullscreen>#inc-container,
  #pg-incidents.is-fullscreen>#inc-table-container {
    grid-column: 2;
    grid-row: 1;
    height: 100%;
    margin-top: 0 !important;
    display: flex !important;
    flex-direction: column;
    overflow-y: auto;
    padding-right: 10px;
  }

  /* Force hide the inactive view when in fullscreen to override the !important above */
  #pg-incidents.is-fullscreen.view-mode-table>#inc-container {
    display: none !important;
  }

  #pg-incidents.is-fullscreen.view-mode-card>#inc-table-container {
    display: none !important;
  }

  /* ── CUSTOM HPC TOGGLE SWITCH ── */
  .hpc-switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
  }

  .hpc-switch input {
    opacity: 0;
    width: 0;
    height: 0;
  }

  .hpc-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .3s;
  }

  .hpc-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
  }

  input:checked+.hpc-slider {
    background-color: var(--p);
  }

  input:checked+.hpc-slider:before {
    transform: translateX(18px);
  }

  .hpc-slider.round {
    border-radius: 20px;
  }

  .hpc-slider.round:before {
    border-radius: 50%;
  }

  /* ── SEGMENTED CONTROL ── */
  .segmented-control {
    display: flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 10px;
    border: 1px solid var(--bd);
    position: relative;
    user-select: none;
  }

  .segmented-control input[type="radio"] {
    display: none !important;
  }

  .segmented-control label {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    margin: 0;
    transition: all 0.2s ease;
    color: #64748b;
    border: none !important;
    background: transparent;
  }

  .segmented-control input[type="radio"]:checked+label {
    background: #fff;

    color: var(--text) !important;
  }

  .segmented-control input[type="radio"]:checked+label .status-dot {
    transform: scale(1.3);
  }

  @media (min-width: 769px) {

    #pg-waste_points.act,
    #pg-staff_locations.act {
      overflow: hidden !important;
      display: flex !important;
      flex-direction: column;
      padding-bottom: 0 !important;
      /* Prevent extra padding from pushing content down */
    }

    .col-wrapper-desktop {
      flex: 1 !important;
      min-height: 0 !important;
      height: 100% !important;
      flex-wrap: nowrap !important;
    }

    .fit-desktop {
      flex: 1 !important;
      min-height: 0 !important;
      height: 100% !important;
      display: flex !important;
      flex-direction: column !important;
    }

    .scroll-desktop {
      flex: 1 !important;
      overflow-y: auto !important;
      min-height: 0 !important;
      height: auto !important;
      padding-right: 10px !important;
    }
  }

  .dt-btn {
    background: transparent;
    color: var(--sub);
    font-weight: 500;
  }

  .dt-btn.act {
    background: var(--p);
    color: #fff;
    font-weight: 600;
    border-radius: 6px;
  }

  .summary-col {
    border-right: 1.5px solid var(--bd);
  }

  @media (max-width: 992px) {

    .col-density,
    .col-current,
    .col-cumulative {
      flex: 1 1 100% !important;
      border-right: none !important;
      border-bottom: 1.5px solid var(--bd) !important;
      padding-right: 0 !important;
      padding-bottom: 14px !important;
    }

    .col-cumulative {
      border-bottom: none !important;
      padding-bottom: 0 !important;
    }
  }

  /* =========================================
/* =========================================
   DASHBOARD REFACTOR: TABS & CARDS
========================================= */

  /* FOLDER TABS CONTAINER */
  .folder-tabs-container {
    display: flex;
    gap: 2px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--bd);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .folder-tabs-container::-webkit-scrollbar {
    display: none;
  }

  /* TAB BUTTONS (FOLDER STYLE) */
  .tab-btn {
    border-radius: 12px 12px 0 0;
    background: #e2e8f0;
    /* Darker inactive state so it doesn't blend with background */
    color: #475569;
    padding: 10px 22px;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    /* ห้าม transition all ป้องกันเด้ง */
    margin-bottom: -1px;
    /* overlap border */
    border: 1px solid #cbd5e1;
    /* Stronger border between tabs */
    border-top: 3px solid transparent;
    /* จองพื้นที่ 3px ไว้ให้เท่ากับตอน Active */
    border-bottom: 1px solid transparent;
    /* จองพื้นที่ 1px ไว้ให้เท่ากับตอน Active */
    cursor: pointer;
    box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.03);
    /* Depressed look */
  }

  .tab-btn:hover {
    background: #cbd5e1;
    color: #0f172a;
  }

  .tab-btn.active {
    background: #ffffff;
    color: var(--p);
    border: 1px solid #cbd5e1;
    border-top: 3px solid var(--p);
    /* Clear active indicator */
    border-bottom: 1px solid #ffffff;
    /* Hide the container border */
    padding: 10px 22px;
    /* ใช้ Padding เท่าเดิมเป๊ะๆ จะได้ไม่กระตุก */
    font-weight: 700;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    /* Lifted appearance */
    z-index: 2;
  }

  /* TAB CONTENT */
  .tab-content {
    animation: fadeIn 0.3s ease-in-out;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    grid-auto-rows: 1fr;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(5px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* PREMIUM STAT CARD (Strict inheritance control) */
  .stat-card-new {
    background: #ffffff;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    border-left: 5px solid var(--bd);
    border-top: 1px solid var(--bd);
    border-right: 1px solid var(--bd);
    border-bottom: 1px solid var(--bd);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    /* Lift cards */
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: left;
    /* Prevent center bleed */
  }

  .stat-card-new:hover {
    transform: translateY(-3px);

  }

  .stat-card-new .sc-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--sub);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .stat-card-new .sc-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--p);
    line-height: 1;
  }

  .stat-card-new .sc-unit {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--sub);
    margin-left: 4px;
  }

  /* CARD COLORS */
  .stat-card-new.sc-blue {
    border-left-color: #3b82f6;
  }

  .stat-card-new.sc-blue .sc-title i {
    color: #3b82f6;
  }

  .stat-card-new.sc-red {
    border-left-color: #ef4444;
  }

  .stat-card-new.sc-red .sc-title i,
  .stat-card-new.sc-red .sc-value {
    color: #ef4444;
  }

  .stat-card-new.sc-orange {
    border-left-color: #f59e0b;
  }

  .stat-card-new.sc-orange .sc-title i,
  .stat-card-new.sc-orange .sc-value {
    color: #f59e0b;
  }

  .stat-card-new.sc-green {
    border-left-color: #10b981;
  }

  .stat-card-new.sc-green .sc-title i,
  .stat-card-new.sc-green .sc-value {
    color: #10b981;
  }

  .stat-card-new.sc-purple {
    border-left-color: #8b5cf6;
  }

  .stat-card-new.sc-purple .sc-title i,
  .stat-card-new.sc-purple .sc-value {
    color: #8b5cf6;
  }

  .stat-card-new.sc-gray {
    border-left-color: #94a3b8;
  }

  .stat-card-new.sc-gray .sc-title i,
  .stat-card-new.sc-gray .sc-value {
    color: #94a3b8;
  }

  .stat-card-new.sc-cyan {
    border-left-color: #06b6d4;
  }

  .stat-card-new.sc-cyan .sc-title i,
  .stat-card-new.sc-cyan .sc-value {
    color: #06b6d4;
  }

  .stat-card-new.sc-brown {
    border-left-color: #b45309;
  }

  .stat-card-new.sc-brown .sc-title i,
  .stat-card-new.sc-brown .sc-value {
    color: #b45309;
  }

  .stat-card-new.sc-pink {
    border-left-color: #ec4899;
  }

  .stat-card-new.sc-pink .sc-title i,
  .stat-card-new.sc-pink .sc-value {
    color: #ec4899;
  }

  /* SHELTER BADGES */
  .shelter-badge-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed var(--bd);
  }

  .shelter-badge {
    background: #f1f5f9;
    color: var(--text);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }

  .shelter-badge span {
    color: var(--p);
    font-weight: 800;
  }

  /* MINI BADGE FOR ORIGIN (TAB 2) */
  .origin-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    background: #f8fafc;
    border: 1px solid var(--bd);
    padding: 4px 10px;
    border-radius: 8px;
    color: var(--sub);
  }

  .origin-badge strong {
    color: var(--text);
  }



  /* ซ่อนลายน้ำของไลบรารีกล้อง (Powered by ScanApp) */
  #center-qr-reader a {
    display: none !important;
  }

  #center-qr-reader img {
    display: none !important;
  }

  #center-qr-reader video {
    border-radius: 8px !important;
  }

  /* สไตล์ปุ่มของ HTML5-QRCode */
  #center-qr-reader button {
    background: var(--p) !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 8px !important;
    font-family: inherit !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    margin: 10px auto !important;
    display: block !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
  }

  #center-qr-reader select {
    padding: 8px !important;
    border-radius: 8px !important;
    border: 1px solid var(--bd) !important;
    font-family: inherit !important;
    margin: 0 auto 10px auto !important;
    display: block !important;
    outline: none !important;
  }

  /* START MENU ACTION BUTTONS UI FIX */
  .start-menu .ni-start {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 16px;
    width: 100%;
    transition: all 0.2s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
  }

  .start-menu .ni-start:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  }

  .start-menu .ni-start i {
    width: 20px;
    text-align: center;
    color: var(--sub);
    margin-right: 8px;
  }

  /* Make the entire Start Menu pop out from the background */
  #start-menu {
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05) !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: 14px !important;
  }

  .badge-blink-warning {
    background-color: #ffedd5;
    color: #ea580c;
    border: 1px solid #fed7aa;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
    animation: blinkWarning 1.5s infinite;
  }

  @keyframes blinkWarning {
    0% {
      opacity: 1;
    }

    50% {
      opacity: 0.5;
    }

    100% {
      opacity: 1;
    }
  }
/* Custom slim scrollbar for scroll-desktop */
.scroll-desktop::-webkit-scrollbar {
  width: 6px;
}
.scroll-desktop::-webkit-scrollbar-track {
  background: transparent;
}
.scroll-desktop::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
.scroll-desktop::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ── WATER ALERT UI ── */
.water-eta-alert {
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: 800;
  margin-top: 15px;
  padding: 10px 20px;
  border-radius: 12px;
  display: inline-block;
}
.water-eta-danger {
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
}
.water-eta-warning {
  color: #d97706;
  background: #fffbeb;
  border: 1px solid #fde68a;
}
.water-hero-container {
  position: relative;
  z-index: 1;
  padding: clamp(20px, 5vh, 60px) 0;
  min-height: clamp(250px, 40vh, 400px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.water-hero-icon {
  font-size: clamp(4rem, 10vw, 8rem);
  margin-bottom: clamp(15px, 3vh, 35px);
}
.water-hero-text {
  font-size: clamp(1.2rem, 3vw, 2rem);
  color: #1e293b;
  font-weight: 700;
  line-height: 1.6;
  padding: 0 clamp(10px, 3vw, 40px);
  text-align: center;
  word-break: keep-all;
  text-wrap: balance;
}
.water-hero-ref {
  margin-top: 25px;
  font-size: clamp(0.85rem, 2vw, 1.1rem);
  color: #475569;
  background: rgba(241, 245, 249, 0.9);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 20px;
  display: inline-block;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.water-no-data {
  text-align: center;
  color: #64748b;
  padding: 35px 0;
}
.water-no-data-icon {
  font-size: 2.5rem;
  color: #f59e0b;
  margin-bottom: 12px;
}
.water-no-data-title {
  font-size: 1.1rem;
  font-weight: bold;
}
.water-no-data-subtitle {
  font-size: 0.95rem;
  margin-top: 6px;
  color: #94a3b8;
}
.water-status-card {
  height: 100%;
  box-sizing: border-box;
  color: #ffffff;
  padding: 18px 20px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid rgba(255,255,255,0.12);
}
.water-status-icon-box {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 1.5px solid rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.water-status-icon {
  font-size: 1.4rem;
  color: #ffffff;
}
.water-status-text-box {
  text-align: left;
  overflow: hidden;
  min-width: 0;
  flex: 1;
}
.water-status-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 2px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.1);
}
.water-status-desc {
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.4;
  word-break: break-word;
}
.water-status-time {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 3px;
}
.water-panel-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}
.water-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  font-weight: 800;
  color: #475569;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.water-panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
}
.water-panel-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: #94a3b8;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}
.water-panel-body {
  flex: 1;
  width: 100%;
  position: relative;
}
.water-panel-map {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}
.water-panel-links {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.water-links-title {
  font-weight: 800;
  color: #64748b;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.water-links-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  padding-left: 2px;
}
.water-link-item {
  color: #2563eb;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}
.water-range-card {
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
}
.water-range-title {
  color: #475569;
  font-weight: 800;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.water-range-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.water-range-btn-global {
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  transition: all 0.2s;
}

/* ── QR SCANNER UI ── */
.qr-error-container {
  padding: 60px 20px;
  color: #ef4444;
}
.qr-error-icon {
  font-size: 3rem;
  margin-bottom: 15px;
}
.qr-error-title {
  font-size: 1.2rem;
}
.qr-error-subtitle {
  font-size: 0.9rem;
  color: #94a3b8;
}
.qr-staff-info-card {
  background: #f1f5f9;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  text-align: left;
}
.qr-staff-info-card.no-margin {
  margin-bottom: 0;
}
.qr-staff-label {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 4px;
}
.qr-staff-value {
  font-weight: 800;
  color: #1e293b;
  font-size: 1.1rem;
}
.qr-staff-value-small {
  font-weight: 800;
  color: #1e293b;
  font-size: 1rem;
}
.qr-staff-status-box {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 1rem;
}
.qr-btn-primary {
  width: 100%;
  margin-top: 15px;
  font-weight: bold;
  padding: 12px;
  background: #3b82f6;
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
}
.qr-not-found {
  text-align: center;
  padding: 20px;
  color: #ef4444;
  font-weight: bold;
}

