/* Import Web Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

/* CSS Variables for Premium Theme matching Reference.png */
:root {
    --primary-color: #0b2e1b;     /* สีเขียวเข้มพิเศษของระบบลูกเสือ */
    --primary-light: #16462c;     /* สีเขียวใบไม้ */
    --accent-color: #d4af37;      /* สีทองลูกเสือ */
    --accent-dark: #b89324;
    --bg-color: #f1f5f2;          /* สีพื้นเทา-เขียวอ่อนสะอาดตา */
    --panel-bg: #ffffff;
    --panel-border: rgba(11, 46, 27, 0.06);
    --text-main: #233129;
    --text-muted: #6e7f75;
    
    /* สีประจำไอคอน/หมวดหมู่ใน Reference.png */
    --scout-green: #15803d;
    --scout-yellow: #eab308;
    --scout-blue: #1d4ed8;
    --scout-purple: #7e22ce;
    --scout-orange: #ea580c;
    --scout-pink: #db2777;
    --scout-brown: #78350f;
    --scout-teal: #0f766e;
    --scout-red: #dc2626;
    
    /* เงาและขอบ */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 16px rgba(11, 46, 27, 0.04);
    --shadow-lg: 0 10px 30px rgba(11, 46, 27, 0.06);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset Styles */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: #0b2e1b;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
}

body {
    font-family: 'Sarabun', 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    overflow-x: hidden;
    padding-bottom: 0;
}

/* ป้องกัน gap ด้านล่างของ viewport */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Page Layout Structure */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.main-content {
    flex-grow: 1;
    margin-left: 280px;
    padding-top: 75px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: calc(100vw - 280px);
    display: flex;
    flex-direction: column;
}

.page-content-wrapper {
    padding: 30px 40px;
    flex-grow: 1;
}

/* Hide Mobile Elements on Desktop by Default */
.mobile-header,
.mobile-button-nav {
    display: none;
}

/* Helper Utilities */
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.no-padding { padding: 0 !important; }
.display-flex-row { display: flex; flex-direction: row; }
.display-flex-column { display: flex; flex-direction: column; }
.align-items-center { align-items: center; }

/* Background color utilities for icons in Reference.png */
.bg-light-green { background-color: rgba(21, 128, 61, 0.08); }
.bg-light-gold { background-color: rgba(212, 175, 55, 0.08); }
.bg-light-blue { background-color: rgba(29, 78, 216, 0.08); }
.bg-light-purple { background-color: rgba(126, 34, 206, 0.08); }
.bg-light-orange { background-color: rgba(234, 88, 12, 0.08); }
.bg-light-pink { background-color: rgba(219, 39, 119, 0.08); }
.bg-light-brown { background-color: rgba(120, 53, 15, 0.08); }
.bg-light-teal { background-color: rgba(15, 118, 110, 0.08); }
.bg-light-gray { background-color: rgba(0, 0, 0, 0.04); }

.color-green { color: var(--scout-green); }
.color-gold { color: var(--accent-dark); }
.color-blue { color: var(--scout-blue); }
.color-purple { color: var(--scout-purple); }
.color-orange { color: var(--scout-orange); }
.color-pink { color: var(--scout-pink); }
.color-brown { color: var(--scout-brown); }
.color-teal { color: var(--scout-teal); }

/* Desktop Topbar Styles */
.desktop-topbar {
    background-color: #ffffff;
    height: 75px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    box-shadow: none;
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    z-index: 99;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.topbar-toggle-btn {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-main);
    cursor: pointer;
}

.user-greeting-group .greeting-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

.user-greeting-group .greeting-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.topbar-icon-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.topbar-icon-btn:hover {
    background-color: #f3f4f6;
}

.badge-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 0.65rem;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.bg-red { background-color: var(--scout-red); }

.topbar-user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background-color: #f8faf9;
    border: 1px solid var(--panel-border);
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
}

.topbar-user-profile:hover {
    background-color: #f1f5f3;
}

.profile-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    overflow: hidden;
}

.profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-text {
    display: flex;
    flex-direction: column;
}

.profile-name {
    font-size: 0.85rem;
    font-weight: 700;
}

.profile-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.profile-arrow {
    font-size: 1rem;
    color: var(--text-muted);
}

/* Desktop Sidebar Styles */
.desktop-sidebar {
    width: 280px;
    height: 100vh;
    background-color: var(--primary-color);
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    color: #ffffff;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.desktop-sidebar.collapsed {
    width: 80px;
}

.desktop-sidebar.collapsed .sidebar-header-img {
    padding: 10px 8px;
    object-fit: contain;
}

.desktop-sidebar.collapsed .sidebar-nav span {
    display: none;
}

.desktop-sidebar.collapsed .sidebar-nav .arrow-right {
    display: none;
}

.desktop-sidebar.collapsed .sidebar-nav a {
    justify-content: center;
    padding: 10px 8px;
}

.desktop-sidebar.collapsed .sidebar-nav a i:first-child {
    margin-right: 0;
    font-size: 1.3rem;
}

.desktop-sidebar.collapsed .sidebar-scout-motto {
    display: none;
}

.desktop-sidebar.collapsed .sidebar-footer-info {
    justify-content: center;
    padding: 10px;
}

