* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    background: #f5f5f5;
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
    animation: fadeIn 0.3s ease-in;
    font-weight: 400;
    line-height: 1.7;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Ripple effect animation */
@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Top Filter Bar */
.top-filter-bar {
    background: #e8f5e9;
    border-bottom: 1px solid #c8e6c9;
    padding: 6px 12px;
    z-index: 100;
    position: sticky;
    top: 0;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 4px;
    justify-content: flex-start;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: nowrap;
}

.filter-item label {
    font-size: 0.9em;
    color: #555;
    white-space: nowrap;
}

.btn-toggle-sidebar {
    padding: 4px 8px;
    border: 1px solid #bdbdbd;
    border-radius: 4px;
    background: white;
    color: #555;
    cursor: pointer;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-toggle-sidebar::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-toggle-sidebar:active::before {
    width: 300px;
    height: 300px;
}

.btn-toggle-sidebar:hover {
    background: #f5f5f5;
    border-color: #9e9e9e;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn-toggle-sidebar:active {
    transform: scale(0.95);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.btn-toggle-sidebar span {
    display: inline-block;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.filter-item input[type="checkbox"] {
    margin-right: 5px;
}

.filter-item select,
.filter-item input[type="date"],
.filter-item input[type="number"] {
    padding: 4px 8px;
    border: 1px solid #bdbdbd;
    border-radius: 4px;
    font-size: 0.9em;
    background: white;
    min-width: 100px;
    flex: 1;
    max-width: 160px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.filter-item select:hover,
.filter-item input[type="date"]:hover,
.filter-item input[type="number"]:hover {
    border-color: #667eea;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.15);
    transform: translateY(-1px);
}

.filter-item select:focus,
.filter-item input[type="date"]:focus,
.filter-item input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1), 0 2px 6px rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.nav-btn {
    padding: 3px 6px;
    border: 1px solid #bdbdbd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.nav-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}

.nav-btn:active::before {
    width: 200px;
    height: 200px;
}

.nav-btn:hover {
    background: #f0f0f0;
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    border-color: #667eea;
}

.nav-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.btn-today {
    padding: 4px 12px;
    border: 1px solid #4caf50;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    margin-left: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
    font-weight: 400;
}

.btn-today::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-today:active::before {
    width: 300px;
    height: 300px;
}

.btn-today:hover {
    background: linear-gradient(135deg, #45a049 0%, #388e3c 100%);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-today:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

#pageNumber {
    padding: 0 8px;
    font-weight: 400;
    font-size: 0.9em;
}

.tabs-row {
    display: flex !important;
    gap: 0;
    border-bottom: 2px solid #808080;
    padding: 0;
    margin-top: 15px;
    margin-bottom: 0;
    background: #c0c0c0;
    padding-top: 2px;
    padding-left: 2px;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    min-height: 30px;
}

.tab {
    padding: 8px 20px;
    background: #c0c0c0;
    border: 1px outset #c0c0c0;
    border-bottom: none;
    border-top-left-radius: 2px;
    border-top-right-radius: 2px;
    cursor: pointer;
    font-size: 0.95em;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #000 !important;
    margin-right: 1px;
    position: relative;
    top: 0;
    font-family: 'Sarabun', 'Prompt', 'Kanit', sans-serif;
    user-select: none;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-width: 80px;
    text-align: center;
    overflow: hidden;
}

.tab::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}

.tab:active::before {
    width: 200px;
    height: 200px;
}

.tab.active {
    background: #fffacd !important;
    border: 1px inset #c0c0c0;
    border-bottom: 2px solid #fffacd;
    margin-bottom: -2px;
    z-index: 10;
    color: #000 !important;
    font-weight: normal;
    box-shadow: 0 -1px 0 0 #fffacd, 0 2px 4px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.tab:hover:not(.active) {
    background: #d4d0c8;
    transform: translateY(-1px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tab:active:not(.active) {
    transform: translateY(0) scale(0.98);
}

.tab-content {
    display: none;
    padding: 20px 0;
}

.tab-content.active {
    display: block;
}

/* Main Layout */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: #f5f5f5;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar.mobile-hidden {
    transform: translateX(-100%);
}

.sidebar.hidden {
    width: 0;
    min-width: 0;
    overflow: hidden;
    border-right: none;
}

.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2em;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.mobile-menu-toggle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.mobile-menu-toggle:active::before {
    width: 300px;
    height: 300px;
}

.mobile-menu-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

.sidebar-tabs {
    display: flex;
    flex-direction: column;
    background: #e8e8e8;
    border-bottom: 1px solid #d0d0d0;
}

.sidebar-tab {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #d0d0d0;
    font-size: 0.9em;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.sidebar-tab::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    transform: scaleY(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-tab.active {
    background: white;
    font-weight: 400;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sidebar-tab.active[data-sidebar="report"] {
    border-right: 3px solid #4caf50;
}

.sidebar-tab.active[data-sidebar="account"] {
    border-right: 3px solid #2196f3;
}

.sidebar-tab.active[data-sidebar="bi"] {
    border-right: 3px solid #ff9800;
}

.sidebar-tab.active::before {
    transform: scaleY(1);
}

.sidebar-tab.active[data-sidebar="account"]::before {
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
}

.sidebar-tab.active[data-sidebar="bi"]::before {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
}

.sidebar-tab:hover {
    background: #f0f0f0;
    transform: translateX(2px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.sidebar-tab:active {
    transform: translateX(1px) scale(0.98);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
}

.report-list,
.product-list {
    min-height: 100%;
}

/* Treeview Styles */
.treeview {
    font-size: 0.9em;
    color: #333;
}

.tree-item {
    margin: 1px 0;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.tree-item > .tree-children {
    flex-basis: 100%;
}

.tree-item.leaf {
    padding-left: 20px;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.tree-item.leaf::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: scaleY(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tree-item.leaf:hover::before {
    transform: scaleY(1);
}

.tree-item.leaf:hover {
    background: rgba(102, 126, 234, 0.08);
    transform: translateX(4px);
    padding-left: 24px;
}

.tree-item.leaf:active {
    transform: translateX(2px) scale(0.98);
}

.tree-label {
    cursor: pointer;
    padding: 6px 8px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 4px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1.4;
    position: relative;
    z-index: 1;
    font-size: 0.95em;
    flex: 1;
    min-width: 0;
}

/* Icon styling - make emoji/icons larger and more visible */
.tree-label::first-letter,
.tree-label > span:first-child {
    font-size: 1.2em;
    display: inline-block;
    margin-right: 4px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tree-label:hover {
    background: #e8f5e9;
    transform: translateX(4px) scale(1.02);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    padding-left: 12px;
}

.tree-label:hover::first-letter,
.tree-label:hover > span:first-child {
    transform: scale(1.2) rotate(5deg);
}

.tree-item.active > .tree-label,
.tree-item.leaf.active > .tree-label {
    background: #c8e6c9;
    color: #2e7d32;
    font-weight: 400;
}

.tree-toggle {
    display: inline-block;
    width: 16px;
    height: 16px;
    text-align: center;
    line-height: 16px;
    cursor: pointer;
    margin-right: 4px;
    font-weight: 400;
    color: #666;
    user-select: none;
}

.tree-item.expanded > .tree-toggle {
    transform: rotate(0deg);
}

.tree-item.expanded > .tree-toggle::before {
    content: '−';
}

.tree-item:not(.expanded) > .tree-toggle::before {
    content: '+';
}

.tree-children {
    margin-left: 20px;
    display: none;
}

/* หัวข้อย่อยใน sidebar tab Account เยื้องขวาให้เห็นระดับชัดเจน */
#accountList .tree-children {
    margin-left: 24px;
}
#accountList .tree-children .tree-item.leaf,
#accountList .tree-item-sub.tree-item.leaf {
    padding-left: 20px;
}

.tree-item.expanded > .tree-children {
    display: block;
}

.tree-item.leaf {
    padding-left: 18px;
}

.sidebar-footer {
    padding: 6px 12px;
    background: #e8e8e8;
    border-top: 1px solid #d0d0d0;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85em;
    color: #666;
}

/* ความกว้าง sidebar และฟอนต์หลักทั้งหน้า (Sarabun/Prompt โหลดจาก Google Fonts) */
:root {
    --sidebar-width: 250px;
    --font-primary: 'Sarabun', 'Prompt', 'Segoe UI', 'Tahoma', sans-serif;
}

/* Main Content - หักความกว้าง sidebar เพื่อให้ตารางพอดี */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fafafa;
    padding: 12px;
    min-width: 0; /* Allows flex item to shrink below content size */
    max-width: calc(100% - var(--sidebar-width)); /* พอดีเมื่อ sidebar แสดง (100% = ความกว้าง main-layout) */
}

/* เมื่อซ่อน sidebar ให้พื้นที่รายงานเต็มความกว้าง */
.main-layout .sidebar.hidden ~ .main-content {
    max-width: 100%;
}

.controls {
    display: flex;
    gap: 20px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-weight: 400;
    color: #555;
    font-size: 0.9em;
}

.filter-group select {
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-group select:hover {
    border-color: #667eea;
}

.filter-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-primary {
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.3);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:active::before {
    width: 400px;
    height: 400px;
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);
}

.btn-primary:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

/* General button styles for inline buttons */
button[onclick] {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

button[onclick]:not(.btn-toggle-sidebar):not(.nav-btn):not(.btn-today):not(.btn-primary)::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
    z-index: 0;
}

button[onclick]:not(.btn-toggle-sidebar):not(.nav-btn):not(.btn-today):not(.btn-primary):active::before {
    width: 300px;
    height: 300px;
}

button[onclick]:not(.btn-toggle-sidebar):not(.nav-btn):not(.btn-today):not(.btn-primary):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

button[onclick]:not(.btn-toggle-sidebar):not(.nav-btn):not(.btn-today):not(.btn-primary):active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Selector buttons */
#branchSelectBtn, #typeSelectBtn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative;
    overflow: hidden;
}

#branchSelectBtn::before, #typeSelectBtn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
    z-index: 0;
}

#branchSelectBtn:active::before, #typeSelectBtn:active::before {
    width: 300px;
    height: 300px;
}

#branchSelectBtn:hover, #typeSelectBtn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    border-color: #667eea !important;
}

#branchSelectBtn:active, #typeSelectBtn:active {
    transform: translateY(0) scale(0.98) !important;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card:hover {
    transform: translateY(-8px) scale(1.03);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.stat-value {
    font-size: 2.5em;
    font-weight: 400;
    color: #667eea;
    margin-bottom: 10px;
}

.stat-label {
    font-size: 1em;
    color: #666;
    font-weight: 400;
}

.reports-container {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-width: 0;
    max-width: 100%;
    width: 100%;
    overflow-x: auto;
    box-sizing: border-box;
}

.reports-list {
    display: grid;
    gap: 12px;
    min-width: 0;
    max-width: 100%;
}

.report-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.report-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    transition: left 0.5s;
}

.report-card:hover::before {
    left: 100%;
}

.report-card:hover {
    border-color: #667eea;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.25);
    transform: none;
}

.report-card:active {
    transform: none;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

/* BI Dashboard - แถวสาขาคลิกได้ (ไม่โหลดใหม่) */
.bi-dashboard .bi-row-clickable {
    cursor: pointer;
}
.bi-dashboard .bi-row-clickable:hover {
    background: #e3f2fd;
}
.bi-dashboard .bi-table tfoot .total-row {
    font-weight: 700;
    background: #f5f5f5;
}
.bi-dashboard .bi-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 6px;
    background: #2196F3;
    color: white;
    border-radius: 3px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    line-height: 1;
    vertical-align: middle;
}
.bi-dashboard .bi-toggle:hover {
    background: #1976D2;
}
.bi-dashboard .bi-toggle-empty {
    background: transparent;
    color: #999;
    cursor: default;
}
.bi-dashboard .bi-row-level-2 {
    background: #fafafa;
}
.bi-dashboard .bi-row-level-3 {
    background: #f5f5f5;
}
.bi-dashboard .bi-row-level-4 {
    background: #f0f0f0;
}

/* BI table: horizontal bar for ยอดขาย column (ไม่มีสีเทา, ตัวเลขทับบนพื้นที่แถบได้) */
.bi-dashboard .bi-td-bar {
    min-width: 140px !important;
}
.bi-dashboard .bi-cell-bar {
    position: relative;
    display: block;
    width: 100%;
    min-height: 20px;
}
.bi-dashboard .bi-bar-track {
    display: block;
    height: 14px;
    position: relative;
    overflow: visible;
    border-radius: 4px;
}
.bi-dashboard .bi-bar-fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #43A047, #66BB6A);
    border-radius: 3px;
    transition: width 0.2s ease;
}
.bi-dashboard .bi-bar-value {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    text-align: right;
    z-index: 1;
    text-shadow: 0 0 2px #fff, 0 0 4px #fff;
}

/* BI table - อยู่ในกรอบ อ่านได้ไม่ตกหล่น จัดอัตราส่วนความกว้าง column */
.bi-dashboard .table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.bi-dashboard .bi-table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.9em;
}
.bi-dashboard .bi-table th:nth-child(1),
.bi-dashboard .bi-table td:nth-child(1) {
    width: 2.5%;
    max-width: 48px;
    min-width: 0;
    text-align: center;
    white-space: nowrap;
}
.bi-dashboard .bi-table th:nth-child(2),
.bi-dashboard .bi-table td:nth-child(2) {
    width: 24%;
    min-width: 0;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}
.bi-dashboard .bi-table th:nth-child(3),
.bi-dashboard .bi-table td:nth-child(3) { width: 10%; min-width: 0; text-align: right; white-space: nowrap; }
.bi-dashboard .bi-table th:nth-child(4),
.bi-dashboard .bi-table td:nth-child(4) { width: 9%; min-width: 0; text-align: right; white-space: nowrap; }
.bi-dashboard .bi-table th:nth-child(5),
.bi-dashboard .bi-table td:nth-child(5) { width: 9%; min-width: 0; text-align: right; white-space: nowrap; }
.bi-dashboard .bi-table th:nth-child(6),
.bi-dashboard .bi-table td:nth-child(6) { width: 9%; min-width: 0; text-align: right; white-space: nowrap; }
.bi-dashboard .bi-table th:nth-child(7),
.bi-dashboard .bi-table td:nth-child(7) { width: 12%; min-width: 0; text-align: right; white-space: nowrap; }
.bi-dashboard .bi-table th:nth-child(8),
.bi-dashboard .bi-table td:nth-child(8) { width: 12%; min-width: 0; text-align: right; white-space: nowrap; }
.bi-dashboard .bi-table th:nth-child(9),
.bi-dashboard .bi-table td:nth-child(9) { width: 11%; min-width: 0; text-align: right; white-space: nowrap; }
.bi-dashboard .bi-table th:nth-child(n+3),
.bi-dashboard .bi-table td:nth-child(n+3) {
    font-variant-numeric: tabular-nums;
}
.bi-dashboard .bi-table .bi-td-bar {
    min-width: 0;
}
/* ตาราง BI 3 คอลัมน์ (ค่าใช้จ่าย/รายได้): col3 ใช้พื้นที่ที่เหลือ */
.bi-dashboard .bi-table th:nth-child(3):last-child,
.bi-dashboard .bi-table td:nth-child(3):last-child {
    width: 72%;
}
.bi-dashboard .bi-table th,
.bi-dashboard .bi-table td {
    padding: 6px 8px;
    box-sizing: border-box;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.report-title {
    font-size: 1.4em;
    font-weight: 400;
    color: #333;
    margin-bottom: 3px;
    line-height: 1.2;
}

.report-type {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 400;
    margin-top: 3px;
    line-height: 1.3;
}

.report-type.sales {
    background: #e3f2fd;
    color: #1976d2;
}

.report-type.finance {
    background: #f1f8e9;
    color: #388e3c;
}

.report-type.inventory {
    background: #fff3e0;
    color: #f57c00;
}

.report-type.marketing {
    background: #fce4ec;
    color: #c2185b;
}

.report-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 400;
    line-height: 1.3;
}

.report-status.active {
    background: #4caf50;
    color: white;
}

.report-status.completed {
    background: #2196f3;
    color: white;
}

.report-status.pending {
    background: #ff9800;
    color: white;
}

.report-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.report-detail-item {
    display: flex;
    flex-direction: column;
}

.report-detail-label {
    font-size: 0.9em;
    color: #888;
    margin-bottom: 2px;
    line-height: 1.2;
}

.report-detail-value {
    font-size: 1.1em;
    font-weight: 400;
    color: #333;
    line-height: 1.3;
}

.report-description {
    margin-top: 10px;
    color: #666;
    line-height: 1.3;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.empty-state-icon {
    font-size: 4em;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
    display: inline-block;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.empty-state-text {
    font-size: 1.2em;
    animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

.empty-state-text h3 {
    margin-bottom: 10px;
    color: #333;
}

.empty-state-text p {
    line-height: 1.6;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
}

/* Tablet Styles */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    
    .main-content {
        padding: 15px;
    }
    
    .filter-row {
        gap: 10px;
    }
    
    .filter-item select,
    .filter-item input[type="date"] {
        max-width: 130px;
    }
    
    .report-summary {
        gap: 20px;
    }
    
    .sales-table {
        font-size: 0.9em;
    }
    
    .sales-table th,
    .sales-table td {
        padding: 6px 8px;
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 999;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.mobile-hidden {
        transform: translateX(-100%);
    }
    
    .main-layout {
        position: relative;
    }
    
    .main-content {
        width: 100%;
        padding: 10px;
        margin-left: 0;
    }
    
    .top-filter-bar {
        padding: 6px 8px;
        padding-left: 50px;
    }

    .filter-row {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .filter-item {
        flex: 0 1 auto;
        min-width: 140px;
        max-width: calc(50% - 4px);
        flex-direction: row;
        align-items: center;
        gap: 5px;
        flex-wrap: nowrap;
    }
    
    /* Full width for items with controls */
    .filter-item:has(.filter-controls) {
        min-width: 100%;
        max-width: 100%;
    }
    
    .filter-item label {
        font-size: 0.85em;
        white-space: nowrap;
        min-width: fit-content;
        flex-shrink: 0;
        padding-right: 2px;
    }

    .filter-item select,
    .filter-item input[type="date"] {
        flex: 1;
        min-width: 0;
        padding: 4px 6px;
        font-size: 0.85em;
    }
    
    .filter-controls {
        justify-content: center;
        flex-wrap: nowrap;
        gap: 3px;
    }
    
    .nav-btn {
        padding: 4px 6px;
        font-size: 0.9em;
    }
    
    #pageNumber {
        padding: 0 5px;
        font-size: 0.9em;
    }
    
    .btn-today {
        padding: 6px 12px;
        font-size: 0.85em;
        margin-left: 5px;
        margin-top: 0;
        white-space: nowrap;
    }
    
    /* Special handling for filter-item with controls */
    .filter-item:has(.filter-controls) {
        flex-wrap: wrap;
    }
    
    .filter-item:has(.filter-controls) .filter-controls {
        width: 100%;
        margin-top: 5px;
    }
    
    .filter-item:has(.filter-controls) .btn-today {
        width: 100%;
        margin-left: 0;
        margin-top: 5px;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
    }

    .filter-group {
        width: 100%;
    }

    .btn-primary {
        width: 100%;
        margin-top: 0;
    }

    .stats {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .report-header {
        flex-direction: column;
        gap: 10px;
    }

    .sidebar-tabs {
        flex-direction: row;
    }

    .sidebar-tab {
        padding: 10px 15px;
    }
    
    .sales-report-container {
        padding: 15px;
    }
    
    .report-header-section h2 {
        font-size: 1.2em;
    }
    
    .report-date-range {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .report-summary {
        flex-direction: column;
        gap: 15px;
    }
    
    .summary-value {
        font-size: 1.1em;
    }
    
    .table-container {
        margin: 0 -15px;
        padding: 0 15px;
    }
    
    .table-container table {
        min-width: 600px;
    }
    
    
    /* Chart responsive */
    .sales-report-container canvas {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* Grid layouts for charts */
    .sales-report-container > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
}

/* Small Mobile Styles */
@media (max-width: 480px) {
    .top-filter-bar {
        padding: 5px 8px;
        padding-left: 45px;
    }
    
    .filter-row {
        gap: 5px;
    }
    
    .filter-item label {
        font-size: 0.85em;
    }
    
    .filter-item select,
    .filter-item input[type="date"] {
        padding: 4px 6px;
        font-size: 0.85em;
    }
    
    .main-content {
        padding: 8px;
    }
    
    .sales-report-container {
        padding: 10px;
    }
    
    .report-header-section h2 {
        font-size: 1.1em;
    }
    
    .sales-table {
        font-size: 0.75em;
    }
    
    .sales-table th,
    .sales-table td {
        padding: 6px 8px;
    }
    
    .table-container table {
        min-width: 500px;
    }
    
    
    .empty-state-icon {
        font-size: 3em;
    }
    
    .empty-state-text {
        font-size: 1em;
    }
    
    .stat-value {
        font-size: 2em;
    }
    
    .report-title {
        font-size: 1.2em;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 200px;
    }
    
    .main-content {
        padding: 15px;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .top-filter-bar,
    .mobile-menu-toggle {
        display: none;
    }
    
    .main-content {
        width: 100%;
        padding: 0;
    }
    
    .sales-table {
        font-size: 0.85em;
    }
    
    .sales-report-container {
        box-shadow: none;
        page-break-inside: avoid;
    }
}

/* Sales Report Table Styles */
.sales-report-container {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
}

/* บังคับให้กราฟอยู่ด้านล่างเสมอ */
.charts-container {
    order: 999 !important;
    margin-top: 30px !important;
}

.sales-report-container .table-container {
    order: 2;
}

.sales-report-container .report-header-section {
    order: 0;
}

.sales-report-container .tabs-row {
    order: 1;
    margin-top: 10px;
    margin-bottom: 0;
}

.sales-report-container .tab-content {
    order: 2;
}

.report-header-section {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.report-header-section .tabs-row {
    margin-top: 15px;
    margin-bottom: 0;
}

.report-header-section h2 {
    color: #333;
    margin-bottom: 6px;
    font-size: 1.2em;
    font-weight: 400;
    line-height: 1.2;
}

.report-date-range {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 5px 8px;
    background: #f5f5f5;
    border-radius: 6px;
    font-size: 0.9em;
    line-height: 1.3;
}

.date-label {
    color: #666;
    font-weight: 400;
}

.date-value {
    color: #333;
    font-weight: 400;
    padding: 4px 10px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.date-separator {
    color: #999;
    margin: 0 5px;
}

.report-summary {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding: 12px 0;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 15px;
}

.summary-item {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
    min-width: 150px;
}

.summary-label {
    font-size: 0.9em;
    color: #666;
    line-height: 1.2;
    font-weight: 400;
    white-space: nowrap;
}

.summary-value {
    font-size: 1.2em;
    font-weight: 400;
    color: #4caf50;
    line-height: 1.2;
    text-align: right;
    min-width: 120px;
    font-variant-numeric: tabular-nums; /* Use tabular numbers for better alignment */
}

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -20px;
    padding: 0 20px;
    position: relative;
}

.table-container table {
    min-width: 800px;
    width: 100%;
}

/* ตารางทุกตารางใน POS / report area ให้พอดีความกว้าง report-container */
.reports-list .table-container,
.sales-report-container .table-container {
    width: 100%;
    max-width: 100%;
}

.reports-list .table-container table,
.sales-report-container .table-container table {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    table-layout: auto;
}

.reports-list .table-container table thead th,
.reports-list .table-container table td,
.sales-report-container .table-container table thead th,
.sales-report-container .table-container table td {
    box-sizing: border-box;
}

/* ตารางยอดขายแยกสาขา - ปรับขนาดพอดีความกว้าง */
.table-container--fit {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-container--fit .sales-table--fit {
    table-layout: fixed;
    width: 100%;
    min-width: 0; /* ลบล้าง min-width: 800px ของ .table-container table */
    font-size: 0.9em;
}

.table-container--fit .sales-table--fit thead th {
    padding: 6px 6px;
    font-size: 0.95em;
}

.table-container--fit .sales-table--fit tbody td,
.table-container--fit .sales-table--fit tfoot td {
    padding: 5px 6px;
}

/* แถวหลัก (สาขา) = สีขาว, แถวรอง (ลูกค้า 1–20) = เทาอ่อน + ชื่อเยื้องขวา */
#table-sales-by-branch .branch-main-row {
    background: #ffffff !important;
    font-weight: 500;
}
#table-sales-by-branch .branch-main-row .branch-name-cell {
    color: #1565c0;
}
#table-sales-by-branch .branch-main-row td {
    border-bottom: 1px solid #e0e0e0;
}
#table-sales-by-branch .branch-detail-data-row {
    background: #f0f0f0 !important;
}
#table-sales-by-branch .branch-detail-data-row td {
    font-size: 0.9em;
    color: #424242;
    border-bottom: 1px solid #e8e8e8;
}
#table-sales-by-branch .branch-detail-label {
    color: #424242;
    font-weight: 400;
    padding-left: 40px !important;
}

/* ส่วนขยายแบบรายงาน (ไอคอนสามเหลี่ยม ▶/▼ อยู่หน้า ชื่อสาขา) */
.branch-name-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    border-right: none !important;
}
.branch-expand-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    color: #757575;
    cursor: pointer;
    font-size: 0.7em;
    user-select: none;
    transition: color 0.15s;
}
.branch-expand-icon:hover {
    color: #424242;
}
.branch-expand-icon:focus {
    outline: 1px dotted #757575;
    outline-offset: 1px;
}
.branch-expand-placeholder {
    color: #bdbdbd;
    font-size: 0.9em;
}
/* แถวรอง (ลูกค้า) — เยื้องขวา ให้รู้ว่าเป็นข้อมูลที่ขยายมาจากสาขา (ใช้ 40px ในตารางยอดขายแยกสาขา) */
.branch-detail-label {
    padding-left: 28px !important;
}

/* ลำดับ + ชื่อสาขา (ไอคอน ▶ + ชื่อ) ให้ดูเป็น field เดียว — ไม่มีเส้นกั้นระหว่างสองคอลัมน์ */
.table-container--fit .sales-table--fit th:nth-child(1),
.table-container--fit .sales-table--fit td:nth-child(1) { width: 2.5%; min-width: 0; border-right: none !important; }
.table-container--fit .sales-table--fit th:nth-child(2),
.table-container--fit .sales-table--fit td:nth-child(2) { width: 23.5%; min-width: 120px; border-left: none !important; border-right: none !important; }
.table-container--fit .sales-table--fit th:nth-child(3),
.table-container--fit .sales-table--fit td:nth-child(3) { width: 8%; border-left: none !important; }
.table-container--fit .sales-table--fit th:nth-child(4),
.table-container--fit .sales-table--fit td:nth-child(4) { width: 5%; }
.table-container--fit .sales-table--fit th:nth-child(5),
.table-container--fit .sales-table--fit td:nth-child(5) { width: 6%; }
.table-container--fit .sales-table--fit th:nth-child(6),
.table-container--fit .sales-table--fit td:nth-child(6) { width: 6%; }
.table-container--fit .sales-table--fit th:nth-child(7),
.table-container--fit .sales-table--fit td:nth-child(7) { width: 6%; }
.table-container--fit .sales-table--fit th:nth-child(8),
.table-container--fit .sales-table--fit td:nth-child(8) { width: 6%; }
.table-container--fit .sales-table--fit th:nth-child(9),
.table-container--fit .sales-table--fit td:nth-child(9) { width: 7%; }
.table-container--fit .sales-table--fit th:nth-child(10),
.table-container--fit .sales-table--fit td:nth-child(10) { width: 7%; }
.table-container--fit .sales-table--fit th:nth-child(11),
.table-container--fit .sales-table--fit td:nth-child(11) { width: 7%; }
.table-container--fit .sales-table--fit th:nth-child(12),
.table-container--fit .sales-table--fit td:nth-child(12) { width: 8%; }

/* ชื่อสาขาแสดงเต็มบรรทัด (ไม่ขึ้นหลายบรรทัด ไม่มีเส้นคั่นขวา) */
.table-container--fit .sales-table--fit th:nth-child(2),
.table-container--fit .sales-table--fit td:nth-child(2) {
    white-space: nowrap;
}

/* ตัวเลขในตาราง fit จัดขวา แบบย่อได้ในจอเล็ก */
.table-container--fit .sales-table--fit td.text-right {
    font-variant-numeric: tabular-nums;
}

/* Ensure consistent alignment across all table elements */
.sales-table th,
.sales-table td {
    box-sizing: border-box;
    vertical-align: middle;
}

/* Align numeric columns consistently - STRONG override for headers */
.sales-table thead th.text-right {
    text-align: right !important;
    padding-right: 12px !important;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.sales-table tbody td.text-right,
.sales-table tfoot td.text-right {
    text-align: right !important;
    padding-right: 12px !important;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Ensure all numeric headers are right-aligned */
.sales-table th[style*="text-align: right"],
.sales-table th[style*="text-align:right"] {
    text-align: right !important;
    padding-right: 12px !important;
}

.sales-table th.text-center,
.sales-table td.text-center {
    text-align: center !important;
}

.sales-table th.text-left,
.sales-table td.text-left {
    text-align: left !important;
    padding-left: 10px;
}

/* Ensure header and data cells have same padding for alignment */
.sales-table thead th {
    padding: 8px 10px;
}

.sales-table tbody td {
    padding: 6px 10px;
}

.sales-table tfoot td {
    padding: 10px;
}

/* Ensure summary aligns with table columns */
.report-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 10px;
    padding: 12px 0;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 15px;
    align-items: baseline;
}

.summary-item {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
}

.summary-label {
    font-size: 0.9em;
    color: #666;
    line-height: 1.2;
    font-weight: 400;
    white-space: nowrap;
    flex-shrink: 0;
}

.summary-value {
    font-size: 1.2em;
    font-weight: 400;
    color: #4caf50;
    line-height: 1.2;
    text-align: right;
    flex: 1;
    font-variant-numeric: tabular-nums;
    min-width: 0;
}


.sales-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    table-layout: fixed; /* Fixed layout for consistent column widths */
    border: 1px solid #d0d0d0;
    background: white;
    font-family: 'Sarabun', 'Prompt', 'Kanit', sans-serif;
}

/* รายงานรายเดือนแยกสาขา: ตัวอักษรใหญ่ขึ้น +2px */
.branch-monthly-report {
    font-size: 18px;
}
.branch-monthly-report .sales-table,
.branch-monthly-report .table-container {
    font-size: 1em;
}

/* Column resizing properties are in .sales-table th above */

.sales-table thead {
    background: #4472C4; /* Excel header blue color */
    color: white;
}

.sales-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 400;
    border: 1px solid #8FAADC; /* Excel header border */
    font-size: 0.95em;
    line-height: 1.5;
    vertical-align: middle;
    background: #4472C4 !important; /* Excel header background */
    color: white !important;
    position: relative;
    user-select: none;
    min-width: 50px; /* Minimum column width */
    max-width: none;
    font-family: 'Sarabun', 'Prompt', 'Kanit', sans-serif;
}

/* Resize handle for Excel-like column resizing */

.sales-table th .resize-handle {
    position: absolute;
    top: 0;
    right: -2px;
    width: 5px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
    transition: background 0.2s;
    touch-action: none;
}

.sales-table th .resize-handle:hover {
    background: rgba(255, 255, 255, 0.4);
    width: 7px;
    right: -3px;
}

.sales-table th.resizing .resize-handle {
    background: rgba(255, 255, 255, 0.6);
    width: 7px;
    right: -3px;
}

.sales-table.resizing {
    user-select: none;
    cursor: col-resize !important;
}

.sales-table.resizing * {
    cursor: col-resize !important;
}

.sales-table.resizing tbody tr:hover {
    background: inherit !important;
}

/* Force right alignment for numeric column headers - handled by JavaScript fixTableHeaderAlignment() */

.sales-table th:first-child {
    text-align: center;
    width: 60px;
    min-width: 60px;
    background: #4472C4 !important;
    color: white !important;
    border: 1px solid #8FAADC !important;
}

/* CRITICAL: Right-align headers for numeric columns - must override default left alignment */
.sales-table th.text-right {
    text-align: right !important;
    padding-right: 12px !important;
    font-variant-numeric: tabular-nums;
    background: #4472C4 !important;
    color: white !important;
    border: 1px solid #8FAADC !important;
}

/* Auto-detect numeric column headers by content */
.sales-table th:has-text("บาท"),
.sales-table th:has-text("(%)"),
.sales-table th:has-text("จำนวนบิล"),
.sales-table th:has-text("ยอดรวม"),
.sales-table th:has-text("ยอดขาย"),
.sales-table th:has-text("ยอดเฉลี่ย"),
.sales-table th:has-text("เฉลี่ย"),
.sales-table th:has-text("กำไร"),
.sales-table th:has-text("ภาษี"),
.sales-table th:has-text("ยอดชำระ"),
.sales-table th:has-text("ยอดค้าง"),
.sales-table th:has-text("ยอดเกิน"),
.sales-table th:has-text("ยอดสินค้า") {
    text-align: right !important;
    padding-right: 12px !important;
}

/* Better approach: Use attribute selector for headers containing specific text patterns */
.sales-table th[style*="text-right"],
.sales-table th:contains("บาท"),
.sales-table th:contains("(%)"),
.sales-table th:contains("จำนวนบิล"),
.sales-table th:contains("ยอดรวม"),
.sales-table th:contains("ยอดขาย"),
.sales-table th:contains("ยอดเฉลี่ย"),
.sales-table th:contains("เฉลี่ย"),
.sales-table th:contains("กำไร"),
.sales-table th:contains("ภาษี"),
.sales-table th:contains("ยอดชำระ"),
.sales-table th:contains("ยอดค้าง"),
.sales-table th:contains("ยอดเกิน"),
.sales-table th:contains("ยอดสินค้า") {
    text-align: right !important;
    padding-right: 12px !important;
}

.sales-table td.text-right {
    text-align: right !important;
    padding-right: 12px !important;
    font-variant-numeric: tabular-nums;
}

.sales-table td {
    padding: 8px 12px;
    border: 1px solid #d0d0d0; /* Excel cell border */
    font-size: 0.9em;
    line-height: 1.6;
    vertical-align: middle;
    word-wrap: break-word;
    overflow-wrap: break-word;
    background: white !important;
    font-family: 'Sarabun', 'Prompt', 'Kanit', sans-serif;
    color: #000 !important; /* ตัวหนังสือสีดำ */
}

.sales-table tbody tr {
    background: white !important;
}

.sales-table tbody tr:nth-child(even) {
    background: #F2F2F2 !important; /* Excel alternating row color */
}

.sales-table tbody tr:hover {
    background: #E7F3FF !important; /* Excel hover color */
}

.sales-table tbody tr:nth-child(even):hover {
    background: #D9E8F5 !important; /* Excel hover color for even rows */
}

/* ตารางยอดขายแยกสาขา: แถวหลักสีขาว แถวรองเทาอ่อน (override ต้องอยู่หลัง .sales-table tbody tr และ .sales-table td) */
#table-sales-by-branch table.sales-table tbody tr.branch-main-row {
    background: #ffffff !important;
}
#table-sales-by-branch table.sales-table tbody tr.branch-main-row td {
    border-bottom: 1px solid #e0e0e0;
    background: #ffffff !important; /* ชนะ .sales-table td */
}
#table-sales-by-branch table.sales-table tbody tr.branch-main-row .branch-name-cell {
    color: #1565c0 !important; /* ชนะ .sales-table td { color: #000 !important } */
}
#table-sales-by-branch table.sales-table tbody tr.branch-detail-data-row,
#table-sales-by-branch table.sales-table tbody tr.branch-detail-data-row:nth-child(odd),
#table-sales-by-branch table.sales-table tbody tr.branch-detail-data-row:nth-child(even) {
    background: #f0f0f0 !important; /* ทุกแถวรองเทาอ่อน ไม่สลับขาว-เทา */
}
#table-sales-by-branch table.sales-table tbody tr.branch-detail-data-row td {
    font-size: 0.9em !important;
    color: #424242 !important; /* ชนะ .sales-table td */
    border-bottom: 1px solid #e8e8e8;
    background: #f0f0f0 !important; /* เซลล์เทาอ่อนด้วย ชนะ .sales-table td */
}
#table-sales-by-branch table.sales-table tbody tr.branch-detail-data-row .branch-detail-label {
    color: #424242 !important;
    padding-left: 40px !important;
}
#table-sales-by-branch table.sales-table tbody tr.branch-detail-data-row:hover {
    background: #ebebeb !important;
}
#table-sales-by-branch table.sales-table tbody tr.branch-detail-data-row:hover td {
    background: #ebebeb !important;
}
#table-sales-by-branch table.sales-table tbody tr.branch-main-row:hover {
    background: #f8f9fa !important;
}
#table-sales-by-branch table.sales-table tbody tr.branch-main-row:hover td {
    background: #f8f9fa !important;
}

