@import url('https://fonts.googleapis.com/css2?family=Kanit:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Kodchasan:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;1,200;1,300;1,400;1,500;1,600;1,700&family=Mali:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;1,200;1,300;1,400;1,500;1,600;1,700&display=swap');

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Kanit', 'Kodchasan', 'Mali', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important; 
    background: #f5f4f0; 
    color: #1a1a1a; 
    font-size: 14px;
    /* ✅ ป้องกันการเลื่อนของ body */
    overflow: auto;
    height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.main {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

/* TOP NAV */
.topnav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  flex-shrink: 0;
  z-index: 1000;
  position: sticky;
  top: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Topbar ใน .main ก็ติดด้วย */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
}

.topnav-logo {
  font-size: 14px;
  font-weight: 600;
  color: var(--green-dark);
  padding-right: 20px;
  border-right: 1px solid var(--border);
  margin-right: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.topnav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.logo { 
    padding: 0 16px 20px; 
    border-bottom: 0.5px solid rgba(0,0,0,0.12); 
    margin-bottom: 8px;
    flex-shrink: 0; /* ป้องกันการหด */
}

.logo-title { 
    font-size: 13px; 
    font-weight: 500; 
    color: #1a1a1a; 
    line-height: 1.4; 
}

.logo-sub { 
    font-size: 11px; 
    color: #666; 
    margin-top: 2px; 
}

.nav-link {
  padding: 6px 14px;
  font-size: 14px;
  color: #666;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: 'Kanit', sans-serif !important;
  text-decoration: none;
}

.nav-link:hover { background: var(--bg); color: var(--text); }

.nav-link.active {
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 500;
}

/* ========== Dropdown Styles ========== */
.nav-dropdown {
  position: relative;
  display: inline-block; /* ✅ สำคัญ: ให้ dropdown อยู่บรรทัดเดียวกับเมนูอื่น */
}

.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}

.nav-dropdown-toggle .arrow {
  font-size: 9px;
  transition: transform 0.2s;
  color: #999;
}

.nav-dropdown-toggle.active .arrow {
  transform: rotate(180deg);
}

.nav-submenu {
  position: absolute;
  top: 100%;
  left: 0;
  list-style: none;
  padding: 4px 0;
  margin: 4px 0 0 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 180px;
  z-index: 1001;
  
  /* Animation */
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  opacity: 0;
}

.nav-submenu.show {
  max-height: 300px;
  opacity: 1;
}

.nav-submenu li a {
  display: block;
  padding: 8px 16px;
  font-size: 12px;
  color: #555;
  text-decoration: none;
  transition: background 0.15s;
  white-space: nowrap;
}

.nav-submenu li a:hover {
  background: var(--green-light);
  color: var(--green-dark);
}

.nav-submenu li a.active {
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 500;
}

/* เพิ่มใน style.css */
.topnav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

#auth-logged-out button:hover {
  border-color: var(--green);
  color: var(--green);
}

/* ลบ .sidebar และ properties เดิมทิ้ง */
.sidebar { display: none; }


.nav-item { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    padding: 8px 16px; 
    font-size: 13px; 
    cursor: pointer; 
    color: #666; 
    transition: background 0.15s;
    flex-shrink: 0;
}

.nav-item:hover { 
    background: #fff; 
    color: #1a1a1a; 
}

.nav-item.active { 
    background: #fff; 
    color: #1a1a1a; 
    font-weight: 500; 
    border-left: 2px solid #1D9E75; 
}

.nav-icon { 
    width: 14px; 
    height: 14px; 
    border-radius: 3px; 
    flex-shrink: 0; 
}

.nav-section { 
    font-size: 10px; 
    color: #aaa; 
    padding: 12px 16px 4px; 
    text-transform: uppercase; 
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

/* ========== Sidebar Footer - อยู่ล่างสุด ========== */
.sidebar-footer {
    /* ✅ ดันให้ลงล่างสุดของ sidebar */
    margin-top: auto;
    padding: 12px 16px;
    border-top: 0.5px solid rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
}

.login-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: white;
    border: 0.5px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    color: #1a1a1a;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.login-btn:hover {
    background: #f5f4f0;
    border-color: #1D9E75;
    color: #1D9E75;
}

.login-btn svg {
    flex-shrink: 0;
}

 /* Hover effect สำหรับปุ่ม + */
#floating-add-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(29,158,117,0.6);
}
    
#floating-add-btn:active {
    transform: scale(0.95);
}
    
/* Animation เมื่อแสดงปุ่ม */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
    
#floating-add-btn.show {
    animation: fadeInUp 0.3s ease forwards;
}

/* ========== Main Content - เลื่อนได้ ========== */
.main {
  flex: 1;
  background: var(--bg);
  width: 100%;
}

/* ========== Pages ========== */
.page { 
    display: none; 
}

.page.active { 
    display: block; 
}

.page-title { 
    font-size: 18px; 
    font-weight: 500; 
    color: #1a1a1a; 
    margin-bottom: 4px; 
}

.page-sub { 
    font-size: 13px; 
    color: #666; 
    margin-bottom: 20px; 
}

/* ========== KPI Grid ========== */
.kpi-grid { 
    display: grid; 
    grid-template-columns: repeat(4, minmax(0,1fr)); 
    gap: 12px; 
    margin-bottom: 20px; 
}

.kpi-card { 
    background: #fff; 
    border: 0.5px solid rgba(0,0,0,0.1); 
    border-radius: 12px; 
    padding: 14px 16px; 
}

.kpi-label { 
    font-size: 11px; 
    color: #666; 
    margin-bottom: 6px; 
}

.kpi-value { 
    font-size: 26px; 
    font-weight: 500; 
    color: #1a1a1a; 
    line-height: 1; 
}

.kpi-unit { 
    font-size: 12px; 
    color: #888; 
    margin-top: 4px; 
}

.kpi-badge { 
    display: inline-block; 
    font-size: 10px; 
    padding: 2px 6px; 
    border-radius: 4px; 
    margin-top: 6px; 
}

.badge-green { 
    background: #EAF3DE; 
    color: #3B6D11; 
}

.badge-amber { 
    background: #FAEEDA; 
    color: #854F0B; 
}

/* ========== Layout Rows ========== */
.row { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 16px; 
    margin-bottom: 16px; 
}

.row-3 { 
    display: grid; 
    grid-template-columns: 2fr 1fr; 
    gap: 16px; 
    margin-bottom: 16px; 
}

/* ========== Cards ========== */
.card { 
    background: #fff; 
    border: 0.5px solid rgba(0,0,0,0.1); 
    border-radius: 12px; 
    padding: 16px; 
}

.card-title { 
    font-size: 13px; 
    font-weight: 500; 
    color: #1a1a1a; 
    margin-bottom: 12px; 
}

/* ========== Map ========== */
.map-placeholder { 
    background: #efefeb; 
    border-radius: 8px; 
    position: relative; 
    overflow: hidden; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

/* ปุ่มล้าง filter ในแผนที่ */
#mf-reset-btn {
  background: #666 !important;
  transition: background 0.2s;
}

#mf-reset-btn:hover {
  background: #444 !important;
}

#mf-reset-btn:active {
  background: #333 !important;
}

/* Modal Search Input */
#modal-search {
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input-long {
  flex: 3 !important;
  min-width: 280px !important;
  max-width: 400px !important;
}

#modal-search:focus {
  outline: none;
  border-color: #1D9E75;
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.15);
}

#modal-search-clear {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

#modal-search-clear:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #1a1a1a;
}

/* Highlight matched text (ถ้าต้องการพัฒนาต่อ) */
.search-highlight {
  background: #FFF4E6;
  color: #854F0B;
  padding: 0 2px;
  border-radius: 2px;
}

/* ========== Bars ========== */
.bar-row { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    margin-bottom: 8px; 
}

.bar-label { 
    font-size: 12px; 
    color: #666; 
    width: 70px; 
    flex-shrink: 0; 
    text-align: right; 
}

.bar-track { 
    flex: 1; 
    height: 8px; 
    background: #efefeb; 
    border-radius: 4px; 
    overflow: hidden; 
}

.bar-fill { 
    height: 100%; 
    border-radius: 4px; 
}

.bar-val { 
    font-size: 11px; 
    color: #888; 
    width: 30px; 
}

/* ── Topic Bars (Overview) ── */
.topic-bar-row {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.topic-bar-label {
  font-size: 12px;
  color: #444;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

.topic-bar-track {
  height: 8px;
  background: #efefeb;
  border-radius: 4px;
  overflow: hidden;
  min-width: 0;
}

.topic-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.topic-bar-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  min-width: 52px;
}

.topic-bar-pct {
  font-size: 12px;
  font-weight: 500;
  color: #1a1a1a;
  line-height: 1;
}

.topic-bar-count {
  font-size: 10px;
  color: #aaa;
  line-height: 1;
}

/* ── Topic Bars (responsive) ── */
#topic-bars-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topic-bar-item {
  display: grid;
  grid-template-columns: 130px 1fr 38px 36px;
  align-items: center;
  gap: 8px;
}

