/* ==========================================
   RESPONSIVE MASTER - UNIVERSAL DEVICE SUPPORT
   ใช้ร่วมกับ style.css, safety-custom.css, reports.css ฯลฯ
   
   Breakpoints:
   - xs : < 360px   (มือถือเล็ก)
   - sm : 360-480px  (มือถือ)
   - md : 481-768px  (มือถือใหญ่/แท็บเล็ตแนวตั้ง)
   - lg : 769-1024px (แท็บเล็ตแนวนอน/โน้ตบุ๊กเล็ก)
   - xl : 1025-1440px (โน้ตบุ๊ก/เดสก์ท็อป)
   - 2xl: > 1440px   (จอใหญ่/4K)
   ========================================== */

/* ==========================================
   1. FLUID TYPOGRAPHY (ปรับขนาดตัวอักษรอัตโนมัติ)
   ========================================== */
html {
  font-size: clamp(16px, 1.2vw + 8px, 18px);
}

body {
  font-size: 1rem;
}

body {
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

h1 {
  font-size: clamp(1.25rem, 2.5vw + 0.5rem, 2.25rem);
}

h2 {
  font-size: clamp(1.1rem, 2vw + 0.4rem, 1.75rem);
}

h3 {
  font-size: clamp(1rem, 1.5vw + 0.3rem, 1.35rem);
}

/* ==========================================
   2. SAFE AREA (รองรับ Notch / Dynamic Island)
   ========================================== */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ==========================================
   3. TOUCH TARGET (ขนาดปุ่มกดสำหรับมือถือ)
   ========================================== */
@media (pointer: coarse) {

  .btn,
  button,
  .nav-btn,
  .tab,
  .tab-btn,
  .tab-btn-modern,
  .menu-item,
  .footer-btn,
  input[type="checkbox"],
  input[type="radio"] {
    min-height: 44px;
    min-width: 44px;
  }

  .menu-item {
    padding: 14px 20px;
  }

  .tab,
  .tab-btn {
    padding: 14px 20px;
  }

  a {
    padding: 2px 0;
  }
}

/* ==========================================
   4. CONTAINER FLUID
   ========================================== */
.container {
  width: 100%;
  max-width: 100%;
  padding-inline: clamp(12px, 3vw, 32px);
  margin-inline: auto;
  box-sizing: border-box;
}

/* ==========================================
   5. APP LAYOUT - SIDEBAR + MAIN
   ========================================== */

/* --- ค่าเริ่มต้น (Desktop) --- */
.app-container {
  display: flex;
  height: 100vh;
  height: 100dvh;
  /* Dynamic viewport height สำหรับมือถือ */
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width, 272px);
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.3s ease, transform 0.3s ease;
  z-index: 100;
}