.sales-table .text-right {
    text-align: right;
}

.sales-table tfoot {
    background: #D9E1F2; /* Excel total row background */
    font-weight: 400;
}

.sales-table .total-row {
    background: #D9E1F2 !important; /* Excel total row background */
    color: #000 !important;
    font-weight: 400;
}

.sales-table .total-row td {
    padding: 10px;
    border: 1px solid #8FAADC !important; /* Excel total row border */
    line-height: 1.3;
    font-weight: 400;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
    background: #D9E1F2 !important;
}

.sales-table .total-row td.text-right {
    text-align: right !important;
    padding-right: 12px !important;
}

/* Fix alignment for total row with colspan */
.sales-table .total-row td[colspan] {
    text-align: left;
}

/* ตารางวิเคราะห์ ABC — ความกว้างคอลัมน์เท่ากันทุกคอลัมน์ (13 คอลัมน์) */
#abcAnalysisTable {
    table-layout: fixed;
    width: 100%;
}
#abcAnalysisTable thead th {
    width: 7.69%; /* 100% / 13 */
    box-sizing: border-box;
}

.sales-table .total-row td[colspan].text-right {
    text-align: right !important;
}

/* แถว ค่าใช้จ่ายสาขาอื่นๆ และ กำไรสุทธิ (รายเดือนแยกสาขา) - ไม่ตัวหนา สีตามที่กำหนด */
.sales-table .branch-other-expense-row,
.sales-table .branch-net-profit-row {
    font-weight: 400 !important;
    background: #e3f2fd !important;
}
.sales-table .branch-net-profit-row {
    background: #e8f5e9 !important;
}
.sales-table .branch-other-expense-row td,
.sales-table .branch-net-profit-row td {
    font-weight: 400 !important;
    border: 1px solid #8FAADC !important;
    padding: 8px 10px;
    vertical-align: middle;
}
.sales-table .branch-other-expense-row td.branch-footer-label,
.sales-table .branch-other-expense-row td.branch-footer-cell {
    color: #1565c0 !important;
}
.sales-table .branch-net-profit-row td.branch-footer-label {
    color: #000 !important;
}
.sales-table .branch-net-profit-row td.branch-footer-cell {
    font-weight: 400 !important;
}