.topic-bar-label {
  font-size: 12px;
  color: #555;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-bar-track {
  height: 8px;
  background: #efefeb;
  border-radius: 4px;
  overflow: hidden;
}

.topic-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.topic-bar-val {
  font-size: 12px;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.topic-bar-count {
  font-size: 10px;
  color: #bbb;
  white-space: nowrap;
}

/* Responsive: จอเล็ก */
@media (max-width: 600px) {
  .topic-bar-item {
    grid-template-columns: 100px 1fr 36px 30px;
    gap: 6px;
  }

  .topic-bar-label {
    font-size: 11px;
  }

  .topic-bar-val {
    font-size: 11px;
  }
}

/* Responsive */
@media (max-width: 600px) {
  .topic-bar-row {
    grid-template-columns: 100px 1fr auto;
    gap: 8px;
  }

  .topic-bar-label {
    font-size: 11px;
  }
}

/* Dropdown Title */
#cf-title {
  background: white;
  border: 0.5px solid rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  color: #1a1a1a;
  cursor: pointer;
  transition: border-color 0.15s;
}

#cf-title:hover {
  border-color: #1D9E75;
}

#cf-title:focus {
  outline: none;
  border-color: #1D9E75;
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.15);
}

/* ========== Trend Chart ========== */
.trend-row { 
    display: flex; 
    align-items: flex-end; 
    gap: 6px; 
    height: 80px; 
    margin-bottom: 8px; 
}

.trend-bar { 
    flex: 1; 
    border-radius: 3px 3px 0 0; 
    background: #1D9E75; 
    opacity: 0.7; 
    cursor: pointer; 
}

.trend-bar:hover { 
    opacity: 1; 
}

.trend-labels { 
    display: flex; 
    gap: 6px; 
}

.trend-lbl { 
    flex: 1; 
    text-align: center; 
    font-size: 10px; 
    color: #aaa; 
}

/* ========== Tables ========== */
table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 12px; 
}

th { 
    font-weight: 500; 
    color: #666; 
    text-align: left; 
    padding: 6px 8px; 
    border-bottom: 0.5px solid rgba(0,0,0,0.1); 
}

td { 
    padding: 7px 8px; 
    border-bottom: 0.5px solid rgba(0,0,0,0.08); 
    color: #1a1a1a; 
}

/* ========== Table Column Styles ========== */

/* คอลัมน์ประเด็นหลัก (Title) */
.td-title {
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  padding: 8px 12px;
}

/* Badge สำหรับประเด็นหลัก */
.title-badge {
  display: inline-block;
  padding: 4px 10px;
  background: linear-gradient(135deg, #E1F5EE 0%, #D4F1E7 100%);
  color: #1D9E75;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  border: 0.5px solid rgba(29, 158, 117, 0.2);
  transition: all 0.15s ease;
}

.title-badge:hover {
  background: linear-gradient(135deg, #D4F1E7 0%, #C7EBDE 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(29, 158, 117, 0.2);
}

/* คอลัมน์ปี */
.td-year {
  text-align: center;
  font-weight: 500;
  color: #666;
  padding: 8px 12px;
}

/* ========== Button Styles ========== */

/* ปุ่มดู */
.btn-view {
  padding: 6px 14px;
  background: linear-gradient(135deg, #378ADD 0%, #2E6DB8 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(55, 138, 221, 0.2);
  white-space: nowrap;
}

.btn-view:hover {
  background: linear-gradient(135deg, #2E6DB8 0%, #255A99 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(55, 138, 221, 0.3);
}

.btn-view:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(55, 138, 221, 0.2);
}

/* ปุ่ม PDF */
.btn-pdf {
  padding: 5px 10px;
  background: white;
  color: #185FA5;
  border: 0.5px solid #185FA5;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-pdf:hover {
  background: #E6F1FB;
  border-color: #0F4D8A;
  color: #0F4D8A;
}

/* ── Map ── */
#leaflet-map, #public-leaflet-map { 
    height:360px; 
    width:100%; 
    background:#efefeb; 
}

#map-wrapper { 
    border-radius:0 0 8px 8px; 
    overflow:hidden; 
}

/* ── Map filter bar ── */
.map-filter-bar {
    display:flex; 
    gap:8px; 
    flex-wrap:wrap;
    padding:10px 16px; 
    border-bottom:0.5px solid rgba(0,0,0,0.08); 
    background:#fafaf8;
}
    
.map-filter-bar select {
    font-size:12px; 
    padding:5px 8px;
    border:0.5px solid rgba(0,0,0,0.18); 
    border-radius:6px;
    background:white; 
    color:#1a1a1a; 
    flex:1; 
    min-width:110px;
}

/* ── Search / filter bar ── */
.filter-bar {
    display:flex; 
    gap:8px; 
    flex-wrap:wrap; 
    margin-bottom:12px;
}
    
.filter-bar input, .filter-bar select {
    font-size:13px; 
    padding:7px 10px;
    border:0.5px solid rgba(0,0,0,0.2); 
    border-radius:8px;
    background:white; 
    color:#1a1a1a;
}
    
.filter-bar input  { 
    flex:2; 
    min-width:160px; 
}

.filter-bar select { 
    flex:1; 
    min-width:110px; 
}

.filter-bar button {
    padding:7px 16px; 
    border:none; 
    border-radius:8px;
    background:#1D9E75; 
    color:white; 
    font-size:13px; 
    cursor:pointer; 
    white-space:nowrap;
}

.filter-bar button:hover { 
    background:#0F6E56; 
}

/* ── Table helpers ── */
.td-center { 
    text-align:center; 
    padding:24px; 
}
    
.td-name   { 
    font-weight:500; 
    font-size:13px; 
    max-width:200px; 
}

 /* ── Charter image thumb ── */
.charter-thumb {
    width:44px; 
    height:44px; 
    object-fit:cover; 
    border-radius:5px;
    border:0.5px solid rgba(0,0,0,0.1); 
    cursor:zoom-in; 
    display:block;
}
    
.charter-thumb-empty {
    width:44px; 
    height:44px; 
    border-radius:5px;
    background:#f0f0ec; 
    border:0.5px solid rgba(0,0,0,0.08);
    font-size:9px; 
    color:#bbb; 
    display:flex;
    align-items:center;
    justify-content:center; 
    text-align:center;
}

/* ── PDF button ── */
.btn-pdf {
    font-size:11px; 
    color:#185FA5; 
    border:0.5px solid #185FA5;
    border-radius:4px; 
    padding:3px 9px; 
    text-decoration:none;
    display:inline-block; 
    white-space:nowrap;
}

.btn-pdf.disabled { 
    color:#bbb; 
    border-color:#ddd; 
    cursor:default; 
}

/* ── Pager ── */
.pager-wrap { 
    display:flex; 
    align-items:center; 
    gap:10px; 
    margin-top:10px; 
}

.pager-btn  {
    padding:5px 14px; 
    border:0.5px solid rgba(0,0,0,0.2); 
    border-radius:6px;
    background:white; 
    color:#444; 
    font-size:12px; 
    cursor:pointer;
}

.pager-btn:disabled { 
    color:#ccc; 
    cursor:default; 
}

.pager-info { 
    font-size:12px; 
    color:#888; 
}

/* ── Public hero ── */
.public-hero {
    background:linear-gradient(135deg,#0F6E56 0%,#1D9E75 100%);
    border-radius:12px; 
    padding:28px 24px; 
    margin-bottom:16px; 
    color:white;
}

.public-hero h2 { 
    font-size:20px; 
    font-weight:500; 
    margin-bottom:6px; 
    color:white; 
}

.public-hero p  { 
    font-size:13px; 
    opacity:0.85; 
}

/* ── Sidebar footer ── */
.sidebar-footer { 
    margin-top:auto; 
    padding:12px 16px 16px; 
}

/* ========== Title Badge Styles ========== */
.title-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  transition: all 0.15s ease;
  cursor: default;
}

.title-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}


.title-badge[data-type="elderly"] {
  background: #E1F5EE;
  color: #1D9E75;
}

.title-badge[data-type="child"] {
  background: #E6F1FB;
  color: #378ADD;
}

.title-badge[data-type="mental"] {
  background: #FBEAF0;
  color: #D4537E;
}

.title-badge[data-type="endoflife"] {
  background: #FFF4E6;
  color: #EF9F27;
}

.title-badge[data-type="ltc"] {
  background: #E8F4FD;
  color: #5DCAA5;
}

.title-badge[data-type="other"] {
  background: #F5F5F3;
  color: #666;
}

tr:last-child td { 
    border-bottom: none; 
}

tr:hover td { 
    background: #f8f8f5; 
}