.main-content {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.content-area {
  flex: 1;
  padding: clamp(16px, 3vw, 32px);
  overflow-y: auto;
}

/* ==========================================
   6. GRID SYSTEMS - RESPONSIVE
   ========================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: clamp(12px, 2vw, 24px);
  width: 100%;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: clamp(12px, 2vw, 24px);
  width: 100%;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: clamp(12px, 2vw, 24px);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: clamp(12px, 2vw, 20px);
}

.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 15px;
}

/* ==========================================
   7. CARDS - RESPONSIVE
   ========================================== */
.card,
.safety-card,
.stat-card {
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.kpi-card {
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
}

.card {
  padding: clamp(16px, 3vw, 32px);
  border-radius: clamp(10px, 2vw, 20px);
  margin-bottom: clamp(12px, 2vw, 24px);
}

.safety-card {
  padding: clamp(16px, 3vw, 30px);
  border-radius: clamp(12px, 2vw, 20px);
}

.stat-card {
  padding: clamp(16px, 2.5vw, 28px);
}

.kpi-card {
  padding: clamp(16px, 2.5vw, 28px);
}

/* ==========================================
   8. TABLES - RESPONSIVE
   ========================================== */
.overflow-auto,
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 600px;
  /* บังคับขนาดขั้นต่ำ ให้ scroll ได้ */
  border-collapse: collapse;
}

th,
td {
  padding: clamp(8px, 1.5vw, 16px);
  font-size: clamp(0.875rem, 1.2vw + 0.3rem, 1rem);
  white-space: nowrap;
}

/* ตารางบนมือถือ: แสดง scrollbar ให้เห็น */
@media (max-width: 768px) {
  .overflow-auto {
    border: 1px solid var(--gray-200, #e5e7eb);
    margin-bottom: 16px;
  }

  .overflow-auto::after {
    content: '← เลื่อนดูข้อมูล →';
    display: block;
    text-align: center;
    font-size: 0.875rem;
    color: var(--gray-400, #9ca3af);
    padding: 6px 0;
  }
}

/* ==========================================
   9. FORMS - RESPONSIVE
   ========================================== */
.form-group input,
.form-group select,
.form-group textarea,
.input-modern,
.search-box input,
.search-box select {
  width: 100%;
  box-sizing: border-box;
  font-size: max(16px, 0.95rem);
  /* ป้องกัน iOS zoom */
  padding: clamp(10px, 1.5vw, 14px) clamp(12px, 2vw, 16px);
}

.search-box {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(8px, 1.5vw, 12px);
}

.search-box input {
  flex: 1;
  min-width: min(100%, 200px);
}

/* ==========================================
   10. BUTTONS - RESPONSIVE
   ========================================== */
.btn,
.btn-premium,
.submit-btn,
.nav-btn {
  font-size: clamp(0.875rem, 1.2vw + 0.3rem, 1rem);
  padding: clamp(10px, 1.5vw, 14px) clamp(16px, 2.5vw, 28px);
  border-radius: clamp(8px, 1.5vw, 16px);
  box-sizing: border-box;
}

/* ==========================================
   11. TABS - RESPONSIVE
   ========================================== */
.tabs,
.tabs-modern,
.tab-container {
  display: flex;
  gap: clamp(4px, 1vw, 12px);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-wrap: nowrap;
}

.tabs::-webkit-scrollbar,
.tabs-modern::-webkit-scrollbar,
.tab-container::-webkit-scrollbar {
  display: none;
}

.tab,
.tab-btn,
.tab-btn-modern {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: clamp(0.875rem, 1.2vw + 0.3rem, 1rem);
}

/* ==========================================
   12. MODALS - RESPONSIVE
   ========================================== */
.modal-content {
  width: min(95vw, 600px);
  max-height: min(90vh, 90dvh);
  padding: clamp(20px, 4vw, 36px);
  border-radius: clamp(12px, 2vw, 24px);
  margin: auto;
  overflow-y: auto;
}

/* ==========================================
   13. CHARTS - RESPONSIVE
   ========================================== */
.chart-container {
  position: relative;
  width: 100%;
  height: clamp(200px, 40vw, 400px);
  min-height: 200px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-container-premium {
  padding: clamp(12px, 2vw, 20px);
}

/* ==========================================
   14. KPI VALUES - FLUID SIZE
   ========================================== */
.stat-value {
  font-size: clamp(1.5rem, 3vw + 0.5rem, 2.5rem);
}

.kpi-value {
  font-size: clamp(1.75rem, 4vw + 0.5rem, 3rem);
}

.stat-label,
.kpi-label {
  font-size: clamp(0.8125rem, 1vw + 0.3rem, 0.9375rem);
}

/* ==========================================
   15. WORKFLOW STEPS - RESPONSIVE
   ========================================== */
.workflow-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: clamp(10px, 2vw, 18px);
}

/* ==========================================
   BREAKPOINT: xs (< 360px) - มือถือเล็ก
   ========================================== */
@media (max-width: 359px) {
  .container {
    padding-inline: 8px;
  }

  .card,
  .safety-card {
    padding: 12px;
  }

  .header h1 {
    font-size: 1.1rem;
  }

  .header {
    padding: 16px 12px;
  }

  .kpi-icon-bg {
    display: none;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .nav {
    flex-direction: column;
  }

  .nav-btn {
    width: 100%;
    justify-content: center;
  }

  .btn-premium {
    font-size: 0.9rem;
    padding: 10px 16px;
  }

  .modal-content {
    padding: 16px;
    width: 98vw;
  }

  .equipment-chips {
    flex-direction: column;
  }

  .equipment-chip {
    width: 100%;
  }
}

/* ==========================================
   BREAKPOINT: sm (360-480px) - มือถือ
   ========================================== */
@media (min-width: 360px) and (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .nav {
    flex-direction: column;
  }

  .nav-btn {
    width: 100%;
    justify-content: center;
  }

  .tabs,
  .tabs-modern {
    flex-direction: column;
  }

  .tab,
  .tab-btn-modern {
    width: 100%;
    text-align: center;
  }

  .search-box {
    flex-direction: column;
  }

  .employee-checklist {
    max-height: 250px;
  }
}

/* ==========================================
   BREAKPOINT: md (481-768px) - มือถือใหญ่/แท็บเล็ตแนวตั้ง
   ========================================== */
@media (min-width: 481px) and (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .nav {
    flex-wrap: wrap;
  }

  .nav-btn {
    flex: 1 1 calc(50% - 8px);
  }

  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .employee-checklist {
    max-height: 350px;
  }
}

/* ==========================================
   HAMBURGER SIDEBAR (ทุกขนาดหน้าจอ)
   body.sidebar-hamburger-mode ถูกใส่โดย sidebar.js
   ========================================== */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: max(14px, env(safe-area-inset-top, 14px));
  left: max(14px, env(safe-area-inset-left, 14px));
  width: 42px;
  height: 42px;
  z-index: 2200;
  border: 1px solid rgba(58, 90, 64, 0.18);
  border-radius: 12px;
  background: var(--ds-surface, #ffffff);
  color: var(--primary-green, #3a5a40);
  font-size: 1.15rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(26, 46, 34, 0.12);
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.mobile-nav-toggle:hover {
  background: var(--green-50, #f0f7f4);
  color: var(--primary-green-dark, #2c4c3b);
  box-shadow: 0 4px 14px rgba(26, 46, 34, 0.16);
}

.mobile-nav-toggle:active {
  transform: scale(0.96);
}

.mobile-nav-toggle[hidden] {
  display: none !important;
}

.mobile-nav-toggle.is-open {
  display: none !important;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  /* Subtle scrim so it reads as "background inactive". No backdrop-filter — keep it cheap. */
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  z-index: 1900;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.sidebar-overlay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Drawer must sit above the click-catcher overlay */
body.sidebar-hamburger-mode .sidebar,
body.sidebar-hamburger-mode .app-container .sidebar,
body.sidebar-menu-open .sidebar {
  z-index: 2000 !important;
}

body.sidebar-menu-open {
  overflow: hidden;
}

/* Drawer layout — desktop + tablet + mobile */
body.sidebar-hamburger-mode .app-container {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
}

body.sidebar-hamburger-mode .sidebar,
body.sidebar-hamburger-mode .app-container .sidebar {
  position: fixed !important;
  top: 0;
  left: calc(-1 * min(88vw, var(--sidebar-width, 280px))) !important;
  width: min(88vw, var(--sidebar-width, 280px)) !important;
  min-width: 0 !important;
  max-width: 320px;
  height: 100% !important;
  height: 100dvh !important;
  transform: none !important;
  z-index: 2000;
  flex-shrink: 0;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: none;
}

body.sidebar-hamburger-mode .sidebar.mobile-open,
body.sidebar-hamburger-mode .app-container .sidebar.mobile-open {
  left: 0 !important;
  transform: none !important;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.35);
}

body.sidebar-hamburger-mode .sidebar.collapsed,
body.sidebar-hamburger-mode .app-container .sidebar.collapsed {
  width: min(88vw, var(--sidebar-width, 280px)) !important;
  min-width: 0 !important;
  left: calc(-1 * min(88vw, var(--sidebar-width, 280px))) !important;
  padding: 0;
}

body.sidebar-hamburger-mode .sidebar.collapsed.mobile-open,
body.sidebar-hamburger-mode .app-container .sidebar.collapsed.mobile-open {
  left: 0 !important;
}

/* Show labels even if a stale collapsed class remains */
body.sidebar-hamburger-mode .sidebar.collapsed .logo-text,
body.sidebar-hamburger-mode .sidebar.collapsed .logo-subtitle,
body.sidebar-hamburger-mode .sidebar.collapsed .menu-item span:not(.menu-icon),
body.sidebar-hamburger-mode .sidebar.collapsed .menu-section-title,
body.sidebar-hamburger-mode .sidebar.collapsed .user-info-name,
body.sidebar-hamburger-mode .sidebar.collapsed .user-info-role,
body.sidebar-hamburger-mode .sidebar.collapsed .footer-btn-text {
  opacity: 1 !important;
  width: auto !important;
  height: auto !important;
  overflow: visible !important;
  position: static !important;
}

body.sidebar-hamburger-mode .mobile-nav-toggle {
  display: flex;
}

body.sidebar-menu-open .mobile-nav-toggle {
  display: none !important;
}

/* Close button lives in the drawer header (not floating on the page) */
body.sidebar-hamburger-mode .sidebar .sidebar-toggle-btn,
body.sidebar-hamburger-mode .sidebar .sidebar-close-btn {
  display: none !important;
}

body.sidebar-hamburger-mode .sidebar.mobile-open .sidebar-toggle-btn,
body.sidebar-hamburger-mode .sidebar.mobile-open .sidebar-close-btn {
  display: inline-flex !important;
  position: absolute;
  top: 14px;
  right: 14px;
  left: auto;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: none;
  transform: none;
  z-index: 5;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

body.sidebar-hamburger-mode .sidebar.mobile-open .sidebar-toggle-btn:hover,
body.sidebar-hamburger-mode .sidebar.mobile-open .sidebar-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.28);
  transform: none;
}

body.sidebar-hamburger-mode .sidebar.mobile-open .sidebar-toggle-btn:active,
body.sidebar-hamburger-mode .sidebar.mobile-open .sidebar-close-btn:active {
  transform: scale(0.96);
}

body.sidebar-hamburger-mode .sidebar-header,
body.sidebar-hamburger-mode .sidebar-header--with-close {
  position: relative;
  padding-right: 56px;
}

body.sidebar-hamburger-mode .sidebar .sidebar-close-icon {
  font-size: 0.95rem;
  line-height: 1;
  font-weight: 600;
}

body.sidebar-hamburger-mode .main-content {
  width: 100% !important;
  min-width: 0 !important;
  margin-left: 0 !important;
  flex: none;
}

body.sidebar-hamburger-mode .top-bar {
  padding-left: 60px;
}

/* Pages that use .page-header (no .top-bar) must also clear the fixed hamburger
   button. On mobile the .main-content padding-top:56px already does this; on
   desktop/tablet it was missing, so the button overlapped the page title.
   Push the header down (not right) to keep the title aligned with the content
   below it. */
@media (min-width: 769px) {
  body.sidebar-hamburger-mode .main-content > .page-header {
    padding-top: 40px;
  }
}

/* ==========================================
   BREAKPOINT: < 768px - MOBILE SIDEBAR
   ========================================== */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
    width: 100% !important;
    min-width: 0 !important;
    height: 100vh;
    height: 100dvh;
  }

  .sidebar {
    position: fixed !important;
    top: 0;
    left: -280px !important;
    width: min(85vw, 280px) !important;
    min-width: 0 !important;
    height: 100% !important;
    height: 100dvh !important;
    transform: none !important;
    z-index: 2000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.mobile-open {
    left: 0 !important;
    transform: none !important;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.4);
  }

  .sidebar.collapsed {
    width: min(85vw, 280px) !important;
    left: -280px !important;
    transform: none !important;
  }

  .app-container .sidebar {
    transform: none !important;
  }

  .app-container .sidebar.mobile-open {
    transform: none !important;
    left: 0 !important;
  }

  body:not(.sidebar-hamburger-mode) .sidebar .sidebar-toggle-btn {
    display: none !important;
  }

  .mobile-nav-toggle {
    display: flex;
  }

  .main-content {
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    flex: 1 1 auto !important;
    margin-left: 0 !important;
    padding-top: 56px;
    display: flex !important;
    flex-direction: column !important;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.sidebar-hamburger-mode .main-content {
    padding-top: 56px;
  }

  .content-area {
    padding: clamp(12px, 3vw, 20px);
  }

  .top-bar {
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 12px 16px 12px 60px;
    align-items: flex-start;
  }

  .top-bar__meta {
    width: 100%;
    font-size: 0.875rem;
  }

  .period-selector,
  .page-header {
    flex-direction: column;
    align-items: stretch !important;
  }

  .period-selector .btn-premium,
  .period-selector select,
  .period-selector button {
    width: 100%;
    max-width: none;
  }

  .form-section.active {
    display: block !important;
  }

  .card:hover,
  .stat-card:hover,
  .kpi-card:hover,
  .safety-card:hover {
    transform: none;
  }
}

/* ==========================================
   BREAKPOINT: lg (769-1024px) - แท็บเล็ตแนวนอน
   ========================================== */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar {
    width: 220px;
  }

  .sidebar.collapsed {
    width: 70px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .content-area {
    padding: 20px;
  }

  .nav-btn {
    padding: 10px 18px;
    font-size: 0.85rem;
  }
}

/* ==========================================
   BREAKPOINT: xl (1025-1440px) - โน้ตบุ๊ก/เดสก์ท็อป
   ========================================== */
@media (min-width: 1025px) and (max-width: 1440px) {
  .sidebar {
    width: 260px;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .chart-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .container {
    max-width: 95%;
  }
}

/* ==========================================
   BREAKPOINT: 2xl (> 1440px) - จอใหญ่/4K
   ========================================== */
@media (min-width: 1441px) {
  .container {
    max-width: 95%;
    margin-inline: auto;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 28px;
  }

  .chart-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 28px;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 28px;
  }

  .card {
    padding: 36px;
  }

  .content-area {
    padding: 32px 40px;
  }

  .chart-container {
    height: 450px;
  }
}

/* ==========================================
   16. IMAGES & MEDIA - RESPONSIVE
   ========================================== */
img,
video,
canvas,
svg {
  max-width: 100%;
  height: auto;
}

.logo-img {
  width: clamp(32px, 5vw, 44px);
  height: clamp(32px, 5vw, 44px);
}

/* ==========================================
   17. PRINT STYLES
   ========================================== */
@media print {

  .sidebar,
  .sidebar-toggle-btn,
  .mobile-nav-toggle,
  .sidebar-overlay,
  .top-bar,
  .btn,
  button,
  .nav,
  .footer-btn,
  .toast-container,
  .modal {
    display: none !important;
  }

  .app-container {
    display: block;
    height: auto;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
    height: auto;
    overflow: visible;
  }

  .card {
    box-shadow: none;
    border: 1px solid var(--site-border, #ddd);
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body {
    background: var(--ds-surface, #ffffff);
    font-size: 12pt;
  }

  table {
    min-width: 0;
    font-size: 10pt;
  }
}

/* ==========================================
   18. ACCESSIBILITY - REDUCED MOTION
   ========================================== */
@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;
  }

  .card:hover,
  .stat-card:hover,
  .kpi-card:hover,
  .btn:hover,
  .menu-item:hover {
    transform: none !important;
  }
}

/* ==========================================
   19. DARK MODE RESPONSIVE FIXES
   ========================================== */
@media (prefers-color-scheme: dark) {
  .overflow-auto::after {
    color: var(--gray-500, #6b7280);
  }
}

/* ==========================================
   20. LANDSCAPE MOBILE FIX
   ========================================== */
@media (max-height: 500px) and (orientation: landscape) {
  .sidebar {
    height: 100vh;
    height: 100dvh;
  }

  .modal-content {
    max-height: 85vh;
    max-height: 85dvh;
  }

  .employee-checklist {
    max-height: 200px;
  }

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

/* ==========================================
   21. HIGH DPI / RETINA DISPLAY
   ========================================== */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

  .card,
  .safety-card,
  .stat-card {
    border-width: 0.5px;
  }
}

/* ==========================================
   22. SCROLLBAR - UNIVERSAL
   ========================================== */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300, #d1d5db) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300, #d1d5db);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-green, #3a5a40);
  background-clip: padding-box;
}

/* มือถือ: ซ่อน scrollbar แต่ยัง scroll ได้ */
@media (max-width: 768px) {

  .tabs::-webkit-scrollbar,
  .tabs-modern::-webkit-scrollbar,
  .sidebar-menu::-webkit-scrollbar {
    display: none;
  }
}

/* ==========================================
   19. TYPOGRAPHY ACCESSIBILITY — ขนาดตัวอักษรขั้นต่ำที่อ่านได้
   ========================================== */
.badge,
.tag,
.stat-label,
.kpi-label,
.rf-kpi-label,
.menu-section-title,
.filter-grid label,
.date-filter label,
.form-group label,
small,
caption {
  font-size: max(0.8125rem, 13px);
}

table th,
table td,
.btn-sm,
.tab,
.tab-btn,
.tab-btn-modern {
  font-size: max(0.875rem, 14px);
}

input,
select,
textarea,
.form-group input,
.form-group select,
.form-group textarea {
  font-size: max(1rem, 16px);
}