/* Ensure consistent column widths */
.sales-table {
    border-spacing: 0;
}

/* Fix for tables with varying column counts */
.sales-table tbody tr td,
.sales-table tfoot tr td {
    vertical-align: middle;
}

/* Better alignment for summary values to match table columns */
.report-summary .summary-value {
    font-family: 'Sarabun', 'Prompt', 'Kanit', sans-serif;
    letter-spacing: 0.3px;
    font-weight: 400;
}

.sales-table .subtotal-row {
    background: #E2EFDA !important; /* Excel subtotal row background (light green) */
    font-weight: 400;
    color: #000 !important;
}

.sales-table .subtotal-row td {
    padding: 8px 10px;
    border: 1px solid #8FAADC !important; /* Excel border */
    line-height: 1.3;
    background: #E2EFDA !important;
}

.sales-table .subtotal-row td.text-right {
    text-align: right !important;
    padding-right: 12px !important;
}

/* Type header row (for grouped reports like profit by brand) */
.sales-table .type-header-row {
    background: #D9E1F2 !important; /* Excel header-like background */
    font-weight: 400;
    color: #000 !important;
}

.sales-table .type-header-row td {
    background: #D9E1F2 !important;
    border: 1px solid #8FAADC !important;
    padding: 8px 15px;
}