/* ========== Tags & Badges ========== */
.tag { 
    display: inline-block; 
    font-size: 10px; 
    padding: 2px 6px; 
    border-radius: 3px; 
}

.tag-green { 
    background: #EAF3DE; 
    color: #3B6D11; 
}

.tag-amber { 
    background: #FAEEDA; 
    color: #854F0B; 
}

.tag-gray { 
    background: #efefeb; 
    color: #666; 
}

.check { 
    color: #1D9E75; 
    font-size: 14px; 
}

.cross { 
    color: #E24B4A; 
    font-size: 14px; 
}

/* ========== Pills ========== */
.pill { 
    font-size: 10px; 
    padding: 2px 8px; 
    border-radius: 10px; 
    background: #FCEBEB; 
    color: #A32D2D; 
}

.pill-warn { 
    font-size: 10px; 
    padding: 2px 8px; 
    border-radius: 10px; 
    background: #FAEEDA; 
    color: #854F0B; 
}

/* ========== Public Page ========== */
.public-hero { 
    background: linear-gradient(135deg, #0F6E56 0%, #1D9E75 100%); 
    border-radius: 12px; 
    padding: 28px 24px; 
    margin-bottom: 16px; 
    color: white; 
}

.public-hero h2 { 
    font-size: 20px; 
    font-weight: 500; 
    margin-bottom: 6px; 
    color: white; 
}

.public-hero p { 
    font-size: 13px; 
    opacity: 0.85; 
}

.public-btn { 
    display: inline-block; 
    margin-top: 14px; 
    background: white; 
    color: #0F6E56; 
    font-size: 13px; 
    font-weight: 500; 
    padding: 8px 18px; 
    border-radius: 8px; 
    cursor: pointer; 
}

.info-cards { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 12px; 
    margin-bottom: 16px; 
}

.info-card { 
    background: #fff; 
    border: 0.5px solid rgba(0,0,0,0.1); 
    border-radius: 12px; 
    padding: 16px; 
}

.info-card h4 { 
    font-size: 13px; 
    font-weight: 500; 
    color: #1a1a1a; 
    margin-bottom: 4px; 
}

.info-card p { 
    font-size: 12px; 
    color: #666; 
    line-height: 1.5; 
}

/* ========== Search Bar ========== */
.search-bar { 
    display: flex; 
    gap: 8px; 
    margin-bottom: 16px; 
    flex-wrap: wrap;
}

.search-bar select { 
    font-size: 13px; 
    padding: 7px 10px; 
    border: 0.5px solid rgba(0,0,0,0.2); 
    border-radius: 8px; 
    background: #fff; 
    color: #1a1a1a; 
    flex: 1;
    min-width: 120px;
}

/* ปุ่มล้างการคัดกรอง */
#cf-reset-btn, #lw-reset-btn {
  background: #666 !important;
}

#cf-reset-btn:hover, #lw-reset-btn:hover {
  background: #444 !important;
}

/* Loading indicator */
.search-loading {
  position: relative;
}

.search-loading::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid #1D9E75;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

.open-btn { 
    font-size: 11px; 
    color: #1D9E75; 
    cursor: pointer; 
    border: 0.5px solid #1D9E75; 
    border-radius: 4px; 
    padding: 2px 8px; 
}

/* ========== Gap Analysis ========== */
.gap-card-inner { 
    background: #f5f4f0; 
    border-radius: 8px; 
    padding: 12px; 
    margin-bottom: 10px; 
}

.gap-card-inner:last-child { 
    margin-bottom: 0; 
}

/* Modal Animation */
@keyframes modalSlideIn {
    from { 
        opacity: 0; 
        transform: scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}
  
/* Toast Animations */
@keyframes slideIn {
    from { 
        transform: translateX(120%); 
        opacity: 0; 
    }
    to { 
        transform: translateX(0); 
        opacity: 1; 
    }
}
  
@keyframes slideOut {
    from { 
        transform: translateX(0); 
        opacity: 1; 
    }
    to { 
        transform: translateX(120%); 
        opacity: 0; 
    }
}
  
#toast-notification.hide {
    animation: slideOut 0.3s ease forwards;
}
  
/* ปิด modal เมื่อคลิกพื้นหลัง */
#confirm-modal {
    cursor: pointer;
}

#confirm-modal > div {
    cursor: default;
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .row-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 200px;
        position: static;
        overflow-x: auto;
        overflow-y: hidden;
        flex-shrink: 0;
        border-right: none;
        border-bottom: 0.5px solid rgba(0,0,0,0.12);
    }
    
    .sidebar-footer {
        position: static;
        border-top: 0.5px solid rgba(0, 0, 0, 0.12);
        border-right: none;
        margin-top: 0;
    }
    
    .main {
        height: calc(100vh - 200px);
    }
    
    .info-cards {
        grid-template-columns: 1fr;
    }
    
    .search-bar {
        flex-direction: column;
    }
    
    .search-bar select,
    .search-bar button {
        width: 100%;
    }
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important; 
    background: #f5f4f0; 
    color: #1a1a1a; 
    font-size: 14px;
    /* ✅ ป้องกันการเลื่อนของ body */
    overflow: hidden;
    height: 100vh;
}

/* ========== Layout หลัก ========== */
.app { 
    display: flex; 
    /* ✅ ใช้ความสูงเต็มหน้าจอ */
    height: 100vh;
    min-height: 100vh;
    /* ✅ ป้องกันการเลื่อนซ้อน */
    overflow: hidden;
}

/* ========== Sidebar - อยู่คงที่ ========== */
.sidebar { 
    width: 200px; 
    min-width: 200px; 
    background: #efefeb; 
    border-right: 0.5px solid rgba(0,0,0,0.12); 
    padding: 16px 0;
    
    /* ✅ ทำให้ sidebar อยู่คงที่ */
    position: sticky;
    top: 0;
    left: 0;
    height: 100vh;
    
    /* ✅ ถ้าเมนูยาวให้เลื่อนเฉพาะใน sidebar */
    overflow-y: auto;
    overflow-x: hidden;
    
    /* ✅ จัดเรียงแนวตั้ง */
    display: flex;
    flex-direction: column;
    
    /* ✅ ซ่อนแถบเลื่อนแต่ยังเลื่อนได้ */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.sidebar::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.logo { 
    padding: 0 16px 20px; 
    border-bottom: 0.5px solid rgba(0,0,0,0.12); 
    margin-bottom: 8px;
    flex-shrink: 0; /* ป้องกันการหด */
}

.logo-title { 
    font-size: 13px; 
    font-weight: 500; 
    color: #1a1a1a; 
    line-height: 1.4; 
}

.logo-sub { 
    font-size: 11px; 
    color: #666; 
    margin-top: 2px; 
}

.nav-item { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    padding: 8px 16px; 
    font-size: 13px; 
    cursor: pointer; 
    color: #666; 
    transition: background 0.15s;
    flex-shrink: 0;
}

.nav-item:hover { 
    background: #fff; 
    color: #1a1a1a; 
}

.nav-item.active { 
    background: #fff; 
    color: #1a1a1a; 
    font-weight: 500; 
    border-left: 2px solid #1D9E75; 
}

.nav-icon { 
    width: 14px; 
    height: 14px; 
    border-radius: 3px; 
    flex-shrink: 0; 
}

.nav-section { 
    font-size: 10px; 
    color: #aaa; 
    padding: 12px 16px 4px; 
    text-transform: uppercase; 
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

/* ========== Sidebar Footer - อยู่ล่างสุด ========== */
.sidebar-footer {
    /* ✅ ดันให้ลงล่างสุดของ sidebar */
    margin-top: auto;
    padding: 12px 16px;
    border-top: 0.5px solid rgba(0, 0, 0, 0.12);
    background: #efefeb;
    flex-shrink: 0;
}

.login-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: white;
    border: 0.5px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    color: #1a1a1a;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.login-btn:hover {
    background: #f5f4f0;
    border-color: #1D9E75;
    color: #1D9E75;
}

.login-btn svg {
    flex-shrink: 0;
}

 /* Hover effect สำหรับปุ่ม + */
#floating-add-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(29,158,117,0.6);
}
    
#floating-add-btn:active {
    transform: scale(0.95);
}
    
/* Animation เมื่อแสดงปุ่ม */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
    
#floating-add-btn.show {
    animation: fadeInUp 0.3s ease forwards;
}

/* ========== Main Content - เลื่อนได้ ========== */
.main { 
    flex: 1; 
    /* ✅ ทำให้เนื้อหาหลักเลื่อนได้ */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px; 
    background: #f5f4f0;
    
    /* ✅ ทำให้การเลื่อนลื่นไหล */
    scroll-behavior: smooth;
}

/* ========== Custom Scrollbar สำหรับ .main ========== */
.main::-webkit-scrollbar {
    width: 6px;
}

.main::-webkit-scrollbar-track {
    background: transparent;
}

.main::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.main::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

/* ========== Pages ========== */
.page { 
    display: none; 
}