.desktop-sidebar.collapsed .sidebar-footer-info .mini-logo {
    width: 36px;
    height: 36px;
    margin: 0;
}

.desktop-sidebar.collapsed .sidebar-footer-info .footer-text-group {
    display: none;
}

.main-content.sidebar-collapsed {
    margin-left: 80px;
    max-width: calc(100vw - 80px);
}

.desktop-topbar.sidebar-collapsed {
    left: 80px;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
}

.sidebar-header {
    width: 100%;
    height: 75px;
    min-height: 75px;
    flex-shrink: 0;
    overflow: hidden;
    background-color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-header-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: left center;
    display: block;
    padding: 10px 15px;
}

.sidebar-logo {
    width: 46px;
    height: 46px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--accent-color);
}

.sidebar-title-group .app-name {
    display: block;
    color: var(--accent-color);
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-title-group .app-sub {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.7rem;
}

.sidebar-nav {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px 10px;
}

/* Custom Scrollbar for Sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-size: 0.9rem;
}

.sidebar-nav a i:first-child {
    font-size: 1.15rem;
    margin-right: 12px;
    width: 20px;
    text-align: center;
    color: var(--accent-color);
    transition: var(--transition);
}

.sidebar-nav .arrow-right {
    margin-left: auto;
    font-size: 0.9rem;
    opacity: 0.5;
    color: var(--accent-color);
    transition: var(--transition);
}

.sidebar-nav a:hover i:first-child,
.sidebar-nav a:hover .arrow-right {
    color: #ffffff;
}

.sidebar-nav li.active a,
.sidebar-nav a:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-nav li.active a {
    background-color: var(--accent-color);
    color: var(--primary-color);
    font-weight: 700;
}

.sidebar-nav li.active a i:first-child,
.sidebar-nav li.active a .arrow-right {
    color: var(--primary-color);
    opacity: 1;
}

/* Sidebar Motto & Cartoon Mascot (Reference.png) */
.sidebar-bottom-section {
    background-image: url('../../BgSidebar.png');
    background-size: 100% 100%;
    background-position: center bottom;
    background-repeat: no-repeat;
    flex-shrink: 0;
    margin-top: auto;
}

.sidebar-scout-motto {
    height: 180px;
    position: relative;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.sidebar-scout-motto::before {
    content: '';
    position: absolute;
    top: -30px;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(to bottom, rgba(11, 46, 27, 0) 0%, rgba(11, 46, 27, 0.6) 100%);
    z-index: 1;
    pointer-events: none;
}

.motto-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background: linear-gradient(to bottom, rgba(11, 46, 27, 0.92) 0%, rgba(11, 46, 27, 0) 100%);
    z-index: 1;
}

.motto-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
}

.speech-bubble {
    background-color: #ffffff;
    color: var(--primary-color);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.4;
    position: relative;
    max-width: 200px;
    margin-bottom: 25px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.speech-bubble .motto-sub {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 6px;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 20px;
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: #ffffff transparent;
}

/* Scout illustration */
.scout-illustration {
    position: absolute;
    bottom: 0;
    right: 10px;
    width: 110px;
    height: 140px;
    overflow: hidden;
    pointer-events: none;
}

.scout-boy-img {
    width: 100%;
    height: auto;
    object-fit: contain;
    object-position: bottom center;
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.25));
}

.sidebar-footer-info {
    margin-top: -15px;
    padding: 15px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-footer-info .mini-logo {
    width: 44px;
    height: 44px;
}

.sidebar-footer-info .footer-text-group {
    display: flex;
    flex-direction: column;
}

.sidebar-footer-info .system-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-color);
}

.sidebar-footer-info .copyright,
.sidebar-footer-info .version {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.5);
}

/* ===== Welcome Profile Card ===== */
.welcome-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    padding: 18px 22px;
    margin-bottom: 26px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

/* ขีดสีเขียวด้านซ้ายการ์ด */
.welcome-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 5px;
    height: 100%;
    background: linear-gradient(to bottom, var(--accent-color), var(--primary-color));
    border-radius: 0 0 0 var(--radius-lg);
}

.welcome-avatar-wrap {
    flex-shrink: 0;
}

.welcome-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    border: 3px solid var(--accent-color);
    box-shadow: 0 4px 12px rgba(11, 46, 27, 0.2);
    overflow: hidden;
}