/* Department header row (e.g. ฝ่ายผลิต) - no highlight, font +2 */
.sales-table .dept-header-row {
    background: transparent !important;
    font-weight: 400;
    color: #000 !important;
}

.sales-table .dept-header-row td {
    background: transparent !important;
    border: 1px solid #ddd !important;
    padding: 8px 15px;
}

/* Tree table alignment helpers */
.sales-table .tree-cell {
    text-align: left;
}
/* หัวข้อรอง (เช่น รายได้จากการขายสุกรขุน) เยื้องขวาให้เห็นว่าเป็นลูกของ รายได้/ต้นทุนขาย/ค่าใช้จ่าย */
.sales-table tr.profit-type-row .tree-cell {
    padding-left: 28px;
}
.sales-table tr.profit-detail-row .tree-cell {
    padding-left: 48px;
}
.sales-table .toggle-spacer {
    display: inline-block;
    width: 18px;
    margin-right: 6px;
}

/* Info box for report formula/source */
.report-info-box {
    margin-top: 10px;
    padding: 12px 14px;
    background: #f1f8e9;
    border: 1px solid #c5e1a5;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #1b5e20;
}
.report-info-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.4;
}
.report-info-icon {
    font-size: 1.05em;
    margin-top: 1px;
}
.report-info-label {
    font-weight: 600;
    white-space: nowrap;
}
.report-info-text {
    color: #2e7d32;
}