.page.active { 
    display: block; 
}

.page-title { 
    font-size: 18px; 
    font-weight: 500; 
    color: #1a1a1a; 
    margin-bottom: 4px; 
}

.page-sub { 
    font-size: 13px; 
    color: #666; 
    margin-bottom: 20px; 
}

/* ========== KPI Grid ========== */
.kpi-grid { 
    display: grid; 
    grid-template-columns: repeat(4, minmax(0,1fr)); 
    gap: 12px; 
    margin-bottom: 20px; 
}

.kpi-card { 
    background: #fff; 
    border: 0.5px solid rgba(0,0,0,0.1); 
    border-radius: 12px; 
    padding: 14px 16px; 
}

.kpi-label { 
    font-size: 11px; 
    color: #666; 
    margin-bottom: 6px; 
}

.kpi-value { 
    font-size: 26px; 
    font-weight: 500; 
    color: #1a1a1a; 
    line-height: 1; 
}

.kpi-unit { 
    font-size: 12px; 
    color: #888; 
    margin-top: 4px; 
}

.kpi-badge { 
    display: inline-block; 
    font-size: 10px; 
    padding: 2px 6px; 
    border-radius: 4px; 
    margin-top: 6px; 
}

.badge-green { 
    background: #EAF3DE; 
    color: #3B6D11; 
}

.badge-amber { 
    background: #FAEEDA; 
    color: #854F0B; 
}

/* ========== Layout Rows ========== */
.row { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 16px; 
    margin-bottom: 16px; 
}

.row-3 { 
    display: grid; 
    grid-template-columns: 2fr 1fr; 
    gap: 16px; 
    margin-bottom: 16px; 
}

/* ========== Cards ========== */
.card { 
    background: #fff; 
    border: 0.5px solid rgba(0,0,0,0.1); 
    border-radius: 12px; 
    padding: 16px; 
}

.card-title { 
    font-size: 13px; 
    font-weight: 500; 
    color: #1a1a1a; 
    margin-bottom: 12px; 
}

/* ========== Map ========== */
.map-placeholder { 
    background: #efefeb; 
    border-radius: 8px; 
    position: relative; 
    overflow: hidden; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

/* ปุ่มล้าง filter ในแผนที่ */
#mf-reset-btn {
  background: #666 !important;
  transition: background 0.2s;
}

#mf-reset-btn:hover {
  background: #444 !important;
}

#mf-reset-btn:active {
  background: #333 !important;
}

/* Modal Search Input */
#modal-search {
  transition: border-color 0.15s, box-shadow 0.15s;
}

#modal-search:focus {
  outline: none;
  border-color: #1D9E75;
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.15);
}

#modal-search-clear {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

#modal-search-clear:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #1a1a1a;
}

/* Highlight matched text (ถ้าต้องการพัฒนาต่อ) */
.search-highlight {
  background: #FFF4E6;
  color: #854F0B;
  padding: 0 2px;
  border-radius: 2px;
}

/* ========== Bars ========== */
.bar-row { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    margin-bottom: 8px; 
}

.bar-label { 
    font-size: 12px; 
    color: #666; 
    width: 70px; 
    flex-shrink: 0; 
    text-align: right; 
}

.bar-track { 
    flex: 1; 
    height: 8px; 
    background: #efefeb; 
    border-radius: 4px; 
    overflow: hidden; 
}

.bar-fill { 
    height: 100%; 
    border-radius: 4px; 
}

.bar-val { 
    font-size: 11px; 
    color: #888; 
    width: 30px; 
}

/* ── Topic Bars (Overview) ── */
.topic-bar-row {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.topic-bar-label {
  font-size: 12px;
  color: #444;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

.topic-bar-track {
  height: 8px;
  background: #efefeb;
  border-radius: 4px;
  overflow: hidden;
  min-width: 0;
}

.topic-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.topic-bar-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  min-width: 52px;
}

.topic-bar-pct {
  font-size: 12px;
  font-weight: 500;
  color: #1a1a1a;
  line-height: 1;
}

.topic-bar-count {
  font-size: 10px;
  color: #aaa;
  line-height: 1;
}

/* ── Topic Bars (responsive) ── */
#topic-bars-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topic-bar-item {
  display: grid;
  grid-template-columns: 130px 1fr 38px 36px;
  align-items: center;
  gap: 8px;
}

.topic-bar-label {
  font-size: 12px;
  color: #555;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-bar-track {
  height: 8px;
  background: #efefeb;
  border-radius: 4px;
  overflow: hidden;
}

.topic-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.topic-bar-val {
  font-size: 12px;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.topic-bar-count {
  font-size: 10px;
  color: #bbb;
  white-space: nowrap;
}

/* Responsive: จอเล็ก */
@media (max-width: 600px) {
  .topic-bar-item {
    grid-template-columns: 100px 1fr 36px 30px;
    gap: 6px;
  }

  .topic-bar-label {
    font-size: 11px;
  }

  .topic-bar-val {
    font-size: 11px;
  }
}

/* Responsive */
@media (max-width: 600px) {
  .topic-bar-row {
    grid-template-columns: 100px 1fr auto;
    gap: 8px;
  }

  .topic-bar-label {
    font-size: 11px;
  }
}

/* Dropdown Title */
#cf-title {
  background: white;
  border: 0.5px solid rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  color: #1a1a1a;
  cursor: pointer;
  transition: border-color 0.15s;
}

#cf-title:hover {
  border-color: #1D9E75;
}

#cf-title:focus {
  outline: none;
  border-color: #1D9E75;
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.15);
}

/* ========== Trend Chart ========== */
.trend-row { 
    display: flex; 
    align-items: flex-end; 
    gap: 6px; 
    height: 80px; 
    margin-bottom: 8px; 
}

.trend-bar { 
    flex: 1; 
    border-radius: 3px 3px 0 0; 
    background: #1D9E75; 
    opacity: 0.7; 
    cursor: pointer; 
}

.trend-bar:hover { 
    opacity: 1; 
}

.trend-labels { 
    display: flex; 
    gap: 6px; 
}

.trend-lbl { 
    flex: 1; 
    text-align: center; 
    font-size: 10px; 
    color: #aaa; 
}

/* ========== Tables ========== */
table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 12px; 
}

th { 
    font-weight: 500; 
    color: #666; 
    text-align: left; 
    padding: 6px 8px; 
    border-bottom: 0.5px solid rgba(0,0,0,0.1); 
}

td { 
    padding: 7px 8px; 
    border-bottom: 0.5px solid rgba(0,0,0,0.08); 
    color: #1a1a1a; 
}

/* ========== Table Column Styles ========== */

/* คอลัมน์ประเด็นหลัก (Title) */
.td-title {
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  padding: 8px 12px;
}