.welcome-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.welcome-text {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.welcome-greeting {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.welcome-name {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1.2;
}

.welcome-role {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

.welcome-badge {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-position-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0;
}

/* Dashboard Stats Cards with custom round icon */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

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

.stat-card {
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 4px 0;
    font-family: 'Inter', sans-serif;
}

.stat-value .unit {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-trend {
    font-size: 0.75rem;
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.text-success { color: #16a34a; }
.text-warning { color: #d97706; }
.text-muted-trend {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 10px;
}

/* Grids and Panels */
.dashboard-row-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 25px;
    margin-bottom: 30px;
}

.dashboard-panel {
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.panel-link {
    font-size: 0.8rem;
    color: var(--scout-blue);
    text-decoration: none;
    font-weight: 600;
}

.panel-body {
    padding: 20px;
}

/* Custom list for activities inside reference image */
.activity-list-custom {
    display: flex;
    flex-direction: column;
}

.activity-list-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--panel-border);
    gap: 15px;
    transition: var(--transition);
}

.activity-list-item:last-child {
    border-bottom: none;
}

.activity-list-item:hover {
    background-color: #fafbfa;
}

.item-badge-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-mini-badge {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.item-details {
    flex-grow: 1;
}

.item-title {
    font-size: 0.9rem;
    color: var(--text-main);
}

.item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    margin-top: 2px;
}

.item-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.badge-status {
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-status.finished { background-color: rgba(21, 128, 61, 0.08); color: var(--scout-green); }
.badge-status.in-progress { background-color: rgba(234, 88, 12, 0.08); color: var(--scout-orange); }
.badge-status.pending { background-color: rgba(0, 0, 0, 0.04); color: var(--text-muted); }

/* Doughnut Chart and Legend */
.doughnut-chart-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 20px;
}

.doughnut-svg {
    transform: rotate(-90deg);
}

.chart-center-text {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.chart-center-text .label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chart-center-text .value {
    font-size: 1.5rem;
    color: var(--primary-color);
    line-height: 1.1;
    font-family: 'Inter', sans-serif;
}

.chart-center-text .unit {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chart-legend-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 0.8rem;
    gap: 10px;
}

.legend-marker {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.legend-name {
    color: var(--text-muted);
    font-weight: 500;
    min-width: 100px;
}

.legend-val {
    font-weight: 700;
    margin-left: auto;
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
}

/* Promotion List and Custom Progress Bars */
.promotion-progress-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.promotion-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.promotion-header-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.promotion-badge-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.circle-bullet {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.promotion-ratio {
    color: var(--text-muted);
}

.progress-bar-wrapper-custom {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-bar-custom {
    height: 8px;
    background-color: #f1f3f1;
    border-radius: 4px;
    flex-grow: 1;
    overflow: hidden;
}

.progress-bar-custom .progress-fill {
    height: 100%;
    border-radius: 4px;
}

.percentage-label {
    font-size: 0.8rem;
    color: var(--text-main);
    width: 35px;
    text-align: right;
    font-family: 'Inter', sans-serif;
}

/* Activity line chart with dropdown */
.year-select-dropdown {
    padding: 6px 12px;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    background-color: #ffffff;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
    outline: none;
}

.line-chart-svg-container {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.line-chart-svg {
    width: 100%;
    height: auto;
}

.line-chart-months {
    display: flex;
    justify-content: space-between;
    padding: 5px 20px 0 35px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Quick Menu Grid */
.quick-menu-section {
    margin-top: 10px;
}

.quick-menu-title {
    font-size: 1.05rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.quick-menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 15px;
}

.quick-menu-card {
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.quick-menu-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.quick-icon-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 10px;
}

.quick-label {
    font-size: 0.75rem;
    color: var(--text-main);
}

/* Mobile Nav FAB Emblem */
.fab-emblem-wrapper {
    position: relative;
    width: 66px;
    height: 66px;
    margin-top: -30px;
}

.fab-emblem-btn {
    width: 66px;
    height: 66px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(212, 175, 55, 0.3);
    border: 4px solid var(--accent-color);
    transition: var(--transition);
    animation: fab-glow-pulse 3s ease-in-out infinite;
}

.fab-emblem-btn:hover {
    transform: scale(1.1);
}

.fab-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

@keyframes fab-glow-pulse {
    0%, 100% {
        box-shadow: 0 4px 14px rgba(212, 175, 55, 0.3);
    }
    50% {
        box-shadow: 0 4px 24px rgba(212, 175, 55, 0.6), 0 0 40px rgba(212, 175, 55, 0.2);
    }
}

/* Page Header (ใช้ร่วมกับทุกหน้าเนื้อหา) */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.page-title-area {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

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

.btn-block {
    width: 100%;
    justify-content: center;
    margin-top: 6px;
}

/* ===== ฟอร์มทั่วไป (หน้า group) ===== */
.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}
.form-group .required {
    color: #dc3545;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: var(--text-main);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(20, 90, 50, 0.12);
}
select.form-control {
    cursor: pointer;
}
.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Alert */
.alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.88rem;
}
.alert-success {
    background: rgba(40, 167, 69, 0.12);
    border: 1px solid rgba(40, 167, 69, 0.3);
    color: #1e7e34;
}
.alert-error {
    background: rgba(220, 53, 69, 0.12);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: #c82333;
}
.text-muted {
    color: var(--text-muted);
}

/* Panel grid (2 คอลัมน์) */
.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 900px) {
    .panel-grid { grid-template-columns: 1fr; }
}

/* Autocomplete */
.autocomplete-group {
    position: relative;
}
.autocomplete-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 50;
    max-height: 240px;
    overflow-y: auto;
    margin-top: 4px;
}
.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.autocomplete-item:last-child {
    border-bottom: none;
}
.autocomplete-item:hover {
    background: rgba(20, 90, 50, 0.06);
}
.autocomplete-item .ai-name {
    font-weight: 600;
    color: var(--text-main);
}
.autocomplete-item .ai-pos {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.autocomplete-item .ai-quals {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}
.autocomplete-item .qual-tag {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 20px;
    background: rgba(212, 175, 55, 0.18);
    color: #9a7b1a;
    border: 1px solid rgba(212, 175, 55, 0.35);
}

/* Group list */
.group-list {
    display: flex;
    flex-direction: column;
}
.group-item {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.group-item:last-child {
    border-bottom: none;
}
.group-item-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.group-item-info {
    flex: 1;
}
.group-item-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}
.group-item-branch {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 20px;
    margin-bottom: 8px;
}
.badge-branch-sena  { background: rgba(20, 90, 50, 0.12);  color: #145a32; }
.badge-branch-samut { background: rgba(13, 110, 253, 0.12); color: #0d6efd; }
.badge-branch-akas  { background: rgba(102, 16, 242, 0.12); color: #6610f2; }
.group-item-leaders {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.group-item-leaders i {
    color: var(--primary-color);
    margin-right: 4px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 2.4rem;
    display: block;
    margin-bottom: 10px;
    opacity: 0.5;
}
.empty-state p {
    font-size: 0.9rem;
}

/* Director Grid (ผู้กำกับลูกเสือ) */
.director-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.director-card {
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: var(--transition);
}

.director-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.director-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    border: 3px solid var(--accent-color);
    margin-bottom: 14px;
    overflow: hidden;
}

.director-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.director-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

.director-position {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.director-quals {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    justify-content: center;
}
.director-quals.collapsed .qual-badge:nth-child(n+6) { display: none; }
.qual-none {
    font-size: .8rem;
    color: var(--text-muted, #6b7280);
    font-style: italic;
}
.qual-toggle {
    margin-top: 8px;
    border: 1px solid var(--border, #e6e8ec);
    background: #fff;
    color: var(--primary-color, #145a32);
    font-size: .78rem;
    padding: 4px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-family: 'Sarabun', sans-serif;
}
.qual-toggle:hover { background: rgba(20,90,50,.06); }

.qual-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.3px;
}
.qual-ev-icon {
    margin-left: 4px;
    font-size: .8rem;
    cursor: pointer;
    opacity: .85;
    transition: opacity .15s;
}
.qual-ev-icon:hover { opacity: 1; }

/* Image viewer modal */
.modal-overlay.image-viewer {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}
.iv-modal {
    position: relative;
    background: #1e293b;
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    padding: 24px 24px 16px;
    text-align: center;
    animation: modalIn .18s ease;
}
.iv-close {
    position: absolute;
    top: 8px; right: 14px;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    color: #94a3b8;
    transition: color .15s;
}
.iv-close:hover { color: #fff; }
.iv-image-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 70vh;
    overflow: hidden;
}
.iv-image-wrap img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 10px;
    object-fit: contain;
}
.iv-title {
    margin: 12px 0 4px;
    font-size: .95rem;
    font-weight: 600;
    color: #e2e8f0;
}

.director-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    background-color: #f1f5f3;
    color: var(--text-muted);
}

.btn-icon:hover {
    transform: scale(1.08);
}

.btn-view:hover {
    background-color: rgba(29, 78, 216, 0.12);
    color: var(--scout-blue);
}

.btn-edit:hover {
    background-color: rgba(212, 175, 55, 0.15);
    color: var(--accent-dark);
}

/* Responsive Custom Breakpoints */
@media (max-width: 900px) {
    body {
        flex-direction: column;
    }
    
    .desktop-sidebar,
    .desktop-topbar {
        display: none; /* Hide Desktop elements on mobile */
    }

    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: 0;
    }

    .page-content-wrapper {
        padding: 85px 15px 95px; /* Leave top header and bottom navbar space */
    }

    .desktop-sidebar {
        display: flex;
        transform: translateX(-100%);
        width: 280px;
    }

    .desktop-sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-header {
        min-height: auto;
        height: 75px;
        border-bottom: none;
    }

    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }

    .sidebar-overlay.show {
        pointer-events: auto;
    }

    .mobile-header {
        display: flex;
        align-items: center;
        height: 60px;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 1000;
        box-shadow: var(--shadow-md);
        overflow: hidden;
        background-color: var(--primary-color);
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }
    
    .mobile-header-img {
        height: 100%;
        object-fit: contain;
        display: block;
        padding: 8px 15px;
        flex: 1;
        min-width: 0;
    }

    .mobile-profile-btn {
        padding: 0;
        margin-right: 12px;
        overflow: hidden;
    }

    .mobile-profile-avatar-img {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        object-fit: cover;
        border: 2px solid var(--accent-color);
        display: block;
    }

    .mobile-menu-btn {
        background: none;
        border: none;
        color: #ffffff;
        font-size: 1.4rem;
        cursor: pointer;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .mobile-menu-btn-left {
        order: -1;
    }

    .mobile-logo {
        width: 38px;
        height: 38px;
        border-radius: 50%;
        border: 2px solid var(--accent-color);
    }

    .mobile-app-title {
        color: #ffffff;
        font-weight: 700;
        font-size: 1.1rem;
    }

    /* Bottom Button Nav for Mobile */
    .mobile-button-nav {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 65px;
        z-index: 1000;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.12);
        margin: 0;
        padding: 0;
        background-color: #0b2e1b;
        background-image: url('../../BgSidebar.png');
        background-size: cover;
        background-position: center;
    }

    .mobile-button-nav .nav-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(to top, rgba(11, 46, 27, 0.45) 0%, rgba(11, 46, 27, 0.25) 100%);
    }

    .mobile-button-nav .nav-links {
        position: relative;
        z-index: 2;
        display: flex;
        justify-content: space-around;
        align-items: center;
        height: 100%;
        padding: 0 10px;
    }

    .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        color: rgba(255,255,255,0.6);
        text-decoration: none;
        font-size: 0.65rem;
        gap: 3px;
        transition: var(--transition);
        width: 60px;
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    }

    .nav-item i {
        font-size: 1.25rem;
    }

    .nav-item.active {
        color: var(--accent-color);
        font-weight: 700;
    }

    .dashboard-row-grid {
        grid-template-columns: 1fr;
    }

    /* Welcome Card ปรับสำหรับมือถือ */
    .welcome-card {
        padding: 14px 16px;
        gap: 12px;
        margin-bottom: 18px;
    }

    .welcome-avatar {
        width: 52px;
        height: 52px;
        font-size: 1.5rem;
    }

    .welcome-name {
        font-size: 1.1rem;
    }

    .welcome-badge {
        width: 48px;
        height: 48px;
    }
}

/* ================================================
   กลุ่ม/กองลูกเสือ — คาร์ดขยายได้
   ================================================ */
.group-cards { display: flex; flex-direction: column; gap: 14px; padding: 16px; }

.group-card {
    border: 1px solid var(--border, #e6e8ec);
    border-radius: 14px;
    background: #fff;
    overflow: hidden;
    transition: box-shadow .2s ease;
}
.group-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.07); }

.group-card-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
}
.group-card-head.open { background: rgba(20,90,50,.04); }

.group-card-id {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.group-card-id i { font-size: 1.4rem; }

.group-card-meta { flex: 1; min-width: 0; }
.group-card-name { font-size: 1rem; font-weight: 600; margin: 0 0 4px; }
.group-card-tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tree-view-btn { position: relative; z-index: 2; cursor: pointer; }
.troop-count {
    font-size: .78rem; color: var(--text-muted, #6b7280);
    display: inline-flex; align-items: center; gap: 3px;
}
.group-card-leaders-mini {
    font-size: .82rem; color: var(--text-muted, #6b7280);
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.group-card-chevron { font-size: 1.4rem; color: var(--text-muted, #6b7280); transition: transform .2s; flex-shrink: 0; }
.group-card-head.open .group-card-chevron { transform: rotate(180deg); }

.group-card-body { border-top: 1px solid var(--border, #e6e8ec); padding: 14px 16px; }

.group-leaders-detail {
    display: flex; flex-wrap: wrap; gap: 8px 22px;
    font-size: .85rem; color: #374151;
    margin-bottom: 14px;
}
.group-leaders-detail i { color: var(--green, #145a32); margin-right: 4px; }

.troop-slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.troop-card {
    border: 1px dashed #d1d5db;
    border-radius: 12px;
    background: #fafbfc;
    padding: 12px;
}
.troop-card-add { border-style: solid; border-color: rgba(20,90,50,.3); background: #fff; }
.troop-card-empty { display: flex; align-items: center; justify-content: center; min-height: 70px; }

.troop-card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    margin-bottom: 10px;
}
.troop-no { font-weight: 600; font-size: .9rem; }
.badge-troop-type {
    font-size: .72rem; font-weight: 600;
    background: rgba(20,90,50,.12); color: #145a32;
    padding: 2px 8px; border-radius: 999px;
    white-space: nowrap;
}
.troop-card-body { font-size: .82rem; color: #374151; }
.troop-leader, .troop-deps { margin-bottom: 6px; }
.troop-leader i, .troop-deps i { color: var(--green, #145a32); margin-right: 4px; }
.dep-name { font-weight: 500; }

/* Chip สำหรับรองผู้กำกับกองหลายคน */
.chip-box { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: rgba(13,110,253,.1); color: #0d6efd;
    font-size: .78rem; padding: 3px 8px; border-radius: 999px;
}
.chip i { cursor: pointer; font-size: .95rem; }

/* ป้ายกำลังใช้ (บุคลากรซ้ำ) */
.assigned-badge {
    margin-left: auto;
    font-size: .68rem; font-weight: 600;
    background: #fff3cd; color: #997404;
    padding: 2px 7px; border-radius: 999px;
    white-space: nowrap;
}

/* รายการที่ถูกใช้แล้ว (เลือกไม่ได้) */
.autocomplete-item.disabled {
    opacity: .55;
    cursor: not-allowed;
    background: #f8f9fa;
    filter: grayscale(0.4);
}
.autocomplete-item.disabled:hover { background: #f8f9fa; }

.form-control-sm { padding: 7px 10px; font-size: .85rem; border-radius: 8px; }
.btn-sm { padding: 7px 12px; font-size: .85rem; }
.btn-block { width: 100%; }

@media (max-width: 600px) {
    .group-card-leaders-mini { display: none; }
    .troop-slots { grid-template-columns: 1fr; }
}

/* แถบค้นหาแบบ realtime */
.filter-bar {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 18px; flex-wrap: wrap;
}
.search-box {
    position: relative;
    flex: 1; max-width: 360px;
}
.search-box i {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted, #6b7280); font-size: 1.05rem;
}
.search-box input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 1px solid var(--border, #e6e8ec);
    border-radius: 10px;
    font-size: .9rem; font-family: 'Sarabun', sans-serif;
    background: #fff;
}
.search-box input:focus {
    outline: none; border-color: var(--primary-color, #145a32);
    box-shadow: 0 0 0 3px rgba(20,90,50,.12);
}
.filter-count { font-size: .82rem; color: var(--text-muted, #6b7280); }

/* แบดตัวกรองวุฒิ */
.filter-chips {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-bottom: 20px;
}
.chip-filter {
    border: 1px solid var(--border, #e6e8ec);
    background: #fff;
    color: #374151;
    font-size: .8rem;
    font-family: 'Sarabun', sans-serif;
    padding: 6px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: all .15s ease;
}
.chip-filter:hover { border-color: var(--primary-color, #145a32); color: var(--primary-color, #145a32); }
.chip-filter.active {
    background: var(--primary-color, #145a32);
    border-color: var(--primary-color, #145a32);
    color: #fff;
    font-weight: 600;
}

/* ปุ่มไอคอนบนการ์ด (แก้ไข) */
.icon-btn {
    width: 32px; height: 32px;
    border: 1px solid var(--border, #e6e8ec);
    border-radius: 8px;
    background: #fff;
    color: var(--text-muted, #6b7280);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 1.05rem;
    transition: all .15s ease;
    flex-shrink: 0;
}
.icon-btn:hover { background: rgba(20,90,50,.08); color: #145a32; border-color: rgba(20,90,50,.3); }
.troop-card-head { position: relative; }
.troop-card-head .icon-btn { margin-left: auto; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .45);
    display: none; align-items: center; justify-content: center;
    z-index: 1000; padding: 16px;
}
.modal-box {
    background: #fff;
    border-radius: 16px;
    width: 100%; max-width: 460px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    animation: modalIn .18s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border, #e6e8ec);
}
.modal-head h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.modal-close {
    border: none; background: transparent; font-size: 1.6rem; line-height: 1;
    cursor: pointer; color: var(--text-muted, #6b7280);
}
.modal-body { padding: 20px; }
.modal-actions {
    display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px;
}
.btn-ghost {
    background: #f1f3f5; color: #374151;
    border: 1px solid transparent;
}

/* ===== ทะเบียนกองลูกเสือ (troop_roster) ===== */
.roster-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.summary-card {
    background: var(--panel-bg, #fff);
    border: 1px solid var(--panel-border, #e6e8ec);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex; flex-direction: column; gap: 4px;
}
.summary-card .summary-label { font-size: .8rem; color: #6b7280; }
.summary-card strong { font-size: 1.05rem; }

.section-title { font-size: 1rem; margin: 0 0 12px; }

.status-badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: .78rem; font-weight: 600;
}
.status-graduated   { background: #dcfce7; color: #15803d; }
.status-transferred { background: #dbeafe; color: #1d4ed8; }
.status-left        { background: #fee2e2; color: #b91c1c; }

.troop-roster-btn { margin-top: 10px; width: 100%; justify-content: center; }

/* โมดัลเพิ่มนักเรียน (รูปแบบ modal-box) */
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 460px;
    max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25);
    animation: modalIn .18s ease; }
.modal-lg { max-width: 620px; }
.modal-header { display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border, #e6e8ec); }
.modal-header h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.close-modal { border: none; background: transparent; font-size: 1.6rem; line-height: 1;
    cursor: pointer; color: var(--text-muted, #6b7280); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end;
    padding: 16px 20px; border-top: 1px solid var(--border, #e6e8ec); }
.modal-hint { font-size: .85rem; color: #6b7280; margin: 0 0 12px; }

.add-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.add-toolbar .search-box { flex: 1; }
.select-all { display: flex; align-items: center; gap: 6px; font-size: .85rem; white-space: nowrap; }

.student-pick-list {
    max-height: 320px; overflow-y: auto; border: 1px solid var(--border, #e6e8ec);
    border-radius: 12px; padding: 6px; background: #fafbfc;
}
.pick-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px;
    border-radius: 9px; cursor: pointer; }
.pick-item:hover { background: #f1f5f9; }
.pick-item.selected { background: #e0f2fe; }
.pick-item input[type=checkbox] { width: 16px; height: 16px; }
.pick-name { flex: 1; }
.pick-level { font-size: .8rem; color: #475569; background: #eef2f7;
    padding: 2px 8px; border-radius: 999px; }
.pick-count { margin-top: 10px; font-size: .85rem; color: #475569; }
.empty-hint { padding: 20px; text-align: center; color: #9ca3af; font-size: .9rem; }

.form-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.form-input, .form-select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border, #d1d5db);
    border-radius: 10px; font-size: .95rem; background: #fff;
    font-family: inherit; color: inherit;
}

/* ===== ตารางข้อมูล (data-table) ===== */
.table-container {
    background: var(--panel-bg, #fff);
    border: 1px solid var(--panel-border, rgba(11,46,27,.06));
    border-radius: var(--radius-lg, 16px);
    padding: 18px 20px;
    margin-bottom: 22px;
}
.table-filter-bar {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 14px; flex-wrap: wrap;
}
.responsive-table-wrapper { overflow-x: auto; }
.data-table {
    width: 100%; border-collapse: collapse; font-size: .92rem;
}
.data-table thead th {
    text-align: left; padding: 12px 14px;
    background: #f5f7f6; color: var(--text-muted, #6e7f75);
    font-weight: 600; font-size: .8rem; letter-spacing: .02em;
    border-bottom: 2px solid var(--panel-border, rgba(11,46,27,.06));
    white-space: nowrap;
}
.data-table thead th.text-center { text-align: center; }
.data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--panel-border, rgba(11,46,27,.06));
    color: var(--text-main, #233129); vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8faf9; }
.data-table .text-center { text-align: center; }
.data-table .empty-row td { text-align: center; color: var(--text-muted, #6e7f75); padding: 28px; }

.action-buttons { display: flex; gap: 6px; justify-content: center; }

.btn-secondary {
    background: #fff; color: var(--text-main, #233129);
    border: 1px solid var(--panel-border, rgba(11,46,27,.12));
}
.btn-secondary:hover { background: #f3f5f4; }
.btn-outline {
    background: transparent; color: var(--primary-color, #0b2e1b);
    border: 1px solid var(--primary-color, #0b2e1b);
}
.btn-outline:hover { background: rgba(11,46,27,.06); }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .92rem; }
.alert-error { background: #fdecea; color: #b91c1c; border: 1px solid #f5c2c0; }

.summary-card .summary-name { font-size: .95rem; line-height: 1.4; font-weight: 600; }
.summary-list { margin: 0; padding-left: 16px; font-size: .85rem; color: var(--text-main, #233129); }
.summary-list li { margin: 2px 0; }

.muted-text { color: var(--text-muted, #6e7f75); font-size: .88rem; }

.type-summary { align-items: flex-start; }
.type-counts { margin-top: 10px; font-size: .9rem; color: var(--text-main, #233129); }
.type-row { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.type-row strong { margin: 0 2px; }
.type-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.type-dot.boy { background: #2563eb; }
.type-dot.girl { background: #db2777; }
.type-total { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--panel-border, rgba(11,46,27,.12)); font-size: .88rem; }

.affil-line { font-size: .92rem; }
.affil-sub { margin-top: 3px; display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--text-muted, #6e7f75); }

.install-prompt {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: 460px;
    width: calc(100% - 32px);
    background: var(--panel-bg, #fff);
    border: 1px solid var(--panel-border, rgba(11,46,27,.1));
    border-radius: var(--radius-lg, 16px);
    padding: 14px 16px;
    box-shadow: 0 12px 30px rgba(0,0,0,.18);
}
.install-prompt-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    flex-shrink: 0;
    object-fit: contain;
}
.install-prompt-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.install-prompt-body strong { font-size: .95rem; color: var(--text-main, #233129); }
.install-prompt-body span { font-size: .8rem; color: var(--text-muted, #6e7f75); }
.install-prompt-actions { display: flex; gap: 8px; flex-shrink: 0; }
@media (max-width: 480px) {
    .install-prompt { flex-wrap: wrap; }
    .install-prompt-actions { width: 100%; }
    .install-prompt-actions .btn { flex: 1; }
}

/* ===== หน้าค่าบำรุงประจำปี ===== */
.fee-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.fee-tab {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 16px; border: 1px solid var(--panel-border, rgba(11,46,27,.12));
    background: #fff; color: var(--text-main, #233129); border-radius: 10px;
    font-size: .92rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.fee-tab.active { background: var(--primary-color, #0b2e1b); color: #fff; border-color: var(--primary-color, #0b2e1b); }

.status-badge.status-paid { background: #16a34a; color: #fff; }
.status-badge.status-unpaid { background: #dc2626; color: #fff; }
.status-badge.status-exempt { background: #7c3aed; color: #fff; }

.data-table tr.row-paid { background: #f3faf5; }
.data-table tr.row-unpaid { background: #fff; }
.data-table tr.row-exempt { background: #f6f2ff; }

.evidence-cell { font-size: .82rem; }
.ev-tag { display: inline-block; padding: 1px 6px; background: #eef2f0; border-radius: 6px; color: var(--text-muted, #6e7f75); margin-right: 4px; }
.ev-link { color: var(--primary-color, #0b2e1b); text-decoration: none; }
.text-warn { color: #b45309; }

/* ===== กิจกรรม / โครงการ ===== */
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 160px; }
.text-right { text-align: right; }
.req { color: #dc2626; font-weight: 600; }
.data-table tr.sub-row td { background: #fafbfa; color: var(--text-muted, #6e7f75); font-size: .85rem; padding-top: 0; padding-bottom: 10px; }

.troop-picker {
    max-height: 260px; overflow-y: auto;
    border: 1px solid var(--border-color, #d8e0db); border-radius: 10px;
    padding: 10px 12px; background: #fafbfa;
}
.picker-group { margin-bottom: 12px; }
.picker-group:last-child { margin-bottom: 0; }
.picker-group-name { font-weight: 700; font-size: .9rem; margin-bottom: 6px; color: var(--primary-color, #0b2e1b); }
.picker-item {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 8px; border-radius: 8px; cursor: pointer;
    font-size: .9rem;
}
.picker-item:hover { background: #eef2f0; }
.picker-item input { margin: 0; }

.tag {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    background: #e7f0ea; color: var(--primary-color, #0b2e1b);
    font-size: .78rem; font-weight: 600; line-height: 1.6;
}

/* ===== ผังต้นไม้กลุ่มลูกเสือ (Org-chart style, พิมพ์ A4 แนวนอน) ===== */
.tree-modal { max-width: 1100px; width: 96%; }
.tree-modal-header { display: flex; align-items: center; justify-content: space-between; }
.tree-modal-actions { display: flex; align-items: center; gap: 10px; }
.tree-modal-body { padding: 22px 26px; text-align: center; }

/* โครงผัง */
.ot-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Pill ทั่วไป */
.ot-pill {
    display: inline-block;
    padding: 8px 22px;
    border-radius: 30px;
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

/* เส้นเชื่อมแนวตั้ง */
.ot-stem-down {
    width: 2px;
    height: 22px;
    background: #94a3b8;
    margin: 0 auto;
}

/* หัวกลุ่ม */
.ot-group { display: flex; flex-direction: column; align-items: center; }
.ot-group-leader {
    background: #16a34a;
    color: #fff;
    padding: 10px 32px;
    font-size: .95rem;
}
.ot-group-deputy {
    background: #16a34a;
    color: #fff;
    padding: 8px 28px;
    font-size: .9rem;
    opacity: .92;
}

/* แถวกอง (แนวนอน) พร้อมเส้นแนวนอนเชื่อม */
.ot-troops {
    display: inline-flex;
    justify-content: center;
    align-items: flex-start;
    gap: 26px;
    flex-wrap: wrap;
    margin-top: 0;
}

/* คอลัมน์กอง */
.ot-troop-col {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 160px;
    max-width: 230px;
    flex: 1;
}

/* เส้นแนวนอนเชื่อมระหว่างกอง (ยื่นคร่อมช่องว่าง 26px ÷ 2 = 13px เพื่อไม่ให้ขาด) */
.ot-troop-col::before {
    content: '';
    position: absolute;
    top: 0;
    height: 2px;
    background: #94a3b8;
}
.ot-troop-col:first-child::before {
    left: 50%;
    width: calc(50% + 13px);
}
.ot-troop-col:last-child::before {
    left: -13px;
    width: calc(50% + 13px);
}
.ot-troop-col:not(:first-child):not(:last-child)::before {
    left: -13px;
    width: calc(100% + 26px);
}
.ot-troop-col:only-child::before { display: none; }

/* หัวกอง (สีตามประเภท — ตั้ง inline style) */
.ot-troop-head {
    color: #fff;
    font-size: .82rem;
    padding: 8px 16px;
    text-align: center;
    white-space: normal;
    line-height: 1.4;
}

/* ผู้กำกับกอง (สีตามประเภท — ตั้ง inline style) */
.ot-leader {
    font-size: .85rem;
    padding: 6px 18px;
}

/* รองผู้กำกับกอง (สีตามประเภท — ตั้ง inline style) */
.ot-dep {
    font-size: .82rem;
    padding: 5px 16px;
}
.ot-dep-empty {
    background: transparent;
    border: 1.5px dashed #cbd5e1;
    color: #94a3b8;
    font-size: .8rem;
    padding: 5px 14px;
}

/* ตำแหน่งใต้ชื่อ */
.ot-position {
    display: block;
    font-size: .72rem;
    font-weight: 400;
    opacity: .75;
    margin-top: 1px;
}

/* จำนวนลูกเสือ */
.ot-member-count {
    margin-top: 8px;
    font-size: .82rem;
    color: var(--primary-color, #0b2e1b);
}

.ot-empty {
    color: var(--text-muted, #6e7f75);
    font-style: italic;
    margin-top: 20px;
}

/* ===== พิมพ์ A4 แนวนอน ===== */
@media print {
    @page { size: A4 landscape; margin: 8mm; }
    html, body { height: auto !important; overflow: visible !important; }

    /* ค collapse body children → ตัดหน้าว่างทิ้ง (visibility:hidden ลูก override ได้ด้วย visibility:visible) */
    body > * {
        visibility: hidden;
        height: 0 !important;
        max-height: 0 !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    #treeModal, #treeModal * { visibility: visible; }
    #treeModal {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: 100% !important;
        display: flex !important;
        align-items: flex-start !important;
        justify-content: center !important;
        padding: 0 !important;
        background: #fff !important;
    }
    #treeModal .tree-modal {
        display: block !important; max-width: none; width: 100%;
        box-shadow: none; border: none; max-height: none;
        overflow: visible; border-radius: 0;
    }
    #treeModal .tree-modal-header { display: flex; padding: 6px 12px; border-bottom: none; }
    #treeModal .tree-modal-body { padding: 8px 14px; text-align: center; }
    #treeModal .tree-modal-actions { display: none !important; }

    #treeModal .ot-chart { display: flex; flex-direction: column; align-items: center; }
    #treeModal .ot-group { display: flex; flex-direction: column; align-items: center; }
    #treeModal .ot-troops { display: flex; justify-content: center; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
    #treeModal .ot-troop-col { display: flex; flex-direction: column; align-items: center; position: relative; }
    #treeModal .ot-pill { display: inline-block; }
    #treeModal .ot-stem-down { display: block; height: 16px; }
    #treeModal .ot-member-count { display: block; }

    .ot-pill, .ot-position, .ot-stem-down, .ot-troop-col::before { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