/* Light green box for bill/customer/sales per bill */
.branch-count-box {
    margin-top: 6px;
    padding: 4px 6px;
    border: 1px solid #c5e1a5;
    background: #f1f8e9;
    border-radius: 4px;
    display: block;
    width: 100%;
    box-sizing: border-box;
    color: #000;
}

/* Detail rows - use dark gray text for readability */
.sales-table tr.expense-type-detail td,
.sales-table tr.branch-type-detail td {
    color: #8b0000 !important;
}

/* Toggle button for expense type detail (รายเดือนค่าใช้จ่าย ตามหน่วยงาน) */
.expense-type-toggle {
    cursor: pointer;
    display: inline-block;
    min-width: 18px;
    height: 18px;
    line-height: 16px;
    text-align: center;
    font-size: 11px;
    border: 1px solid #8FAADC;
    border-radius: 3px;
    margin-right: 6px;
    user-select: none;
    color: #333;
    background: #f5f5f5;
    transition: background 0.2s, color 0.2s;
}
.expense-type-toggle:hover {
    background: #e3f2fd;
    color: #1976d2;
}

/* Product name column - responsive width - adjusts first before other columns */
.profit-all-table {
    table-layout: auto;
}

/* คอลัมน์อื่นๆ มี fixed width เพื่อให้คอลัมน์รายการสินค้าปรับขนาดได้ก่อน */
.profit-all-table th:not(.product-name-column),
.profit-all-table td:not(.product-name-column) {
    width: auto;
    min-width: fit-content;
}