/* Badge สำหรับประเด็นหลัก */
.title-badge {
  display: inline-block;
  padding: 4px 10px;
  background: linear-gradient(135deg, #E1F5EE 0%, #D4F1E7 100%);
  color: #1D9E75;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  border: 0.5px solid rgba(29, 158, 117, 0.2);
  transition: all 0.15s ease;
}

.title-badge:hover {
  background: linear-gradient(135deg, #D4F1E7 0%, #C7EBDE 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(29, 158, 117, 0.2);
}

/* คอลัมน์ปี */
.td-year {
  text-align: center;
  font-weight: 500;
  color: #666;
  padding: 8px 12px;
}

/* ========== Button Styles ========== */

/* ปุ่มดู */
.btn-view {
  padding: 6px 14px;
  background: linear-gradient(135deg, #378ADD 0%, #2E6DB8 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(55, 138, 221, 0.2);
  white-space: nowrap;
}

.btn-view:hover {
  background: linear-gradient(135deg, #2E6DB8 0%, #255A99 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(55, 138, 221, 0.3);
}

.btn-view:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(55, 138, 221, 0.2);
}

/* ปุ่มดูแบบเล็ก */
.btn-sm {
  padding: 5px 12px;
  font-size: 11px;
}

/* ปุ่ม PDF */
.btn-pdf {
  padding: 5px 10px;
  background: white;
  color: #185FA5;
  border: 0.5px solid #185FA5;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-pdf:hover {
  background: #E6F1FB;
  border-color: #0F4D8A;
  color: #0F4D8A;
}

/* ── Map ── */
#leaflet-map, #public-leaflet-map { 
    height:360px; 
    width:100%; 
    background:#efefeb; 
}

#map-wrapper { 
    border-radius:0 0 8px 8px; 
    overflow:hidden; 
}

/* ── Map filter bar ── */
.map-filter-bar {
    display:flex; 
    gap:8px; 
    flex-wrap:wrap;
    padding:10px 16px; 
    border-bottom:0.5px solid rgba(0,0,0,0.08); 
    background:#fafaf8;
}
    
.map-filter-bar select {
    font-size:12px; 
    padding:5px 8px;
    border:0.5px solid rgba(0,0,0,0.18); 
    border-radius:6px;
    background:white; 
    color:#1a1a1a; 
    flex:1; 
    min-width:110px;
}

/* ── Search / filter bar ── */
.filter-bar {
    display:flex; 
    gap:8px; 
    flex-wrap:wrap; 
    margin-bottom:12px;
}
    
.filter-bar input, .filter-bar select {
    font-size:13px; 
    padding:7px 10px;
    border:0.5px solid rgba(0,0,0,0.2); 
    border-radius:8px;
    background:white; 
    color:#1a1a1a;
}
    
.filter-bar input  { 
    flex:2; 
    min-width:160px; 
}

.filter-bar select { 
    flex:1; 
    min-width:110px; 
}

.filter-bar button {
    padding:7px 16px; 
    border:none; 
    border-radius:8px;
    background:#1D9E75; 
    color:white; 
    font-size:13px; 
    cursor:pointer; 
    white-space:nowrap;
}

.filter-bar button:hover { 
    background:#0F6E56; 
}

/* ── Table helpers ── */
.td-center { 
    text-align:center; 
    padding:24px; 
}
    
.td-name   { 
    font-weight:500; 
    font-size:13px; 
    max-width:200px; 
}

 /* ── Charter image thumb ── */
.charter-thumb {
    width:44px; 
    height:44px; 
    object-fit:cover; 
    border-radius:5px;
    border:0.5px solid rgba(0,0,0,0.1); 
    cursor:zoom-in; 
    display:block;
}
    
.charter-thumb-empty {
    width:44px; 
    height:44px; 
    border-radius:5px;
    background:#f0f0ec; 
    border:0.5px solid rgba(0,0,0,0.08);
    font-size:9px; 
    color:#bbb; 
    display:flex;
    align-items:center;
    justify-content:center; 
    text-align:center;
}

/* ── PDF button ── */
.btn-pdf {
    font-size:11px; 
    color:#185FA5; 
    border:0.5px solid #185FA5;
    border-radius:4px; 
    padding:3px 9px; 
    text-decoration:none;
    display:inline-block; 
    white-space:nowrap;
}

.btn-pdf.disabled { 
    color:#bbb; 
    border-color:#ddd; 
    cursor:default; 
}

/* ── Pager ── */
.pager-wrap { 
    display:flex; 
    align-items:center; 
    gap:10px; 
    margin-top:10px; 
}

.pager-btn  {
    padding:5px 14px; 
    border:0.5px solid rgba(0,0,0,0.2); 
    border-radius:6px;
    background:white; 
    color:#444; 
    font-size:12px; 
    cursor:pointer;
}

.pager-btn:disabled { 
    color:#ccc; 
    cursor:default; 
}

.pager-info { 
    font-size:12px; 
    color:#888; 
}

/* ── Public hero ── */
.public-hero {
    background:linear-gradient(135deg,#0F6E56 0%,#1D9E75 100%);
    border-radius:12px; 
    padding:28px 24px; 
    margin-bottom:16px; 
    color:white;
}

.public-hero h2 { 
    font-size:20px; 
    font-weight:500; 
    margin-bottom:6px; 
    color:white; 
}

.public-hero p  { 
    font-size:13px; 
    opacity:0.85; 
}

/* ── Sidebar footer ── */
.sidebar-footer { 
    margin-top:auto; 
    padding:12px 16px 16px; 
}

/* ========== Title Badge Styles ========== */
.title-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  transition: all 0.15s ease;
  cursor: default;
}

.title-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}


.title-badge[data-type="elderly"] {
  background: #E1F5EE;
  color: #1D9E75;
}

.title-badge[data-type="child"] {
  background: #E6F1FB;
  color: #378ADD;
}

.title-badge[data-type="mental"] {
  background: #FBEAF0;
  color: #D4537E;
}

.title-badge[data-type="endoflife"] {
  background: #FFF4E6;
  color: #EF9F27;
}

.title-badge[data-type="ltc"] {
  background: #E8F4FD;
  color: #5DCAA5;
}

.title-badge[data-type="other"] {
  background: #F5F5F3;
  color: #666;
}

tr:last-child td { 
    border-bottom: none; 
}

tr:hover td { 
    background: #f8f8f5; 
}

/* ========== Tags & Badges ========== */
.tag { 
    display: inline-block; 
    font-size: 10px; 
    padding: 2px 6px; 
    border-radius: 3px; 
}

.tag-green { 
    background: #EAF3DE; 
    color: #3B6D11; 
}

.tag-amber { 
    background: #FAEEDA; 
    color: #854F0B; 
}

.tag-gray { 
    background: #efefeb; 
    color: #666; 
}

.check { 
    color: #1D9E75; 
    font-size: 14px; 
}

.cross { 
    color: #E24B4A; 
    font-size: 14px; 
}

/* ========== Pills ========== */
.pill { 
    font-size: 10px; 
    padding: 2px 8px; 
    border-radius: 10px; 
    background: #FCEBEB; 
    color: #A32D2D; 
}

.pill-warn { 
    font-size: 10px; 
    padding: 2px 8px; 
    border-radius: 10px; 
    background: #FAEEDA; 
    color: #854F0B; 
}

/* ========== Public Page ========== */
.public-hero { 
    background: linear-gradient(135deg, #0F6E56 0%, #1D9E75 100%); 
    border-radius: 12px; 
    padding: 28px 24px; 
    margin-bottom: 16px; 
    color: white; 
}

.public-hero h2 { 
    font-size: 20px; 
    font-weight: 500; 
    margin-bottom: 6px; 
    color: white; 
}

.public-hero p { 
    font-size: 13px; 
    opacity: 0.85; 
}

.public-btn { 
    display: inline-block; 
    margin-top: 14px; 
    background: white; 
    color: #0F6E56; 
    font-size: 13px; 
    font-weight: 500; 
    padding: 8px 18px; 
    border-radius: 8px; 
    cursor: pointer; 
}

.info-cards { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 12px; 
    margin-bottom: 16px; 
}

.info-card { 
    background: #fff; 
    border: 0.5px solid rgba(0,0,0,0.1); 
    border-radius: 12px; 
    padding: 16px; 
}

.info-card h4 { 
    font-size: 13px; 
    font-weight: 500; 
    color: #1a1a1a; 
    margin-bottom: 4px; 
}

.info-card p { 
    font-size: 12px; 
    color: #666; 
    line-height: 1.5; 
}

/* ========== Search Bar ========== */
.search-bar { 
    display: flex; 
    gap: 8px; 
    margin-bottom: 16px; 
    flex-wrap: wrap;
}

.search-bar select { 
    font-size: 13px; 
    padding: 7px 10px; 
    border: 0.5px solid rgba(0,0,0,0.2); 
    border-radius: 8px; 
    background: #fff; 
    color: #1a1a1a; 
    flex: 1;
    min-width: 120px;
}

/* ปุ่มล้างการคัดกรอง */
#cf-reset-btn, #lw-reset-btn {
  background: #666 !important;
}

#cf-reset-btn:hover, #lw-reset-btn:hover {
  background: #444 !important;
}

/* Loading indicator */
.search-loading {
  position: relative;
}

.search-loading::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid #1D9E75;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

.open-btn { 
    font-size: 11px; 
    color: #1D9E75; 
    cursor: pointer; 
    border: 0.5px solid #1D9E75; 
    border-radius: 4px; 
    padding: 2px 8px; 
}

/* ========== Gap Analysis ========== */
.gap-card-inner { 
    background: #f5f4f0; 
    border-radius: 8px; 
    padding: 12px; 
    margin-bottom: 10px; 
}

.gap-card-inner:last-child { 
    margin-bottom: 0; 
}

/* Modal Animation */
@keyframes modalSlideIn {
    from { 
        opacity: 0; 
        transform: scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}
  
/* Toast Animations */
@keyframes slideIn {
    from { 
        transform: translateX(120%); 
        opacity: 0; 
    }
    to { 
        transform: translateX(0); 
        opacity: 1; 
    }
}
  
@keyframes slideOut {
    from { 
        transform: translateX(0); 
        opacity: 1; 
    }
    to { 
        transform: translateX(120%); 
        opacity: 0; 
    }
}
  
#toast-notification.hide {
    animation: slideOut 0.3s ease forwards;
}
  
/* ปิด modal เมื่อคลิกพื้นหลัง */
#confirm-modal {
    cursor: pointer;
}

#confirm-modal > div {
    cursor: default;
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .row-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 200px;
        position: static;
        overflow-x: auto;
        overflow-y: hidden;
        flex-shrink: 0;
        border-right: none;
        border-bottom: 0.5px solid rgba(0,0,0,0.12);
    }
    
    .sidebar-footer {
        position: static;
        border-top: 0.5px solid rgba(0, 0, 0, 0.12);
        border-right: none;
        margin-top: 0;
    }
    
    .main {
        height: calc(100vh - 200px);
    }
    
    .info-cards {
        grid-template-columns: 1fr;
    }
    
    .search-bar {
        flex-direction: column;
    }
    
    .search-bar select,
    .search-bar button {
        width: 100%;
    }
}

:root {
  --green: #1D9E75;
  --green-dark: #0F6E56;
  --green-light: #E6F7F1;
  --blue: #378ADD;
  --amber: #EF9F27;
  --red: #E04031;
  --pink: #D4537E;
  --bg: #F5F4F0;
  --card: #FFFFFF;
  --border: rgba(0,0,0,0.08);
  --text: #1a1a1a;
  --muted: #888;
  --sidebar-w: 220px;
  --radius: 12px;
}

/* ── LAYOUT ── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.logo {
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.logo-title {
  font-family: 'IBM Plex Sans Thai', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--green-dark);
  letter-spacing: -0.3px;
}
.logo-sub {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}


.modal-close-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: none;
  color: #bbb;
  font-size: 24px;
  font-weight: 300;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  padding: 0;
}

.modal-close-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #666;
}

.modal-close-btn:active {
  transform: scale(0.95);
}

/* ════════════════════════════════
   🔘 MODAL ACTION BUTTONS
   ════════════════════════════════ */
.btn-modal-cancel,
.btn-modal-confirm {
  flex: 1;
  min-height: 44px;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Sarabun', 'Kanit', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-modal-cancel {
  background: #f5f5f5;
  color: #666;
}

.btn-modal-cancel:hover {
  background: #e8e8e8;
}

.btn-modal-confirm {
  background: var(--red, #E04031);
  color: white;
}

.btn-modal-confirm:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-modal-cancel:active,
.btn-modal-confirm:active {
  transform: scale(0.98);
}

/* ════════════════════════════════
   📱 RESPONSIVE FOR MODAL BUTTONS
   ════════════════════════════════ */
@media (max-width: 768px) {
  .modal-close-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    font-size: 26px;
  }
  
  .btn-modal-cancel,
  .btn-modal-confirm {
    min-height: 48px;
    font-size: 15px;
    padding: 14px 16px;
  }
  
  /* Modal footer: stack buttons on small screens */
  .modal-footer {
    flex-direction: column;
    gap: 10px;
  }
  
  .modal-footer .btn-sm {
    width: 100%;
    min-height: 48px;
  }
}

@media (max-width: 480px) {
  .modal-close-btn {
    width: 52px;
    height: 52px;
    min-width: 52px;
    min-height: 52px;
    font-size: 28px;
  }
  
  .btn-modal-cancel,
  .btn-modal-confirm {
    min-height: 52px;
    font-size: 16px;
  }
}

.nav-section {
  font-size: 10px;
  font-weight: 600;
  color: #bbb;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 16px 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 13px;
  color: #555;
  border-radius: 0;
  transition: all 0.15s;
  position: relative;
}
.nav-item:hover { background: #f7f7f5; color: var(--text); }
.nav-item.active { background: var(--green-light); color: var(--green-dark); font-weight: 500; }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--green);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
}

/* ── MAIN ── */
.main {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

.btn-icon {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  font-size: 12px;
  font-family: 'Sarabun', sans-serif;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  font-weight: 500;
}
.btn-icon:hover { background: var(--bg); }
.btn-icon.primary { background: var(--green); color: white; border-color: transparent; }
.btn-icon.primary:hover { background: var(--green-dark); }
.btn-icon.blue { background: var(--blue); color: white; border-color: transparent; }
.btn-icon.blue:hover { opacity: 0.9; }

/* ── CONTENT ── */
.content { padding: 20px 24px 40px; }

@media (max-width: 768px) {
  .content { padding: 12px 12px 80px; }
}

/* ── FILTER BAR ── */
.filter-strip {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
  font-family: 'Kanit', 'Kodchasan', 'Mali', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.filter-strip select,
.filter-strip input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
  font-family: 'Sarabun', sans-serif;
  color: var(--text);
  background: white;
  min-width: 120px;
  outline: none;
  transition: border-color 0.15s;
}
.filter-strip select:focus,
.filter-strip input:focus { border-color: var(--green); }

.filter-strip input { min-width: 200px; }

.filter-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

.btn-reset {
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #00000036;
  color: white;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-reset:hover { background: #ccc6c6; }

/* ── KPI GRID ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--green);
}
.kpi-card.amber::after { background: var(--amber); }
.kpi-card.blue::after { background: var(--blue); }
.kpi-card.red::after { background: var(--red); }

.kpi-label { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.kpi-value {
  font-family: 'IBM Plex Sans Thai', sans-serif;
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}
.kpi-unit { font-size: 11px; color: var(--muted); }

/* ── CARDS ── */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card-title {
  font-family: 'IBM Plex Sans Thai', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.card-sub { font-size: 11px; color: var(--muted); margin-bottom: 14px; }

/* ── MAP ── */
.map-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafaf8;
}
.map-filter-bar select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: 'Sarabun', sans-serif;
  background: white;
  min-width: 120px;
  outline: none;
}
.map-filter-bar select:focus { border-color: var(--green); }

#leaflet-map { height: 440px; width: 100%; }

/* ── STATUS CHART ── */
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-label { font-size: 12px; color: var(--text); flex: 1; }
.status-pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.progress-bar {
  height: 6px;
  background: #f0f0ec;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease;
}

/* ── TOPIC BARS ── */
.topic-bar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #f5f5f0;
}
.topic-bar-item:last-child { border-bottom: none; }
.topic-bar-label {
  font-size: 11px;
  color: var(--text);
  width: 110px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topic-bar-track {
  flex: 1;
  height: 6px;
  background: #f0f0ec;
  border-radius: 3px;
  overflow: hidden;
}
.topic-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease;
}
.topic-bar-val {
  font-size: 11px;
  font-weight: 600;
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}
.topic-bar-count {
  font-size: 10px;
  color: var(--muted);
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}

/* ── GRID LAYOUTS ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── FLOATING ADD BTN ── */
#floating-add-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: white;
  border: none;
  box-shadow: 0 4px 16px rgba(29,158,117,0.4);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 300;
  z-index: 1000;
  transition: all 0.2s ease;
}
#floating-add-btn:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(29,158,117,0.5); }

/* ── AUTH ── */
#auth-logged-in { display: none; }

/* ── MODAL ── */
.modal-ov {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: white;
  border-radius: 14px;
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  overflow: hidden;
}
.modal-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.modal-search-bar {
  padding: 10px 18px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  background: #fafafa;
}
.modal-search-bar input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Sarabun', sans-serif;
  background: white;
  outline: none;
}
.modal-search-bar input:focus { border-color: var(--green); }
.modal-search-wrap { position: relative; }
.modal-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 13px;
}
.modal-body { padding: 14px 18px 16px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.modal-footer > div:first-child {
  flex: 1;
  min-width: 0;
}

.modal-footer .btn-sm {
  min-width: 80px;
  min-height: 36px;
  padding: 8px 16px;
}


.modal-filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.modal-filter-bar select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: 'Sarabun', sans-serif;
  background: white;
  outline: none;
}

.charter-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fafaf8;
  margin-bottom: 10px;
  display: flex;
  gap: 12px;
}
.charter-card-img {
  width: 56px;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: #f0f0ec;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.charter-card-body { flex: 1; min-width: 0; }
.charter-card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.4;
}
.charter-card-meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.charter-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.btn-sm {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  font-size: 11px;
  font-family: 'Sarabun', sans-serif;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}
.btn-sm:hover { background: var(--bg); }
.btn-sm.green { background: var(--green); color: white; border-color: transparent; }
.btn-sm.green:hover { background: var(--green-dark); }
.btn-sm.blue { background: var(--blue); color: white; border-color: transparent; }
.btn-sm.blue:hover { opacity: 0.9; }

/* ── STATUS BADGE ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 500;
}

/* ── CONFIRM MODAL ── */
#confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* ── TOAST ── */
@keyframes slideInRight {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(120%); opacity: 0; }
}
.toast-enter { animation: slideInRight 0.3s ease forwards; }
.toast-exit { animation: slideOutRight 0.3s ease forwards; }

/* ── LEAFLET OVERRIDES ── */
.leaflet-control-attribution { font-size: 9px !important; }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .content { padding: 12px 12px 80px; }

  /* Filter strip: stack vertically */
  .filter-strip {
    flex-direction: column;
    gap: 6px;
  }
  .filter-strip input,
  .filter-strip select,
  .filter-strip button {
    width: 100%;
    min-width: unset !important;
    max-width: unset !important;
  }
  .filter-divider { display: none; }
  .search-input-long {
    min-width: unset !important;
    max-width: unset !important;
    width: 100% !important;
  }

  /* KPI: 2 columns on mobile */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .kpi-value { font-size: 22px; }

  /* Map full width */
  #leaflet-map { height: 280px; }

  /* Cards spacing */
  .card { padding: 12px; }
  .card-title { font-size: 13px; }

  /* Topic bars */
  #topic-bars-container { gap: 8px; }

  /* Modal */
  .modal-box { max-width: 100%; border-radius: 10px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 20px; }
  .btn-icon { padding: 7px 10px; }
}