.profit-all-table .product-name-column {
    width: 100% !important;
    min-width: 80px;
    max-width: none !important;
}

@media (min-width: 1600px) {
    .profit-all-table .product-name-column {
        min-width: 200px;
    }
}

@media (min-width: 1400px) {
    .profit-all-table .product-name-column {
        min-width: 150px;
    }
}

@media (max-width: 1200px) {
    .profit-all-table .product-name-column {
        min-width: 120px;
    }
}

@media (max-width: 1000px) {
    .profit-all-table .product-name-column {
        min-width: 100px;
    }
}

@media (max-width: 900px) {
    .profit-all-table .product-name-column {
        min-width: 80px;
    }
}

@media (max-width: 768px) {
    .sales-table {
        font-size: 0.9em;
    }
    
    .sales-table th,
    .sales-table td {
        padding: 5px 7px;
    }
    
    .profit-all-table .product-name-column {
        min-width: 60px;
        max-width: none !important;
    }
    
    .report-summary {
        flex-direction: column;
        gap: 15px;
    }
    
    /* Overlay for mobile menu */
    .sidebar:not(.mobile-hidden)::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
        pointer-events: none;
    }
}

/* AI Modal Styles */
.ai-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ai-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.ai-modal-content {
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    z-index: 10000;
}