@media (max-width: 480px) {
  .btn-icon {
    padding: 8px 12px;
    font-size: 11px;
    min-height: 36px;
  }
  
  .btn-icon svg {
    width: 16px;
    height: 16px;
  }
  
  ััั.btn-icon.blue span {
    font-size: 12px;
    font-weight: 500;
  }
}

/* Responsive: Stack on mobile */
@media (max-width: 480px) {
  .modal-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  
  .modal-footer > div:first-child {
    text-align: center;
  }
  
  .modal-footer .btn-sm {
    width: 100%;
    min-height: 44px;
  }
}
/* ── ZONE BADGE ── */
.zone-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: #e8f4f0;
  color: var(--green-dark);
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  font-size: 13px;
  font-family: 'Sarabun', sans-serif;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s;
}
.link-btn:hover { opacity: 0.9; }

@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&display=swap');

:root {
  --green: #1D9E75;
  --green-dark: #0F6E56;
  --green-light: #E6F7F1;
  --blue: #378ADD;
  --amber: #EF9F27;
  --bg: #F5F4F0;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #666;
  --border: rgba(0, 0, 0, 0.08);
  --sidebar-w: 220px;
  --radius: 12px;
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Kanit', sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
  height: 100vh;
}

/* Layout */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: #efefeb;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.logo {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}

.logo-title {
  font-size: 14px;
  font-weight: 600;
}

.logo-sub {
  font-size: 11px;
  color: var(--muted);
}

.nav-section {
  font-size: 10px;
  color: #aaa;
  text-transform: uppercase;
  padding: 16px 16px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: 0.2s;
}

.nav-item:hover {
  background: white;
  color: var(--text);
}

.nav-item.active {
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 500;
  border-left: 3px solid var(--green);
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--border);
}

/* Main */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
  scroll-behavior: smooth;
}

/* Scrollbar */
.main::-webkit-scrollbar {
  width: 6px;
}

.main::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
}

/* Page */
.page {
  display: none;
}

.page.active {
  display: block;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
}

.page-sub {
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0 20px;
}

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.kpi-label {
  font-size: 11px;
  color: var(--muted);
}

.kpi-value {
  font-size: 28px;
  font-weight: 600;
  margin-top: 6px;
}

.kpi-unit {
  font-size: 12px;
  color: #888;
}

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* Grid */
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.row-3 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

/* Buttons */
.btn-view,
.btn-pdf,
button {
  border: none;
  cursor: pointer;
  transition: 0.2s;
}

.btn-view {
  padding: 8px 14px;
  background: var(--blue);
  color: white;
  border-radius: 8px;
}

.btn-view:hover {
  opacity: 0.9;
}

.btn-pdf {
  padding: 6px 10px;
  border: 1px solid var(--blue);
  color: var(--blue);
  background: white;
  border-radius: 6px;
}

/* Filter */
.filter-bar,
.search-bar,
.map-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-bar input,
.filter-bar select,
.search-bar select,
.map-filter-bar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: white;
}

/* Map */
#leaflet-map,
#public-leaflet-map {
  width: 100%;
  height: 570px;
  border-radius: 10px;
}

/* Topic bar */
.topic-bar-item {
  display: grid;
  grid-template-columns: 120px 1fr 40px 40px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.topic-bar-label {
  font-size: 12px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-bar-track {
  height: 8px;
  background: #efefeb;
  border-radius: 4px;
  overflow: hidden;
}

.topic-bar-fill {
  height: 100%;
  background: var(--green);
}

.topic-bar-val {
  font-size: 12px;
  font-weight: 500;
}

.topic-bar-count {
  font-size: 10px;
  color: #aaa;
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th, td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

tr:hover td {
  background: #f8f8f5;
}

/* Floating Button */
#floating-add-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 28px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(29,158,117,0.4);
}

/* ========== Dropdown Styles ========== */
.nav-dropdown {
  position: relative;
  display: inline-block; /* ✅ สำคัญ: ให้ dropdown อยู่บรรทัดเดียวกับเมนูอื่น */
}

.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}

.nav-dropdown-toggle .arrow {
  font-size: 9px;
  transition: transform 0.2s;
  color: #999;
}

.nav-dropdown-toggle.active .arrow {
  transform: rotate(180deg);
}

.nav-submenu {
  position: absolute;
  top: 100%;
  left: 0;
  list-style: none;
  padding: 4px 0;
  margin: 4px 0 0 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 180px;
  z-index: 1001;
  
  /* Animation */
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  opacity: 0;
}

.nav-submenu.show {
  max-height: 300px;
  opacity: 1;
}

.nav-submenu li a {
  display: block;
  padding: 8px 16px;
  font-size: 12px;
  color: #555;
  text-decoration: none;
  transition: background 0.15s;
  white-space: nowrap;
}

.nav-submenu li a:hover {
  background: var(--green-light);
  color: var(--green-dark);
}

.nav-submenu li a.active {
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 500;
}

/* Responsive Tablet */
@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .row,
  .row-3 {
    grid-template-columns: 1fr;
  }
}

/* Responsive Mobile */
@media (max-width: 768px) {
  body {
    overflow: auto;
  }

  .app {
    flex-direction: column;
    height: auto;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    max-height: 180px;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .main {
    padding: 16px;
    height: auto;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .topic-bar-item {
    grid-template-columns: 80px 1fr 35px;
  }

  .topic-bar-count {
    display: none;
  }

  .filter-bar,
  .search-bar,
  .map-filter-bar {
    flex-direction: column;
  }

  .filter-bar input,
  .filter-bar select,
  .search-bar select,
  .map-filter-bar select,
  button {
    width: 100%;
  }

  #leaflet-map,
  #public-leaflet-map {
    height: 280px;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .topnav-links {
    display: none; /* ซ่อนเมนูบนมือถือ หรือทำ hamburger menu */
  }
  .topnav { padding: 0 17px; }
}

@media (max-width: 768px) {
  /* ✅ Body ต้องเลื่อนได้ปกติ */
  body {
    overflow-y: auto;
    overflow-x: hidden;
    height: auto;
    min-height: 100vh;
  }

  /* ✅ App Layout สำหรับมือถือ */
  .app {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible; /* ✅ สำคัญ: ห้ามเป็น hidden เพราะจะตัดการเลื่อน */
  }

  /* ✅ Topnav ต้องติดด้านบนเสมอ */
  .topnav {
    position: sticky !important; /* ✅ บังคับให้ sticky */
    top: 0 !important;
    z-index: 1000 !important;
    width: 100%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1); /* ✅ เพิ่มเงาให้ดูมีมิติ */
  }

  /* ส่วนอื่นๆ ของมือถือ */
  .main {
    padding: 16px;
    padding-top: 50px; /* ✅ เว้นระยะด้านบนไม่ให้เนื้อหาทับเมนู */
  }
}

/* ════════════════════════════════
   🔘 MODAL ACTION BUTTONS (Map Modal)
   ════════════════════════════════ */
.charter-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.btn-edit-modal {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #378ADD 0%, #2E6DB8 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-family: 'Kanit', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(55, 138, 221, 0.2);
}

.btn-edit-modal:hover {
  background: linear-gradient(135deg, #2E6DB8 0%, #255A99 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(55, 138, 221, 0.3);
}

.btn-edit-modal:active {
  transform: translateY(0);
}

.btn-del-modal {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #E04031 0%, #C03025 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-family: 'Kanit', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(224, 64, 49, 0.2);
}

.btn-del-modal:hover {
  background: linear-gradient(135deg, #C03025 0%, #A0281F 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(224, 64, 49, 0.3);
}

.btn-del-modal:active {
  transform: translateY(0);
}

/* ════════════════════════════════
   🗑️ DELETE CONFIRM MODAL
   ════════════════════════════════ */
.del-confirm-ov {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.del-confirm-ov.show {
  display: flex;
}

.del-confirm-box {
  background: white;
  border-radius: 16px;
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
  text-align: center;
  animation: slideUp 0.3s ease;
}

.del-confirm-icon {
  width: 56px;
  height: 56px;
  background: #FFF4E6;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 28px;
}

.del-confirm-title {
  font-size: 17px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 8px;
}

.del-confirm-msg {
  font-size: 13px;
  color: #666;
  margin-bottom: 20px;
  line-height: 1.5;
}

.del-confirm-name {
  font-weight: 500;
  color: #E04031;
  display: block;
  margin: 4px 0;
}

.del-confirm-actions {
  display: flex;
  gap: 10px;
}

.del-confirm-actions button {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Kanit', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.del-confirm-cancel {
  background: #f0f0ec;
  color: #555;
}

.del-confirm-cancel:hover {
  background: #e0e0dc;
}

.del-confirm-delete {
  background: linear-gradient(135deg, #E04031 0%, #C03025 100%);
  color: white;
}

.del-confirm-delete:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { 
    opacity: 0; 
    transform: translateY(20px) scale(0.98); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0) scale(1); 
  }
}

/* Responsive for mobile */
@media (max-width: 480px) {
  .del-confirm-box {
    padding: 20px;
    margin: 0 12px;
  }
  
  .del-confirm-actions {
    flex-direction: column;
    gap: 8px;
  }
  
  .del-confirm-actions button {
    min-height: 44px;
  }
}

/* ========== FOOTER STYLES (Full Width Background) ========== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 0 24px;      /* ✅ เว้นระยะขอบซ้าย-ขวา สำหรับเนื้อหา */
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  flex-shrink: 0;
  width: 100%;          /* ✅ ยาวเต็มจอ */
  font-family: 'Kanit', 'Sarabun', sans-serif;
  font-size: 12px;
  color: var(--muted, #888);
  box-sizing: border-box; /* ✅ สำคัญ: ให้ padding ไม่นับรวมในความกว้าง */
}

.footer-container {
  /* ✅ เปลี่ยนจาก max-width เป็น width 100% */
  width: 100%;          
  max-width: 1400px;    /* ✅ แต่จำกัดความกว้างเนื้อหาไว้ที่ 1200px */
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

/* ส่วนเนื้อหาใน Footer */
.footer-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.footer-org {
  font-weight: 500;
  color: var(--text, #1a1a1a);
}

.footer-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
}

.footer-contact {
  display: flex;
  align-items: center;
  gap: 12px;
}

.contact-label {
  color: var(--muted, #aaa);
}

.contact-link {
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.contact-link:hover {
  color: var(--green-dark, #0F6E56);
  text-decoration: underline;
}

.footer-copyright {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted, #aaa);
}

@media (max-width: 1024px) {
  .site-footer {
    height: auto;
    padding: 12px 16px;
  }

  .footer-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .footer-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
  }

  .footer-divider {
    display: none;
  }

  .footer-contact {
    display: flex;
    flex-direction: column;  /* ✅ บังคับแนวตั้ง */
    align-items: flex-start;
    gap: 2px;
  }

  /* ✅ บังคับให้แต่ละ span เป็น block เต็มบรรทัด */
  .footer-contact > span {
    display: block;
    width: 100%;
    line-height: 1.8;
    font-size: 11px;
  }

  .contact-link {
    word-break: break-all;
  }

  .footer-copyright {
    margin-left: 0;
    width: 100%;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 4px;
    font-size: 10px;
  }
}

/* === Mobile Toggle Button (ซ่อนในจอใหญ่) === */
.mobile-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
  margin-left: auto; /* ดันไปขวาสุด */
  z-index: 101;
  margin: 20px;
}

.hamburger-line {
  width: 22px;
  height: 2px;
  background: var(--text, #1a1a1a);
  border-radius: 2px;
  transition: 0.3s;
}

/* =========================================
   ✅ MOBILE RESPONSIVE NAV (วางท้ายไฟล์)
   ========================================= */
@media (max-width: 768px) {
  
  /* 1. แก้ไข Topnav: ให้ความสูงยืดหยุ่นและเป็นจุดอ้างอิง */
  .topnav {
    height: auto !important;
    min-height: 52px;
    padding: 0 16px !important;
    flex-wrap: wrap;
    align-items: center;
    row-gap: 0;
    z-index: 1000;
    position: sticky;
    top: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    /* ✅ เพิ่ม: ทำให้เป็นจุดอ้างอิงสำหรับลูกที่ใช้ position: absolute */
    position: relative;
  }

  /* 2. ✅ ซ่อนโลโก้ในโหมดมือถือ */
  .topnav-logo {
    display: none !important;
  }

  /* 3. ปุ่ม Hamburger: ดันไปขวาสุด */
  .mobile-toggle {
    order: 2;
    display: flex !important;
    margin-left: auto;
    padding: 8px;
    z-index: 101;
    background: none;
    border: none;
    cursor: pointer;
  }

  /* 4. เมนูหลัก: ให้ลงมาแถวใหม่เต็มความกว้าง */
  .topnav-links {
    order: 3;
    width: 100%;
    display: none;
    flex-direction: column;
    padding: 8px 0 12px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
    background: #fff;
    animation: slideDown 0.2s ease;
  }

  .topnav-links.active {
    display: flex !important;
  }

  /* 5. สไตล์ลิงก์ในเมนูมือถือ */
  .topnav-links .nav-link {
    padding: 12px 0;
    font-size: 16px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    width: 100%;
    text-align: center;
  }
  .topnav-links .nav-link:last-child {
    border-bottom: none;
  }

  /* 6. Dropdown HIA ในมือถือ */
  .nav-dropdown {
    width: 100%;
  }
  .nav-dropdown-toggle {
    justify-content: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
  }
  .nav-submenu {
    position: static;
    box-shadow: none;
    border: none;
    padding-left: 0;
    background: #fafaf8;
    margin-top: 0;
    display: none;
    max-height: none;
    opacity: 1;
    text-align: center;
  }
  .nav-submenu.show {
    display: block;
  }
  .nav-submenu .nav-link {
    padding: 8px 0;
    font-size: 15px;
    color: var(--muted, #666);
    border: none;
  }

  /* 7. ✅ ส่วน Auth (Login/User): ยึดมุมขวาบนสุด */
  .topnav-right {
    order: 1;
    position: absolute;      /* ✅ ลอยออกจากปกติ */
    top: 50%;                /* ✅ กึ่งกลางแนวตั้ง */
    right: 16px;             /* ✅ ชิดขวา เว้นระยะ 16px */
    transform: translateY(-50%); /* ✅ จัดกึ่งกลางเป๊ะๆ */
    width: auto;
    justify-content: flex-end;
    padding: 0;
    margin: 0;
    border: none;
    z-index: 102;            /* ✅ อยู่เหนือปุ่มเมนู */
    display: flex !important;
    align-items: center;
    gap: 8px;
  }

  /* ✅ ซ่อนชื่อผู้ใช้และบทบาทในมือถือ (แสดงเฉพาะไอคอน) */
  #auth-logged-in #user-name,
  #auth-logged-in #user-role {
    display: none !important;
  }

  /* ✅ ปรับ Avatar ให้เป็นไอคอนกลมเล็กๆ */
  #auth-logged-in #user-avatar {
    width: 36px !important;
    height: 36px !important;
    font-size: 14px !important;
    margin: 0 !important;
  }

  /* ✅ ปรับปุ่ม Logout ให้เป็นไอคอนเล็กๆ */
  #auth-logged-in button[onclick="handleLogout()"] {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    background: #f5f3f0 !important;
    border: 1px solid var(--border) !important;
  }
  
  #auth-logged-in button[onclick="handleLogout()"] svg {
    width: 14px !important;
    height: 14px !important;
  }

  /* ✅ จัดเรียงไอคอนให้ชิดกัน */
  #auth-logged-in {
    gap: 6px !important;
    padding: 4px 0 !important;
  }

  /* ✅ ปุ่มเข้าสู่ระบบ (กรณียังไม่ได้ล็อกอิน) - ซ่อนข้อความ */
  #auth-logged-out button {
    padding: 8px !important;
    min-width: 40px !important;
    justify-content: center !important;
  }
  #auth-logged-out button span {
    display: none !important;
  }

  /* ✅ Animation */
  @keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* ✅ แปลงปุ่มเมนูเป็นรูปกากบาท */
  .mobile-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }
  .mobile-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
  }
  .mobile-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
  }

  /* ✅ ซ่อนปุ่มออกจากระบบในมือถือ */
  #auth-logged-in button[onclick="handleLogout()"] {
    display: none !important;
  }

  /* ✅ จัดระยะห่างใหม่เมื่อปุ่มหาย (เหลือแค่ไอคอน User) */
  #auth-logged-in {
    gap: 0 !important;
    padding: 0 !important;
  }
}

/* ── ซ่อน user icon เมื่อเมนูมือถือเปิด ── */
@media (max-width: 768px) {
  .topnav-right.menu-open {
    display: none !important;
  }
}

.charter-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}

.charter-card-actions .btn-sm,
.charter-card-actions .btn-edit-modal,
.charter-card-actions .btn-del-modal {
  flex: 1 1 auto;
  min-width: 80px;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
}

@media (max-width: 400px) {
  .charter-card {
    flex-direction: column;
  }

  .charter-card-img {
    width: 100% !important;
    height: 100px !important;
  }

  .charter-card-actions {
    flex-direction: column;
  }

  .charter-card-actions .btn-sm,
  .charter-card-actions .btn-edit-modal,
  .charter-card-actions .btn-del-modal {
    width: 100%;
    min-height: 40px;
    font-size: 12px;
    padding: 8px 12px;
  }
}