.ai-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f5f5f5;
    border-radius: 8px 8px 0 0;
}

.ai-modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.3em;
    font-weight: 400;
}

.ai-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.ai-modal-close:hover {
    background: #e0e0e0;
    color: #333;
}

.ai-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    min-height: 200px;
    max-height: calc(90vh - 140px);
}

.ai-modal-body #aiModalContent {
    padding: 20px;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
    color: #333;
    font-size: 0.95em;
}

.ai-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
    border-radius: 0 0 8px 8px;
    display: flex;
    justify-content: flex-end;
}

/* ========== จัดการข้อมูลบัญชี Modal (เหมือนโปรเจกต์ account) ========== */
.data-manage-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.data-manage-modal[style*="display: flex"],
.data-manage-modal[style*="display:flex"] {
    display: flex !important;
}

.data-manage-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.data-manage-content {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    z-index: 10001;
}

.data-manage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 2px solid #e0e0e0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px 12px 0 0;
}

.data-manage-header h3 {
    margin: 0;
    color: white;
    font-size: 1.3em;
    font-weight: 600;
}

.data-manage-close {
    background: none;
    border: none;
    font-size: 32px;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
    line-height: 1;
}

.data-manage-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.data-manage-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    min-height: 200px;
    max-height: calc(90vh - 180px);
}

.data-manage-item {
    margin-bottom: 20px;
}

.data-manage-item label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.data-manage-item input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.data-manage-item input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.data-manage-item input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.data-manage-hint {
    display: block;
    font-size: 0.85em;
    color: #999;
    margin-top: 4px;
}

.data-manage-info {
    margin-top: 24px;
    padding: 16px;
    background: #f5f7fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.data-manage-info p {
    margin: 0 0 8px 0;
    font-weight: 600;
    color: #333;
}

.data-manage-info ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.data-manage-info li {
    margin-bottom: 6px;
    color: #666;
    line-height: 1.5;
}

/* Data Status Section */
.data-status-section {
    margin-bottom: 24px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.data-status-section h4 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 1.1em;
    font-weight: 600;
}

.data-status-info {
    margin-bottom: 12px;
}

.data-status-loading,
.data-status-exists,
.data-status-not-exists,
.data-status-success,
.data-status-error,
.data-status-ok {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 6px;
}

.data-status-loading {
    background: #e3f2fd;
    color: #1976d2;
}

.data-status-exists {
    background: #e8f5e9;
    color: #2e7d32;
}

.data-status-not-exists {
    background: #fff3e0;
    color: #f57c00;
}

.data-status-success {
    background: #e8f5e9;
    color: #2e7d32;
}

.data-status-ok {
    background: #e8f5e9;
    color: #2e7d32;
}

.data-status-error {
    background: #ffebee;
    color: #c62828;
}

.status-icon {
    font-size: 1.5em;
    flex-shrink: 0;
}

.status-text {
    flex: 1;
}

.data-status-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.btn-data-calculate {
    padding: 10px 20px;
    background: linear-gradient(135deg, #2196f3 0%, #1976d2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-data-calculate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.btn-data-skip {
    padding: 10px 20px;
    background: #f5f5f5;
    color: #333;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-data-skip:hover {
    background: #e8e8e8;
}

.btn-data-delete {
    padding: 10px 20px;
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-data-delete:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

.data-manage-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #e0e0e0, transparent);
    margin: 20px 0;
}

.data-manage-footer {
    padding: 16px 24px;
    border-top: 2px solid #e0e0e0;
    background: #f9f9f9;
    border-radius: 0 0 12px 12px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-data-save {
    padding: 10px 24px;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-data-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-data-cancel {
    padding: 10px 24px;
    background: #f5f5f5;
    color: #333;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-data-cancel:hover {
    background: #e8e8e8;
}

/* Report Container Styles for Account Reports */
.report-container {
    background: white;
    border-radius: 4px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    margin-bottom: 20px;
    border: 1px solid #d0d0d0;
}

.report-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 15px;
    position: relative;
    background: white;
    border: 1px solid #d0d0d0;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1em;
    min-width: 800px;
    background: white;
    border: 1px solid #d0d0d0;
}

.report-table thead {
    background: #d9d9d9;
    color: #000;
}

.report-table th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    border: 1px solid #a0a0a0;
    font-size: 1em;
    line-height: 1.4;
    white-space: nowrap;
    background: #d9d9d9;
}

.report-table th.text-right {
    text-align: right !important;
    padding-right: 12px !important;
    font-variant-numeric: tabular-nums;
}

.report-table th.col-left-align {
    text-align: left !important;
    padding-left: 12px !important;
}

.report-table th.vertical-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    height: 120px;
    padding: 5px;
}

.report-table th.vertical-text .header-text {
    display: inline-block;
    transform: rotate(0deg);
}

.report-table td {
    padding: 6px 10px;
    border: 1px solid #d0d0d0;
    font-size: 1em;
    line-height: 1.4;
    background: white;
}

.report-table tbody tr:hover {
    background: #e6f3ff;
}

.report-table tbody tr:nth-child(even) {
    background: white;
}

.report-table tbody tr:nth-child(even):hover {
    background: #e6f3ff;
}

.report-table td.text-right {
    text-align: right !important;
    padding-right: 12px !important;
    font-variant-numeric: tabular-nums;
}

.report-table td.col-left-align {
    text-align: left !important;
    padding-left: 12px !important;
}

.report-table .category-header {
    background-color: #f0f0f0;
    font-weight: bold;
}

.report-table .category-header td {
    padding: 8px 10px;
    border: 1px solid #a0a0a0;
    border-top: 2px solid #808080;
}

.report-table .total-row {
    background: #d9ead3;
    font-weight: 600;
}

.report-table .total-row td {
    border: 1px solid #a0a0a0;
    border-top: 2px solid #808080;
    padding: 8px 10px;
    background: #d9ead3;
}

.report-table .category-total-row {
    background: #d9ead3;
    font-weight: 600;
}

.report-table .category-total-row td {
    border: 1px solid #a0a0a0;
    border-top: 2px solid #808080;
    padding: 8px 10px;
    background: #d9ead3;
}

.report-table .profit-row {
    background: #ffe6cc;
    font-weight: 600;
}

.report-table .profit-row td {
    border: 1px solid #a0a0a0;
    border-top: 2px solid #808080;
    padding: 8px 10px;
    background: #ffe6cc;
}

.report-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-export {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.btn-export:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-export:active {
    transform: translateY(0);
}

.btn-export span {
    font-size: 1.1em;
}

/* ซ่อนกราฟ/รูปในรายงาน เมื่อกดปุ่ม ซ่อน รูป */
body.hide-report-charts .charts-container,
body.hide-report-charts .reports-list canvas,
body.hide-report-charts .reports-list .chart-container,
body.hide-report-charts .reports-list img,
body.hide-report-charts #biTreemap,
body.hide-report-charts #biExpenseTreemap,
body.hide-report-charts .bi-treemap-panel {
    display: none !important;
}

/* เมื่อซ่อนกราฟ แผงรายงาน BI ขยายเต็มความกว้าง */
body.hide-report-charts .bi-dashboard-layout .bi-reports-wrapper {
    flex: 1 1 100% !important;
    max-width: 100% !important;
}

/* 2 กราฟอยู่เหนือแดชบอร์ด: จอแคบให้เรียงเป็นคอลัมน์เดียว */
@media (max-width: 900px) {
    .bi-treemap-panel-above {
        grid-template-columns: 1fr !important;
    }
}

