/* ==========================================================================
   CSS DESIGN SYSTEM - SYSTEMS FOR SCHOOL REQUISITION (SPS & APR)
   ========================================================================== */

/* 1. กำหนดตัวแปรสำหรับโทนสีและขนาด (CSS Custom Properties) */
:root {
    /* ธีมสีโหมดสว่าง (Default Light Theme) */
    --font-primary: 'Outfit', 'Sarabun', sans-serif;
    
    --bg-primary: #f5f7fb;
    --bg-sidebar: #0f172a;
    --bg-card: #ffffff;
    --bg-header: rgba(255, 255, 255, 0.8);
    
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    
    --secondary: #0ea5e9;
    --secondary-hover: #0284c7;
    
    --success: #10b981;
    --success-light: #d1fae5;
    --success-hover: #059669;
    
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --danger-hover: #dc2626;
    
    --text-main: #1e293b;
    --text-sub: #64748b;
    --text-on-dark: #f8fafc;
    --border-color: #e2e8f0;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --border-radius-sm: 6px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

/* ธีมสีโหมดมืด (Dark Theme Overrides) */
body.dark-mode {
    --bg-primary: #090d16;
    --bg-sidebar: #05080e;
    --bg-card: #131b2e;
    --bg-header: rgba(19, 27, 46, 0.8);
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.15);
    
    --text-main: #f1f5f9;
    --text-sub: #94a3b8;
    --border-color: #1e293b;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

/* 2. การตั้งค่าพื้นฐาน (Global Resets) */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overflow-x: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

img, svg, video, canvas {
    max-width: 100%;
    height: auto;
}

input, select, textarea, button {
    font-family: var(--font-primary);
}

/* ซ่อน Scrollbar ของบราวเซอร์เพื่อความสวยงามแต่ยังเลื่อนได้ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--text-sub);
    border-radius: 4px;
    opacity: 0.3;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* 3. แผงสาธิตขั้นตอนการทำงานและสลับบทบาทจำลอง (Workflow Demo & Role Switcher Bar) */
.demo-workflow-bar {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 60%, #172554 100%);
    color: #e2e8f0;
    padding: 6px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    z-index: 15;
    position: relative;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.demo-workflow-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
    margin: 0 auto;
    flex-wrap: wrap;
    gap: 10px;
}

.demo-workflow-steps {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.demo-workflow-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #93c5fd;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-right: 4px;
    background: rgba(59, 130, 246, 0.15);
    padding: 4px 9px;
    border-radius: 14px;
    border: 1px solid rgba(147, 197, 253, 0.25);
}

.demo-pulse-dot {
    width: 7px;
    height: 7px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: demoPulse 2s infinite;
}

@keyframes demoPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.demo-step-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.demo-step-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.35);
    color: #ffffff;
    transform: translateY(-1px);
}

.demo-step-btn.active {
    background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    border-color: #818cf8;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(79, 70, 229, 0.5);
}

.demo-step-btn .step-num {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.demo-step-btn.active .step-num {
    background: #ffffff;
    color: #1e1b4b;
}

.demo-step-btn .step-icon {
    font-size: 13px;
}

.step-arrow {
    color: rgba(255, 255, 255, 0.35);
    font-size: 13px;
    font-weight: 700;
    user-select: none;
    margin: 0 1px;
}

/* Dropdown สำหรับเลือกหัวหน้าฝ่ายในขั้นตอนที่ 2 */
.demo-step-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.demo-step-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--border-radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
    width: 290px;
    max-height: 350px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    flex-direction: column;
    padding: 6px 0;
}

.demo-step-dropdown-menu.show {
    display: flex;
}

.demo-step-dropdown-menu .dropdown-header {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.demo-head-option {
    padding: 9px 12px;
    color: #cbd5e1;
    font-size: 12px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: all var(--transition-fast);
}

.demo-head-option:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.demo-head-option.active {
    background: rgba(79, 70, 229, 0.25);
    color: #a5b4fc;
    font-weight: 600;
    border-left: 3px solid #6366f1;
}

.demo-head-option-title {
    font-weight: 600;
    color: #f1f5f9;
}

.demo-head-option-approver {
    font-size: 11px;
    color: #94a3b8;
}

/* ส่วนควบคุมข้อมูลจำลอง (Mock Data Controls) */
.demo-mock-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.demo-mock-status-pill {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    color: #e2e8f0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.demo-mock-status-pill.active {
    background: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.45);
    color: #6ee7b7;
}

.btn-demo-action {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-weight: 600;
    font-size: 11.5px;
    border-radius: 16px;
    padding: 5px 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
}

.btn-demo-action:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #4338ca 100%);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.5);
    transform: translateY(-1px);
}

.btn-demo-action-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5 !important;
    border: 1px solid rgba(248, 113, 113, 0.4);
    font-weight: 600;
    font-size: 11.5px;
    border-radius: 16px;
    padding: 5px 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all var(--transition-fast);
}

.btn-demo-action-danger:hover {
    background: #dc2626 !important;
    color: #ffffff !important;
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
    transform: translateY(-1px);
}

/* 4. โครงสร้าง Layout หลัก (App Container) */
.app-container {
    display: flex;
    flex: 1;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
}

/* เมนูด้านข้าง (Sidebar) - ตรึงอยู่กับที่ ไม่เลื่อนตามเนื้อหา */
.app-sidebar {
    width: 260px;
    height: 100vh;
    max-height: 100vh;
    background-color: var(--bg-sidebar);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
    overflow: hidden;
    transition: width var(--transition-normal);
    position: relative;
    z-index: 20;
}

.sidebar-brand {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-md);
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 2px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-info h1 {
    font-size: 13px;
    font-weight: 700;
    color: white;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.sub-brand {
    font-size: 11px;
    color: var(--text-sub);
    letter-spacing: 0.5px;
}

/* เมนูคำสั่งในสไลด์บาร์ */
.sidebar-menu {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    color: #94a3b8;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
    position: relative;
}

.menu-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: #cbd5e1;
}

.menu-item.active {
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.15) 0%, rgba(79, 70, 229, 0.02) 100%);
    color: white;
    font-weight: 600;
}

.menu-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 15%;
    height: 70%;
    width: 4px;
    background-color: var(--primary);
    border-radius: 0 4px 4px 0;
}

.menu-icon {
    font-size: 18px;
}

.badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    margin-left: auto;
    white-space: nowrap;
}

.badge-warning {
    background-color: var(--warning-light);
    color: #b45309;
}

/* พื้นที่โปรไฟล์ผู้ใช้งานด้านล่างสไลด์บาร์ - ล็อคติดด้านล่างเสมอ */
.sidebar-profile {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background-color: rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
    margin-top: auto;
}

.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 2px solid rgba(79, 70, 229, 0.3);
}

.profile-details {
    overflow: hidden;
}

.profile-name {
    font-size: 13px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.profile-role {
    font-size: 11px;
    color: var(--text-sub);
}

.profile-dept {
    font-size: 10px;
    color: var(--primary);
    font-weight: bold;
}

/* ปุ่มออกจากระบบในสไลด์บาร์ - ตัวอักษรสีสว่าง มองเห็นชัดเจน */
.btn-logout-sidebar,
#btn-logout {
    width: 100%;
    padding: 8px 12px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #ffffff !important;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.3) 0%, rgba(220, 38, 38, 0.45) 100%) !important;
    border: 1px solid rgba(248, 113, 113, 0.55) !important;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.btn-logout-sidebar:hover,
#btn-logout:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: #ffffff !important;
    border-color: #f87171 !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.5) !important;
    transform: translateY(-1px);
}

/* พื้นที่แสดงผลส่วนหลัก (Main Content) */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    min-width: 0;
}

/* ส่วนหัวหลัก (Header) */
.app-header {
    height: 60px;
    flex-shrink: 0;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 10;
    transition: background-color var(--transition-normal);
}

.role-badge {
    background-color: var(--primary-light);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.btn-refresh-live {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.25);
    color: var(--primary);
    padding: 5px 11px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-refresh-live:hover {
    background: rgba(37, 99, 235, 0.16);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.btn-refresh-live .sync-icon.rotating {
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

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

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.datetime-display {
    font-size: 13px;
    color: var(--text-sub);
    font-weight: 500;
}

.btn-lang {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-main);
    transition: all var(--transition-fast);
}

.btn-lang:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.content-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    height: calc(100vh - 60px);
}

/* แถบเมนูด้านบนสุดของระบบเบิกจ่ายวัสดุอุปกรณ์ (Top Sub-navigation Bar) */
.top-subnav-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    margin-bottom: 24px;
    overflow-x: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.subnav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-radius: var(--border-radius-sm);
    color: var(--text-sub);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.subnav-item:hover {
    background-color: var(--bg-primary);
    color: var(--text-main);
}

.subnav-item.active {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.subnav-icon {
    font-size: 16px;
}

.content-section {
    animation: fadeIn var(--transition-normal) forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-title {
    margin-bottom: 24px;
}

.section-title h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
    word-break: keep-all;
    overflow-wrap: break-word;
}

.section-title p {
    font-size: 14px;
    color: var(--text-sub);
}

/* ==================== สไตล์ส่วนแดชบอร์ด (Dashboard) ==================== */

/* การ์ดสถิติ (Stats Grid) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.stat-card::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: 0;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    opacity: 0.05;
    background-color: var(--text-main);
    transform: translate(15px, 15px);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--border-radius-md);
    background: var(--bg-primary);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ไล่เฉดสีเพื่อลูกเล่นสุดพรีเมียม */
.total-items .stat-icon { background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(14, 165, 233, 0.1)); }
.pending-orders .stat-icon { background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(249, 115, 22, 0.1)); }
.low-stock .stat-icon { background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(244, 63, 94, 0.1)); }
.completed-disp .stat-icon { background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(20, 184, 166, 0.1)); }

.stat-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-sub);
}

.stat-val {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-main);
    margin: 2px 0;
    line-height: 1;
}

.stat-sub {
    font-size: 11px;
    color: var(--text-sub);
}

/* แผงข้อมูลวิเคราะห์ แผนภูมิ/ตาราง */
.dashboard-charts-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.dashboard-panel h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* แผนภูมิแท่งจำลองด้วย HTML/CSS (Custom Responsive Bar Chart) */
.dept-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 8px;
}

.chart-row {
    display: grid;
    grid-template-columns: 155px 1fr 50px 105px;
    align-items: center;
    gap: 10px;
}

.chart-label {
    font-size: 12px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chart-bar-container {
    height: 10px;
    background-color: var(--bg-primary);
    border-radius: 5px;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 5px;
    width: 0;
    transition: width 1s cubic-bezier(0.1, 0.8, 0.2, 1);
}

.chart-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-sub);
    text-align: right;
    white-space: nowrap;
}

.chart-value.chart-expense {
    color: #059669;
    font-weight: 700;
}

/* รายชื่อไอเทมเบิกบ่อย */
.popular-items-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.popular-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: var(--border-radius-md);
    background: var(--bg-primary);
}

.pop-item-name {
    font-size: 13px;
    font-weight: 500;
}

.pop-item-count {
    background-color: var(--primary-light);
    color: var(--primary);
    font-size: 11px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 12px;
}

/* ตารางข้อมูลทั่วไป (Data Table Style) */
.table-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
    -webkit-overflow-scrolling: touch;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

.data-table th {
    background-color: rgba(0, 0, 0, 0.02);
    padding: 13px 15px;
    font-weight: 600;
    color: var(--text-sub);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    vertical-align: middle;
}

body.dark-mode .data-table th {
    background-color: rgba(255, 255, 255, 0.02);
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.01);
}

body.dark-mode .data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.01);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ==================== สไตล์แท็บแคตตาล็อกเบิกพัสดุ (Catalog) ==================== */

.catalog-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.filter-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    min-width: 260px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-sub);
    font-size: 14px;
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    padding: 10px 32px 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    cursor: pointer;
    appearance: none;
    transition: all var(--transition-fast);
}

.select-wrapper select:focus {
    border-color: var(--primary);
}

.select-wrapper::after {
    content: '▼';
    font-size: 9px;
    color: var(--text-sub);
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.category-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 6px;
}

.cat-tab {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-sub);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.cat-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.cat-tab.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* กริดแสดงการ์ดพัสดุ (Catalog Grid) */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

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

.catalog-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.card-cat-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background-color: var(--bg-primary);
    color: var(--text-sub);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: bold;
    white-space: nowrap;
}

.card-item-image {
    width: 60px;
    height: 60px;
    border-radius: var(--border-radius-md);
    background-color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-top: 10px;
}

.card-item-title {
    margin-top: 6px;
}

.card-item-title h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    word-break: keep-all;
    overflow-wrap: break-word;
}

.card-item-title span {
    font-size: 12px;
    color: var(--text-sub);
    display: block;
}

.card-stock-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.stock-status-pill {
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 10px;
    white-space: nowrap;
}

.status-instock { background-color: var(--success-light); color: var(--success-hover); }
.status-low { background-color: var(--warning-light); color: #d97706; }
.status-empty { background-color: var(--danger-light); color: var(--danger-hover); }

.card-location {
    font-size: 11px;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ==================== สไตล์ปุ่มคำสั่ง (Buttons) ==================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--border-radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    outline: none;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
}
.btn-primary:disabled {
    background-color: var(--text-sub);
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: var(--bg-primary);
    color: var(--text-main);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-secondary-outline {
    background-color: transparent;
    color: var(--text-main);
    border-color: var(--border-color);
}
.btn-secondary-outline:hover {
    background-color: var(--bg-primary);
}

.btn-success {
    background-color: var(--success);
    color: white;
}
.btn-success:hover {
    background-color: var(--success-hover);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}
.btn-danger:hover {
    background-color: var(--danger-hover);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
    border-radius: var(--border-radius-sm);
}

.btn-text {
    background: transparent;
    color: var(--primary);
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}
.btn-text:hover {
    text-decoration: underline;
}

.btn-icon-only {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all var(--transition-fast);
}

.btn-icon-only:hover {
    border-color: var(--primary);
}

/* ป้ายแสดงสถานะ (Status Badges) */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-pending-dept { background-color: #fef3c7; color: #b45309; }
.badge-pending-supply { background-color: #e0f2fe; color: #0369a1; }
.badge-approved { background-color: #d1fae5; color: #065f46; }
.badge-rejected-dept { background-color: #fee2e2; color: #991b1b; }
.badge-rejected-supply { background-color: #ffedd5; color: #9a3412; }
.badge-cancelled { background-color: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; }

.btn-danger-outline {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn-danger-outline:hover {
    background: #ef4444;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

.chart-row.expense-row {
    grid-template-columns: 200px 1fr 120px;
}
.chart-bar-fill.expense-fill {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

.card-price-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #059669;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.12);
    padding: 2px 8px;
    border-radius: 12px;
}

/* ==================== หน้ารายการรออนุมัติและคลังพัสดุ (Approvals & Inventory) ==================== */

.approval-filter-bar, .inventory-filter-bar, .history-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
}

.approval-tabs, .stock-filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.app-tab, .stock-btn {
    background-color: transparent;
    border: 1px solid transparent;
    color: var(--text-sub);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.app-tab:hover, .stock-btn:hover {
    color: var(--text-main);
    background-color: var(--bg-primary);
}

.app-tab.active, .stock-btn.active {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: bold;
}

.inventory-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.admin-action-row {
    display: flex;
    gap: 8px;
}

/* ==================== สไตล์หน้าประวัติการเบิกจ่าย (History Log Screen) ==================== */

.history-filter-panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 12px 14px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.hist-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.hist-filter-row-top {
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.hist-search-wrap {
    flex: 1 1 220px;
    position: relative;
    display: flex;
    align-items: center;
}

.hist-search-wrap input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-main);
    font-size: 12.5px;
    outline: none;
    transition: border-color var(--transition-fast);
}

.hist-search-wrap input:focus {
    border-color: var(--primary);
}

.hist-search-wrap .search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-sub);
    pointer-events: none;
    font-size: 13px;
}

.hist-select-wrap {
    flex: 0 1 auto;
    min-width: 130px;
}

.hist-select-wrap select {
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-main);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition-fast);
}

.hist-select-wrap select:focus {
    border-color: var(--primary);
}

.hist-clear-btn {
    white-space: nowrap !important;
    padding: 7px 11px !important;
    font-size: 12px !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.hist-filter-row-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
}

.hist-summary-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.hist-summary-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.08);
    color: #2563eb;
    font-weight: 500;
    white-space: nowrap;
}

.hist-summary-pill strong {
    font-weight: 700;
    color: #1e3a8a;
    font-variant-numeric: tabular-nums;
}

body.dark-mode .hist-summary-pill {
    background: rgba(37, 99, 235, 0.2);
    color: #93c5fd;
}

body.dark-mode .hist-summary-pill strong {
    color: #bfdbfe;
}

.hist-summary-cost {
    background: rgba(5, 150, 105, 0.08);
    color: #059669;
}

.hist-summary-cost strong {
    color: #047857;
}

body.dark-mode .hist-summary-cost {
    background: rgba(5, 150, 105, 0.2);
    color: #6ee7b7;
}

body.dark-mode .hist-summary-cost strong {
    color: #a7f3d0;
}

.hist-actions-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ตารางประวัติการเบิกจ่ายแบบกะทัดรัด ไม่ล้นจอ รายการเบิกกว้าง */
.history-data-table {
    width: 100%;
    table-layout: auto;
    font-size: 12px;
}

.history-data-table th {
    padding: 10px 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-sub);
    white-space: nowrap;
    border-bottom: 2px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.02);
}

body.dark-mode .history-data-table th {
    background-color: rgba(255, 255, 255, 0.02);
}

.history-data-table td {
    padding: 7px 6px;
    vertical-align: middle;
    font-size: 11.5px;
    border-bottom: 1px solid var(--border-color);
}

.history-data-table td .dept-cat-pill {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 600;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-sub);
    display: inline-block;
    white-space: nowrap;
}

.history-data-table .items-summary-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.history-data-table .item-summary-badge {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11.5px;
    line-height: 1.35;
}

.history-data-table .hist-item-name {
    font-weight: 500;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-data-table .hist-item-qty {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.history-data-table .hist-purpose-cell {
    font-size: 11px;
    color: var(--text-sub);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}

.history-data-table .hist-remark-chip {
    font-size: 10px;
    color: var(--text-sub);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 105px;
    margin-top: 1px;
}

.history-data-table .hist-action-btn {
    padding: 3px 6px !important;
    font-size: 10.5px !important;
    white-space: nowrap !important;
    width: 100%;
    justify-content: center;
}

/* ==================== ป๊อปอัปกรอบข้อความ (Modals) ==================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.modal-backdrop.show {
    display: flex;
    opacity: 1;
}

.modal-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 580px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    transform: translateY(16px);
    transition: transform var(--transition-normal);
}

.modal-backdrop.show .modal-card {
    transform: translateY(0);
}

.modal-card-sm {
    max-width: 400px;
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    word-break: keep-all;
    overflow-wrap: break-word;
}

.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--text-sub);
    cursor: pointer;
    outline: none;
}
.modal-close-btn:hover {
    color: var(--danger);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 120px);
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* พรีวิวพัสดุในหน้าเบิก */
.selected-item-preview {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.preview-icon {
    font-size: 32px;
}

.preview-info h4 {
    font-size: 14px;
    font-weight: 700;
}

.preview-info span {
    font-size: 12px;
    color: var(--text-sub);
}

.preview-stock-status {
    font-size: 11px;
    color: var(--text-sub);
    margin-top: 4px;
}

/* ฟอร์มและข้อมูลควบคุม (Forms Styles) */
.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
}

.required {
    color: var(--danger);
}

input[type="text"], input[type="number"], input[type="password"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    transition: all var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-readonly {
    background-color: var(--bg-primary) !important;
    color: var(--text-sub) !important;
    cursor: not-allowed;
}

.form-hint {
    font-size: 11px;
    color: var(--text-sub);
}

/* ปุ่มควบคุมจำนวนแบบสเต็ปเปอร์ (Stepper Qty Input) */
.qty-stepper {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    width: 130px;
}

.qty-btn {
    background-color: var(--bg-primary);
    border: none;
    width: 38px;
    height: 38px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-main);
    transition: background-color var(--transition-fast);
}

.qty-btn:hover {
    background-color: var(--border-color);
}

.qty-stepper input {
    border: none !important;
    border-radius: 0 !important;
    text-align: center;
    width: 54px;
    padding: 0 !important;
    height: 38px;
    box-shadow: none !important;
}

/* แสดงรายละเอียดใบเบิกในหน้าอนุมัติ */
.review-details-box {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-row {
    display: flex;
    font-size: 13px;
}

.detail-label {
    width: 120px;
    font-weight: 600;
    color: var(--text-sub);
}

.purpose-text {
    flex: 1;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
}

/* ==================== แจ้งเตือนพัฟอัป Toast Alerts ==================== */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 300;
    max-width: 320px;
}

.toast-message {
    background-color: var(--bg-card);
    border-left: 4px solid var(--primary);
    padding: 12px 16px;
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

/* ==================== ความเข้ากันได้ของอุปกรณ์ (Responsive Web) ==================== */

@media (max-width: 1024px) {
    .dashboard-charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* 1. Reset การเลื่อนระดับหน้าจอ ให้ลื่นไหลบนมือถือ */
    html, body {
        height: auto !important;
        min-height: 100% !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }

    /* 2. Layout หลัก */
    .app-container {
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 100vh !important;
        max-height: none !important;
        overflow: visible !important;
    }
    
    /* 3. แถบ Sidebar บนมือถือ: ไม่ sticky บังจอ จัดให้กระชับเรียบหรู */
    .app-sidebar {
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color) !important;
        position: relative !important;
        top: auto !important;
        z-index: 50 !important;
        flex-shrink: 0;
    }
    
    .sidebar-brand {
        padding: 10px 14px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        display: flex;
        align-items: center;
        gap: 10px;
    }
    
    .brand-logo {
        width: 34px;
        height: 34px;
    }
    
    .brand-info h1 {
        font-size: 13.5px;
        max-width: none;
        white-space: normal;
    }
    
    .brand-info .sub-brand {
        font-size: 10px;
    }
    
    .sidebar-menu {
        flex-direction: row;
        overflow-x: auto;
        padding: 6px 10px;
        gap: 6px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .sidebar-menu::-webkit-scrollbar {
        display: none;
    }
    
    .menu-item {
        padding: 7px 12px;
        white-space: nowrap;
        font-size: 12px;
        border-radius: var(--border-radius-sm);
        flex-shrink: 0;
    }
    
    .menu-item.active::before {
        display: none;
    }
    
    .sidebar-profile {
        padding: 8px 12px !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-wrap: wrap;
        gap: 8px;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
        background-color: rgba(0, 0, 0, 0.35);
    }
    
    .sidebar-profile > div:first-child {
        width: auto !important;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .profile-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .profile-name {
        font-size: 12px;
    }
    .profile-role, .profile-dept {
        font-size: 10px;
    }
    
    .profile-actions {
        width: auto !important;
        margin-top: 0 !important;
        flex-direction: row !important;
    }
    
    .profile-actions .btn,
    .btn-logout-sidebar,
    #btn-logout {
        padding: 5px 10px !important;
        font-size: 11px !important;
    }
    
    /* 4. พื้นที่เนื้อหาหลัก */
    .app-main {
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow-y: visible !important;
        overflow-x: hidden !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .content-body {
        height: auto !important;
        max-height: none !important;
        overflow-y: visible !important;
        overflow-x: hidden !important;
        padding: 12px 10px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* 5. Header ปรับขนาดพอดีจอ ไม่ล้นและไม่บัง */
    .app-header {
        height: auto !important;
        min-height: 52px;
        padding: 8px 12px !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;
        position: sticky;
        top: 0;
        z-index: 40;
    }
    
    .header-search-dummy {
        display: flex;
        align-items: center;
    }
    
    .role-badge {
        font-size: 11px;
        padding: 4px 9px;
    }
    
    .header-actions {
        width: auto !important;
        display: flex;
        align-items: center;
        gap: 6px !important;
        flex-wrap: wrap;
    }
    
    #cart-toggle-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
    
    .datetime-display {
        font-size: 11px !important;
        display: none; /* ซ่อนวันที่แบบยาวบนจอเล็กเพื่อประหยัดพื้นที่ */
    }
    
    .btn-lang {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    /* 6. แถบเมนูย่อยด้านบน (Top Subnav) */
    .top-subnav-bar {
        padding: 5px;
        gap: 6px;
        margin-bottom: 14px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .top-subnav-bar::-webkit-scrollbar {
        display: none;
    }
    
    .subnav-item {
        padding: 8px 12px;
        font-size: 12px;
        flex-shrink: 0;
        gap: 6px;
    }
    
    /* 7. ส่วนหัวแต่ละหน้า */
    .section-title {
        margin-bottom: 14px;
    }
    
    .section-title h2 {
        font-size: 18px;
    }
    
    .section-title p {
        font-size: 12px;
    }
    
    /* 8. สถิติ Dashboard */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 16px;
    }
    
    .stat-card {
        padding: 12px 14px;
    }
    
    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 20px;
    }
    
    .stat-val {
        font-size: 20px;
    }
    
    .dashboard-panel {
        padding: 14px 12px;
        margin-bottom: 16px;
        border-radius: var(--border-radius-md);
    }
    
    /* แผนภูมิแท่ง ปรับให้อยู่ในแถวสวยงาม ไม่ล้นจอ */
    .chart-row {
        grid-template-columns: 1fr auto auto;
        gap: 4px 8px;
        align-items: center;
    }
    
    .chart-label {
        font-size: 11.5px;
    }
    
    .chart-value {
        font-size: 11px;
    }
    
    .chart-bar-container {
        grid-column: 1 / -1;
        order: 3;
        height: 8px;
        margin-top: 2px;
    }
    
    /* 9. ตัวกรองและการค้นหาทุกหน้า */
    .catalog-header-bar,
    .inventory-header-bar,
    .approval-filter-bar,
    .inventory-filter-bar,
    .history-filter-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        gap: 10px !important;
    }
    
    .filter-controls {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        gap: 8px !important;
    }
    
    .search-box {
        min-width: 0 !important;
        width: 100% !important;
    }
    
    .search-box input {
        width: 100% !important;
        font-size: 14px !important;
    }
    
    .select-wrapper {
        width: 100% !important;
    }
    
    .select-wrapper select {
        width: 100% !important;
        font-size: 13px !important;
    }
    
    .category-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
        margin-bottom: 14px;
        gap: 6px;
    }
    .category-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .cat-tab {
        padding: 6px 12px;
        font-size: 12px;
        flex-shrink: 0;
    }
    
    /* 10. Catalog Grid & Cards */
    .catalog-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .catalog-card {
        padding: 14px;
        border-radius: var(--border-radius-md);
    }
    
    /* 11. ปรับปรุงตารางข้อมูลทั้งหมดให้ Scroll ใน Container อย่างลื่นไหล */
    .table-container {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: var(--border-radius-md) !important;
        margin-bottom: 12px;
    }
    
    .data-table {
        min-width: 580px !important;
        font-size: 12px !important;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px 10px !important;
    }
    
    /* 12. หน้าจัดการคลัง (Inventory) */
    .inventory-actions {
        display: grid !important;
        grid-template-columns: 1fr !important;
        width: 100% !important;
        gap: 8px !important;
    }
    
    .inventory-actions .btn {
        width: 100% !important;
        justify-content: center !important;
        font-size: 12.5px !important;
        padding: 8px 12px !important;
    }
    
    .stock-filter-buttons {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        width: 100% !important;
    }
    
    .stock-btn {
        flex: 1 1 auto !important;
        text-align: center !important;
        padding: 7px 10px !important;
        font-size: 12px !important;
    }
    
    .filter-dropdowns {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 8px !important;
    }
    
    /* 13. ฟอร์มและอินพุต */
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
    }
    
    .form-group {
        margin-bottom: 12px !important;
    }
    
    /* ป้องกัน iOS Safari auto-zoom เมื่อแตะ input */
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="email"],
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* 14. Modals & Dialogs ปรับให้พอดีหน้าจอมือถือ 100% */
    .modal-backdrop {
        padding: 8px !important;
        align-items: center !important;
    }
    
    .modal-card,
    .modal-card.modal-card-xl,
    .modal-card-sm,
    div.modal-card[style*="max-width"] {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        max-height: 94vh !important;
        border-radius: var(--border-radius-lg) !important;
        display: flex !important;
        flex-direction: column !important;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4) !important;
    }
    
    .modal-header {
        padding: 12px 14px !important;
    }
    
    .modal-header h3 {
        font-size: 15px !important;
    }
    
    .modal-body {
        padding: 14px 12px !important;
        max-height: calc(94vh - 120px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .modal-footer {
        padding: 10px 12px !important;
        flex-direction: column-reverse !important;
        gap: 8px !important;
    }
    
    .modal-footer .btn {
        width: 100% !important;
        justify-content: center !important;
        padding: 10px 14px !important;
    }
    
    /* โมดอลรายงานจัดซื้อบนมือถือ */
    .report-kpi-grid,
    div.report-kpi-grid[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    .report-filter-bar > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    /* 15. หน้าต่าง Login Gate บนมือถือ */
    .login-gate-backdrop {
        padding: 12px !important;
    }
    
    .login-gate-card {
        padding: 22px 16px !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: auto !important;
    }
    
    .login-gate-logo {
        width: 58px !important;
        height: 58px !important;
    }
    
    .login-gate-header h2 {
        font-size: 17px !important;
    }
    
    .login-gate-sub {
        font-size: 11.5px !important;
    }
    
    .supabase-status-badge {
        font-size: 10.5px !important;
        padding: 4px 8px !important;
    }
}

/* หน้าจอขนาดเล็กพิเศษ (Smartphones < 480px เช่น iPhone SE, Android ขนาดกะทัดรัด) */
@media (max-width: 480px) {
    .content-body {
        padding: 10px 8px !important;
    }
    
    .section-title h2 {
        font-size: 16.5px !important;
    }
    
    .brand-info h1 {
        font-size: 12.5px !important;
    }
    
    .btn {
        padding: 7px 12px !important;
        font-size: 12px !important;
    }
    
    .catalog-qty-selector {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .catalog-qty-selector .btn {
        flex: 1;
    }
}

/* ==================== สไตล์สำหรับระบบตะกร้าเบิกหลายรายการ (Cart & Multi-item Additions) ==================== */

.cart-qty-input {
    width: 60px;
    padding: 4px 6px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-weight: 600;
    font-size: 12px;
    outline: none;
}

.cart-qty-input:focus {
    border-color: var(--primary);
}

/* กล่องกรอกปรับจูนตัวเลขในตารางขออนุมัติโดยหัวหน้าฝ่าย */
.review-qty-edit-input {
    width: 70px;
    padding: 6px;
    text-align: center;
    border: 2px solid var(--primary);
    border-radius: var(--border-radius-sm);
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    font-size: 13px;
    outline: none;
    transition: all var(--transition-fast);
}

.review-qty-edit-input:focus {
    background-color: var(--bg-card);
    box-shadow: 0 0 5px rgba(79, 70, 229, 0.4);
}

body.dark-mode .review-qty-edit-input {
    background-color: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    color: #e0e7ff;
}

/* การลบพัสดุในตะกร้า */
.btn-delete-cart {
    background: transparent;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-sub);
    transition: color var(--transition-fast);
}

.btn-delete-cart:hover {
    color: var(--danger);
}

/* ตัวแจ้งเตือนตะกร้าด่วนบริเวณ Catalog card */
.catalog-qty-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
}

.catalog-qty-input {
    width: 50px;
    padding: 8px 4px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-weight: 600;
    font-size: 13px;
}

.card-action-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.card-action-row .btn {
    flex: 1;
}

/* แถบพัสดุในตารางรออนุมัติแบบกลุ่ม */
.items-summary-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.item-summary-badge {
    display: inline-flex;
    align-items: center;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    gap: 6px;
}

.item-summary-badge strong {
    color: var(--primary);
}

body.dark-mode .item-summary-badge strong {
    color: #a5b4fc;
}

/* ไอคอนแจ้งจำนวนในตะกร้ากระพริบเมื่อมีของ */
@keyframes pulse-notify {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); box-shadow: 0 0 8px rgba(79, 70, 229, 0.6); }
    100% { transform: scale(1); }
}

.cart-pulse {
    animation: pulse-notify 1.5s infinite;
}

/* ==================== แผงตั้งค่าระบบสำหรับผู้บริหาร (Executive Settings Panel) ==================== */
.settings-tabs {
    display: flex;
    gap: 10px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1px;
    margin-bottom: 25px;
}

.settings-tabs .tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.settings-tabs .tab-btn:hover {
    color: var(--text-main);
}

.settings-tabs .tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 25px;
}

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

.settings-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.settings-card h3 {
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

/* ==================== LOGIN GATE STYLES ==================== */
.login-gate-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    background: radial-gradient(circle at 10% 20%, rgba(79, 70, 229, 0.28) 0%, rgba(15, 23, 42, 0.96) 90%), rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.login-gate-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 40px rgba(79, 70, 229, 0.2);
    max-width: 520px;
    width: 100%;
    padding: 32px;
    position: relative;
    animation: loginCardFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loginCardFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-gate-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-gate-logo {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    object-fit: cover;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    margin-bottom: 12px;
    border: 2px solid var(--primary-light);
}

.login-gate-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 4px 0;
}

.login-gate-sub {
    font-size: 13px;
    color: var(--text-sub);
    margin: 0 0 10px 0;
}

.supabase-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.supabase-status-badge .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.login-gate-form {
    margin-bottom: 20px;
}

.input-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon-wrapper .input-icon {
    position: absolute;
    left: 12px;
    font-size: 15px;
    pointer-events: none;
    opacity: 0.6;
}

.input-icon-wrapper input {
    padding-left: 38px;
    width: 100%;
}

.btn-block {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-lg {
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
}

.quick-demo-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-sub);
    font-size: 12px;
    margin: 20px 0 14px 0;
}

.quick-demo-divider::before,
.quick-demo-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.quick-demo-divider span {
    padding: 0 10px;
}

.quick-demo-buttons-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.quick-role-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.quick-role-btn:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.quick-role-btn .qr-icon {
    font-size: 22px;
}

.quick-role-btn strong {
    font-size: 12px;
    color: var(--text-main);
    display: block;
}

.quick-role-btn small {
    font-size: 10px;
    color: var(--text-sub);
    line-height: 1.2;
}

.quick-head-selector-box {
    background: var(--bg-primary);
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 12px;
}

.quick-head-selector-box label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.quick-select-dropdown {
    flex: 1;
    padding: 8px 10px;
    font-size: 12px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-main);
}

.user-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* ========================================================
   ระบบรายงานสรุปการใช้วัสดุอุปกรณ์และการวางแผนจัดซื้อ
   Procurement & Material Consumption Planning Styles
   ======================================================== */

.popular-item-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border-radius: var(--border-radius-md);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.popular-item-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.popular-item-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.pop-item-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.pop-item-code {
    font-size: 10px;
    font-family: monospace;
    font-weight: 600;
    color: var(--text-sub);
    background: var(--bg-card);
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.pop-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pop-item-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.pop-item-qty {
    background-color: rgba(59, 130, 246, 0.12);
    color: #2563eb;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.pop-item-cost {
    background-color: rgba(16, 185, 129, 0.12);
    color: #059669;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.pop-item-sub {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-sub);
}

.pop-stock-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10.5px;
    padding: 1px 6px;
    border-radius: 4px;
}

.pop-stock-pill.stock-ok {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.pop-stock-pill.stock-low {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
    font-weight: 600;
}

.pop-stock-pill.stock-out {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
    font-weight: 700;
}

/* Modal XL & LG */
.modal-card.modal-card-xl {
    width: 95%;
    max-width: 1150px;
    border-radius: var(--border-radius-lg);
}

.modal-card.modal-card-lg {
    width: 94%;
    max-width: 920px;
    border-radius: var(--border-radius-lg);
}

/* Reorder status badges in procurement report table */
.badge-reorder-urgent {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #f87171;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1.3;
    text-align: center;
}

.badge-reorder-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1.3;
    text-align: center;
}

.badge-reorder-ok {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1.3;
    text-align: center;
}

.badge-reorder-idle {
    background: var(--bg-primary);
    color: var(--text-sub);
    border: 1px solid var(--border-color);
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1.3;
    text-align: center;
}

/* Dark theme overrides for badges */
[data-theme="dark"] .badge-reorder-urgent {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.4);
}
[data-theme="dark"] .badge-reorder-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.4);
}
[data-theme="dark"] .badge-reorder-ok {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.4);
}

/* ========================================================
   Proportioned On-Screen Report Tables (ตารางสรุปรายงานพัสดุ)
   ======================================================== */
.report-proportioned-table {
    table-layout: auto !important;
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
}

.report-proportioned-table th,
.report-proportioned-table td {
    vertical-align: middle;
    padding: 8px 8px;
}

#dept-report-data-table {
    table-layout: auto !important;
    width: 100% !important;
    min-width: 980px;
    border-collapse: collapse;
}

#dept-report-data-table th {
    padding: 9px 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid var(--border-color);
}

#dept-report-data-table td {
    padding: 7px 8px;
    vertical-align: middle;
    font-size: 12px;
    border-bottom: 1px solid var(--border-color);
}

.dept-requester-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(30, 58, 138, 0.07);
    color: #1e3a8a;
    font-weight: 500;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 4px;
    margin: 2px 3px 2px 0;
    white-space: normal;
    word-break: break-word;
    line-height: 1.35;
}

body.dark-mode .dept-requester-pill {
    background: rgba(147, 197, 253, 0.15);
    color: #93c5fd;
}

.report-compare-proportioned-table {
    table-layout: fixed;
    width: 100%;
    min-width: 1180px;
    border-collapse: collapse;
}

.report-compare-proportioned-table th,
.report-compare-proportioned-table td {
    word-wrap: break-word;
    overflow-wrap: break-word;
    vertical-align: middle;
}

/* ========================================================
   OFFICIAL PDF REPORT STUDIO & A4 PAPER VIEWER STYLES
   ======================================================== */
.pdf-preview-modal-backdrop {
    background: rgba(9, 13, 22, 0.88) !important;
    backdrop-filter: blur(6px);
    z-index: 9999 !important;
    padding: 0 !important;
    align-items: stretch !important;
    justify-content: center !important;
}

.pdf-studio-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pdf-studio-toolbar {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #f8fafc;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    z-index: 10;
}

.pdf-toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pdf-badge-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(96, 165, 250, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.pdf-toolbar-title {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.25;
}

.pdf-toolbar-subtitle {
    font-size: 11.5px;
    color: #94a3b8;
    margin-top: 2px;
}

.pdf-toolbar-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.pdf-control-group {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #cbd5e1;
}

.pdf-control-group label {
    font-weight: 600;
    white-space: nowrap;
}

.pdf-control-group select {
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.pdf-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
    cursor: pointer;
    user-select: none;
}

.pdf-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-pdf-print-now {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
    color: #ffffff !important;
    border: 1px solid #60a5fa !important;
    padding: 8px 18px !important;
    border-radius: 8px !important;
    font-size: 13.5px !important;
    font-weight: 700 !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
    transition: all 0.2s ease;
}

.btn-pdf-print-now:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.6);
}

.btn-pdf-close {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #e2e8f0 !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    padding: 8px 14px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-pdf-close:hover {
    background: rgba(239, 68, 68, 0.85) !important;
    color: #ffffff !important;
    border-color: #f87171 !important;
}

/* พื้นที่แสดงหน้ากระดาษจำลอง A4 */
.pdf-studio-viewport {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 28px 24px 48px 24px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: radial-gradient(circle at top, #334155 0%, #1e293b 60%, #0f172a 100%);
}

.pdf-paper-sheet {
    background: #ffffff !important;
    color: #0f172a !important;
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    padding: 12mm 12mm 14mm 12mm;
    margin: 0 auto;
    box-sizing: border-box;
    position: relative;
    transition: width 0.25s ease;
}

/* ขนาดกระดาษ A4 มาตรฐาน */
.pdf-paper-sheet.landscape {
    width: 297mm;
    min-height: 210mm;
}

.pdf-paper-sheet.portrait {
    width: 210mm;
    min-height: 297mm;
}

/* ส่วนหัวเอกสารทางการ (Official Letterhead) */
.pdf-doc-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 10px;
    border-bottom: 2.5px solid #1e3a8a;
    margin-bottom: 10px;
}

.pdf-doc-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
}

.pdf-doc-logo {
    width: 58px;
    height: 58px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    padding: 3px;
    background: #ffffff;
    flex-shrink: 0;
}

.pdf-school-title {
    font-size: 15pt;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    line-height: 1.2;
}

.pdf-school-subtitle {
    font-size: 8.5pt;
    color: #475569;
    margin: 2px 0 4px 0;
}

.pdf-report-main-title {
    font-size: 12pt;
    font-weight: 700;
    color: #1e3a8a;
    margin: 0;
    line-height: 1.3;
}

.pdf-doc-ref-box {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    border-radius: 6px;
    padding: 6px 12px;
    min-width: 215px;
    font-size: 8.5pt;
    line-height: 1.55;
    color: #334155;
    flex-shrink: 0;
}

.pdf-doc-ref-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.pdf-doc-ref-row strong {
    color: #0f172a;
    font-weight: 700;
}

/* แถบข้อมูลขอบเขตรายงาน (Scope & Filter Metadata Strip) */
.pdf-scope-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-left: 4px solid #1e3a8a;
    border-radius: 4px;
    padding: 6px 12px;
    margin-bottom: 10px;
    font-size: 8.5pt;
}

.pdf-scope-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.pdf-scope-label {
    font-size: 7.5pt;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
}

.pdf-scope-val {
    font-size: 9pt;
    color: #0f172a;
    font-weight: 700;
}

/* แถบสรุปตัวเลข KPI (Executive Summary KPI Strip) */
.pdf-kpi-strip {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}

.pdf-kpi-strip.cols-5 {
    grid-template-columns: repeat(5, 1fr);
}

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

.pdf-kpi-box {
    border: 1px solid #cbd5e1;
    border-top: 3px solid #1e3a8a;
    border-radius: 5px;
    padding: 6px 10px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.pdf-kpi-box.accent-emerald { border-top-color: #059669; }
.pdf-kpi-box.accent-amber { border-top-color: #d97706; }
.pdf-kpi-box.accent-violet { border-top-color: #7c3aed; }
.pdf-kpi-box.accent-rose { border-top-color: #e11d48; }

.pdf-kpi-label {
    font-size: 8pt;
    color: #475569;
    font-weight: 600;
}

.pdf-kpi-value {
    font-size: 12.5pt;
    font-weight: 700;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
    margin: 2px 0;
}

.pdf-kpi-sub {
    font-size: 7.5pt;
    color: #64748b;
}

/* หัวข้อตารางย่อยในเอกสาร PDF */
.pdf-section-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: 10px 0 5px 0;
    padding-bottom: 3px;
    border-bottom: 1.5px solid #334155;
}

.pdf-section-heading h4 {
    font-size: 10pt;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.pdf-section-heading span {
    font-size: 8.5pt;
    color: #475569;
    font-weight: 600;
}

/* ตารางข้อมูลหลักในเอกสาร PDF (Precision Proportioned PDF Table) */
.pdf-data-table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    margin-bottom: 12px;
    font-variant-numeric: tabular-nums;
    color: #0f172a !important;
}

.pdf-paper-sheet.density-standard .pdf-data-table {
    font-size: 8.75pt;
}
.pdf-paper-sheet.density-Standard .pdf-data-table th,
.pdf-paper-sheet.density-standard .pdf-data-table th {
    padding: 5.5px 6px;
}
.pdf-paper-sheet.density-standard .pdf-data-table td {
    padding: 5px 6px;
}

.pdf-paper-sheet.density-compact .pdf-data-table {
    font-size: 8pt;
}
.pdf-paper-sheet.density-compact .pdf-data-table th,
.pdf-paper-sheet.density-compact .pdf-data-table td {
    padding: 3.5px 4.5px;
}

.pdf-paper-sheet.density-comfortable .pdf-data-table {
    font-size: 9.25pt;
}
.pdf-paper-sheet.density-comfortable .pdf-data-table th,
.pdf-paper-sheet.density-comfortable .pdf-data-table td {
    padding: 7px 7px;
}

/* ตารางเปรียบเทียบหลายฝ่าย (Matrix) ปรับขนาดตัวอักษรให้พอดีกับคอลัมน์จำนวนมาก */
.pdf-data-table.pdf-matrix-table {
    font-size: 8pt;
}
.pdf-data-table.pdf-matrix-table th,
.pdf-data-table.pdf-matrix-table td {
    padding: 4px 3.5px;
}

.pdf-data-table thead th {
    background-color: #1e3a8a !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    border: 1px solid #1e3a8a !important;
    line-height: 1.25;
    vertical-align: middle;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.pdf-data-table thead th.pdf-th-subdept {
    background-color: #1e40af !important;
    font-size: 7.5pt;
    text-align: center !important;
}

.pdf-data-table tbody td {
    border: 1px solid #cbd5e1 !important;
    vertical-align: middle;
    line-height: 1.35;
    word-wrap: break-word;
    overflow-wrap: break-word;
    color: #0f172a !important;
}

.pdf-data-table tbody tr:nth-child(even) td {
    background-color: #f8fafc !important;
}

.pdf-data-table tfoot td {
    background-color: #eff6ff !important;
    border: 1px solid #94a3b8 !important;
    border-top: 2px solid #1e3a8a !important;
    border-bottom: 2px solid #1e3a8a !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    vertical-align: middle;
}

/* คลาสจัดตำแหน่งข้อความในเซลล์ตาราง PDF */
.pdf-cell-center { text-align: center !important; }
.pdf-cell-right { text-align: right !important; font-variant-numeric: tabular-nums; }
.pdf-cell-left { text-align: left !important; }

.pdf-item-code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 8pt;
    font-weight: 700;
    color: #1e3a8a;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 1px 4px;
    border-radius: 3px;
    display: inline-block;
}

.pdf-item-title {
    font-weight: 700;
    color: #0f172a;
    display: block;
    line-height: 1.25;
}

.pdf-item-sub {
    font-size: 7.5pt;
    color: #64748b;
    display: block;
    margin-top: 1px;
}

.pdf-requester-list {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 6px;
    font-size: 7.75pt;
    line-height: 1.3;
}

.pdf-requester-tag {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    padding: 0.5px 4px;
    color: #1e293b;
    display: inline-block;
}

.pdf-matrix-top-val {
    font-weight: 700;
    color: #065f46;
    background: #d1fae5;
    border: 1px solid #6ee7b7;
    border-radius: 3px;
    padding: 0.5px 3px;
    display: inline-block;
}

.pdf-status-pill {
    display: inline-block;
    padding: 1.5px 5px;
    border-radius: 4px;
    font-size: 7.75pt;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
}
.pdf-status-urgent { background: #fee2e2; color: #991b1b; border: 1px solid #f87171; }
.pdf-status-warning { background: #fef3c7; color: #92400e; border: 1px solid #fbbf24; }
.pdf-status-ok { background: #d1fae5; color: #065f46; border: 1px solid #34d399; }
.pdf-status-idle { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }

/* ส่วนลงนาม 3 ช่องท้ายกระดาษ (Official 3-Column Signatures) */
.pdf-signature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 22px;
    padding-top: 12px;
    page-break-inside: avoid;
    break-inside: avoid;
}

.pdf-sig-box {
    text-align: center;
    padding: 10px 12px;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    background: #fcfdff;
}

.pdf-sig-role-header {
    font-size: 8.5pt;
    font-weight: 700;
    color: #1e3a8a;
    margin-bottom: 26px;
}

.pdf-sig-line {
    font-size: 9pt;
    color: #334155;
    margin-bottom: 4px;
}

.pdf-sig-name {
    font-size: 9.5pt;
    font-weight: 700;
    color: #0f172a;
}

.pdf-sig-position {
    font-size: 8.5pt;
    color: #475569;
    margin-top: 1px;
}

.pdf-sig-date {
    font-size: 8pt;
    color: #64748b;
    margin-top: 4px;
}

/* ส่วนท้ายกระดาษ (Document Footer Note) */
.pdf-doc-footer {
    margin-top: 14px;
    padding-top: 6px;
    border-top: 1px solid #cbd5e1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 7.5pt;
    color: #64748b;
}

/* ========================================================
   PRINT MEDIA RULES (@media print)
   ======================================================== */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html,
    body,
    .app-container,
    .app-main,
    .content-body {
        height: auto !important;
        max-height: none !important;
        min-height: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        background: #ffffff !important;
        color: #000000 !important;
        font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif !important;
    }

    /* Common UI elements to hide when printing */
    .app-sidebar,
    .app-header,
    .demo-workflow-bar,
    .top-subnav-bar,
    .demo-bar,
    .toast-container,
    .btn,
    button,
    .report-header-actions,
    .modal-close-btn,
    .kpi-click-hint,
    .no-print,
    .pdf-studio-toolbar {
        display: none !important;
    }

    /* =========================================================
       0. โหมดพิมพ์มาตรฐานผ่านระบบ PDF Studio (#modal-pdf-preview)
       ========================================================= */
    body.printing-pdf-studio .app-container,
    body.printing-pdf-studio .modal-backdrop:not(#modal-pdf-preview),
    body.printing-pdf-studio #login-gate-overlay {
        display: none !important;
    }

    body.printing-pdf-studio #modal-pdf-preview {
        display: block !important;
        position: static !important;
        background: #ffffff !important;
        backdrop-filter: none !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    body.printing-pdf-studio .pdf-studio-container,
    body.printing-pdf-studio .pdf-studio-viewport {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
        background: #ffffff !important;
    }

    body.printing-pdf-studio .pdf-paper-sheet {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }

    .pdf-data-table {
        width: 100% !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
        page-break-inside: auto !important;
    }

    .pdf-data-table thead {
        display: table-header-group !important;
    }

    .pdf-data-table tfoot {
        display: table-row-group !important;
    }

    .pdf-data-table tr {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .pdf-signature-grid,
    .pdf-kpi-strip,
    .pdf-scope-strip {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    /* =========================================================
       1. โหมดสำรอง: พิมพ์จากหน้ารายงานฝ่ายโดยตรง (Fallback Direct Print)
       ========================================================= */
    body.printing-dept-report .content-body > section:not(#view-dept-reports),
    body.printing-dept-report .modal-backdrop,
    body.printing-dept-report #modal-procurement-report,
    body.printing-dept-report #view-dept-reports .section-title,
    body.printing-dept-report #view-dept-reports .dept-report-subtabs,
    body.printing-dept-report #view-dept-reports .dept-report-filter-bar,
    body.printing-dept-report #view-dept-reports .dept-report-actions,
    body.printing-dept-report #view-dept-reports #dept-report-all-depts-section,
    body.printing-dept-report .dept-compare-action-col {
        display: none !important;
    }

    body.printing-dept-report #view-dept-reports {
        display: block !important;
        position: static !important;
        background: #ffffff !important;
        color: #000000 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body.printing-dept-report #dept-report-print-header {
        display: block !important;
        margin-bottom: 14px !important;
    }

    body.printing-dept-report #dept-report-print-signatures {
        display: block !important;
        page-break-inside: avoid !important;
        margin-top: 28px !important;
    }

    body.printing-dept-report .stats-grid {
        display: grid !important;
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 8px !important;
        margin-bottom: 14px !important;
    }

    body.printing-dept-report .stat-card {
        background: #f8fafc !important;
        border: 1px solid #cbd5e1 !important;
        box-shadow: none !important;
        padding: 6px 10px !important;
        color: #000000 !important;
    }

    body.printing-dept-report .stat-card .stat-val {
        font-size: 12pt !important;
        color: #000000 !important;
    }

    body.printing-dept-report .table-container {
        border: 1px solid #333333 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    body.printing-dept-report #dept-report-data-table,
    body.printing-dept-report #dept-report-compare-table {
        width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
        font-size: 8.5pt !important;
    }

    body.printing-dept-report #dept-report-data-table th,
    body.printing-dept-report #dept-report-data-table td,
    body.printing-dept-report #dept-report-compare-table th,
    body.printing-dept-report #dept-report-compare-table td {
        border: 1px solid #64748b !important;
        padding: 4px 5px !important;
        color: #000000 !important;
        min-width: 0 !important;
        max-width: none !important;
        white-space: normal !important;
        word-wrap: break-word !important;
    }

    body.printing-dept-report #dept-report-data-table th,
    body.printing-dept-report #dept-report-compare-table th {
        background: #f1f5f9 !important;
        font-weight: bold !important;
    }

    body.printing-dept-report #dept-report-data-table tr,
    body.printing-dept-report #dept-report-compare-table tr {
        page-break-inside: avoid !important;
    }

    /* =========================================================
       2. โหมดสำรอง: พิมพ์รายงานจัดซื้อโดยตรง (Procurement Report Modal)
       ========================================================= */
    body.printing-procurement-report .content-body > section,
    body.printing-procurement-report .modal-backdrop:not(#modal-procurement-report),
    body.printing-procurement-report #modal-procurement-report .modal-header,
    body.printing-procurement-report #modal-procurement-report .report-filter-bar,
    body.printing-procurement-report #modal-procurement-report .modal-footer,
    body.printing-procurement-report #modal-procurement-report .modal-close-btn,
    body.printing-procurement-report .report-header-actions {
        display: none !important;
    }

    body.printing-procurement-report #modal-procurement-report {
        display: block !important;
        position: static !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        height: auto !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    body.printing-procurement-report #modal-procurement-report .modal-card {
        box-shadow: none !important;
        border: none !important;
        background: #ffffff !important;
        color: #000000 !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    body.printing-procurement-report #modal-procurement-report .modal-body {
        padding: 0 !important;
        overflow: visible !important;
    }

    body.printing-procurement-report .print-official-header {
        display: block !important;
        margin-bottom: 12px !important;
    }

    body.printing-procurement-report .print-signature-section {
        display: block !important;
        page-break-inside: avoid !important;
        margin-top: 28px !important;
    }

    body.printing-procurement-report .report-kpi-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
        margin-bottom: 14px !important;
    }

    body.printing-procurement-report .report-kpi-card {
        background: #f8fafc !important;
        border: 1px solid #cbd5e1 !important;
        box-shadow: none !important;
        padding: 8px 10px !important;
        color: #000000 !important;
    }

    body.printing-procurement-report .report-table-container {
        border: 1px solid #333333 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    body.printing-procurement-report #report-procurement-table {
        width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
        font-size: 8.75pt !important;
    }

    body.printing-procurement-report #report-procurement-table th,
    body.printing-procurement-report #report-procurement-table td {
        border: 1px solid #64748b !important;
        padding: 4.5px 6px !important;
        color: #000000 !important;
        word-wrap: break-word !important;
    }

    body.printing-procurement-report #report-procurement-table th {
        background: #f1f5f9 !important;
        font-weight: bold !important;
    }

    body.printing-procurement-report #report-procurement-table tr {
        page-break-inside: avoid !important;
    }
}

/* ========================================================
   การนำเข้าพัสดุเป็นชุด (Bulk Import Drag & Drop Styles)
   ======================================================== */
.bulk-drop-zone:hover {
    border-color: var(--primary) !important;
    background: rgba(59, 130, 246, 0.04) !important;
}

.bulk-drop-zone.dragover {
    border-color: #059669 !important;
    background: rgba(16, 185, 129, 0.08) !important;
    transform: scale(1.01);
}

.badge-import-new {
    background: #d1fae5;
    color: #065f46;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 600;
}

.badge-import-update {
    background: #fef3c7;
    color: #92400e;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 600;
}

.badge-import-skip {
    background: #e2e8f0;
    color: #475569;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10.5px;
}

.badge-import-invalid {
    background: #fee2e2;
    color: #991b1b;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 700;
}

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

.rotating {
    display: inline-block;
    animation: spin 0.8s linear infinite;
}

/* ==================== Department Material Report Styles ==================== */
.dept-report-filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.dept-report-filter-bar .filter-group-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.dept-summary-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.dept-summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.dept-summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.dept-summary-card.active-dept {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.04);
}

.dept-summary-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.dept-summary-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.dept-summary-card-stats {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-sub);
    margin-top: 6px;
}

.dept-summary-card-stats strong {
    color: var(--text-main);
    font-size: 13px;
}

.badge-price-wac {
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary);
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: 600;
    margin-left: 4px;
    display: inline-block;
}

/* ==================== Department Material Report & Comparison Styles ==================== */
.dept-report-subtabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
    flex-wrap: wrap;
}

.dept-report-subtab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dept-report-subtab-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.dept-report-subtab-btn.active {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%) !important;
    color: #ffffff !important;
    border-color: #1e3a8a !important;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.dept-report-subtab-btn .badge-chip {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.07);
    color: inherit;
    font-weight: 600;
    transition: all 0.2s ease;
}

.dept-report-subtab-btn .badge-chip-compare {
    background: rgba(16, 185, 129, 0.15);
    color: #047857;
    font-weight: 700;
}

[data-theme="dark"] .dept-report-subtab-btn .badge-chip-compare {
    background: rgba(16, 185, 129, 0.25);
    color: #34d399;
}

/* เมื่อปุ่ม Active ตัวอักษรและ Badge บนปุ่มจะเปลี่ยนเป็นสีขาวตัดกับพื้นหลังสีเข้มชัดเจน 100% */
.dept-report-subtab-btn.active .badge-chip,
.dept-report-subtab-btn.active .badge-chip-compare {
    background: rgba(255, 255, 255, 0.25) !important;
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.35);
}

/* การ์ด KPI ในหน้ารายงานที่คลิกดูเจาะลึกได้ (Interactive KPI Cards) */
.stat-card-interactive {
    cursor: pointer !important;
    position: relative;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
}

.stat-card-interactive:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.14);
    border-color: var(--primary) !important;
}

.stat-card-interactive:active {
    transform: translateY(-1px);
}

.kpi-click-hint {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
    padding: 1px 7px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    opacity: 0.85;
    transition: all 0.2s ease;
    pointer-events: none;
    user-select: none;
}

.stat-card-interactive:hover .kpi-click-hint {
    opacity: 1;
    background: var(--primary);
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

/* Comparison Table Cells & Headers */
.dept-col-header {
    text-align: right;
    min-width: 84px;
    max-width: 110px;
    padding: 8px 6px !important;
    cursor: pointer;
    user-select: none;
    vertical-align: middle;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.dept-col-header:hover {
    background: rgba(37, 99, 235, 0.08) !important;
    color: var(--primary) !important;
}

.dept-col-header.sorted {
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.16) 0%, rgba(37, 99, 235, 0.06) 100%) !important;
    color: #1e3a8a !important;
    border-bottom: 2px solid var(--primary) !important;
}

[data-theme="dark"] .dept-col-header.sorted {
    color: #93c5fd !important;
    background: rgba(37, 99, 235, 0.25) !important;
}

.dept-col-header-box {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.dept-col-icon {
    font-size: 13px;
    flex-shrink: 0;
}

.dept-col-title {
    font-size: 11.5px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dept-col-sort-pill {
    font-size: 9.5px;
    background: var(--primary);
    color: #ffffff;
    border-radius: 3px;
    padding: 1px 4px;
    font-weight: 700;
    margin-left: 2px;
}

.dept-col-sort-hint {
    font-size: 10px;
    color: #94a3b8;
    opacity: 0.5;
    margin-left: 1px;
}

.dept-col-header:hover .dept-col-sort-hint {
    opacity: 1;
    color: var(--primary);
}

/* Comparison Table Cells */
.compare-cell-val {
    font-weight: 700;
    font-size: 13px;
    color: var(--text-main);
    display: block;
}

.compare-cell-top {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: 5px;
    padding: 3px 6px;
    color: #047857;
    font-weight: 700;
    display: inline-block;
}

[data-theme="dark"] .compare-cell-top {
    background: rgba(16, 185, 129, 0.25);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.5);
}

.compare-cell-zero {
    color: var(--text-light, #94a3b8);
    font-size: 12px;
}

.compare-bar-track {
    width: 100%;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

[data-theme="dark"] .compare-bar-track {
    background: #334155;
}

.compare-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--primary);
    transition: width 0.3s ease;
}

/* Item Deep Dive Comparison Modal Styles */
.item-drilldown-kpi {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.item-drilldown-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
}

.item-drilldown-bar-row:hover {
    background: var(--bg-secondary);
}

.item-drilldown-bar-label {
    min-width: 160px;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.item-drilldown-bar-outer {
    flex: 1;
    height: 14px;
    background: #e2e8f0;
    border-radius: 7px;
    overflow: hidden;
}

[data-theme="dark"] .item-drilldown-bar-outer {
    background: #334155;
}

.item-drilldown-bar-inner {
    height: 100%;
    border-radius: 7px;
    transition: width 0.4s ease;
}

.item-drilldown-bar-stat {
    min-width: 130px;
    text-align: right;
    font-size: 13px;
    font-weight: 600;
}

/* KPI Drilldown Modal Styles */
.kpi-drilldown-highlight-box {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.kpi-drilldown-mini-card {
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.kpi-drilldown-mini-card .label {
    font-size: 12px;
    color: var(--text-sub);
    font-weight: 600;
    margin-bottom: 4px;
}

.kpi-drilldown-mini-card .val {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-main);
}

.kpi-drilldown-section-title {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-main);
    margin: 18px 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kpi-drilldown-bar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.kpi-drilldown-bar-name {
    min-width: 170px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.kpi-drilldown-bar-track {
    flex: 1;
    height: 12px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

[data-theme="dark"] .kpi-drilldown-bar-track {
    background: #334155;
}

.kpi-drilldown-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.4s ease;
}

.kpi-drilldown-bar-stat {
    min-width: 140px;
    text-align: right;
    font-size: 13px;
    font-weight: 700;
}

/* ==================== Inventory, Stock History & Budget Hub Styles ==================== */

/* 1. ปุ่มแก้ไขและลบในการจัดการคลัง: ขนาดใหญ่ อยู่บรรทัดเดียวกัน มีระยะห่างชัดเจน ไม่กดพลาด */
.inv-action-cell {
    min-width: 295px;
    width: 295px;
    text-align: center !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
}

.inv-action-btn-group {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.btn-inv-edit,
.btn-inv-delete,
.btn-inv-history {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 38px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.2;
}

.btn-inv-history {
    background: #f0fdf4;
    color: #15803d;
    border: 1.5px solid #86efac;
    box-shadow: 0 1px 2px rgba(22, 163, 74, 0.08);
}

.btn-inv-history:hover {
    background: #16a34a;
    color: #ffffff;
    border-color: #15803d;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(22, 163, 74, 0.22);
}

[data-theme="dark"] .btn-inv-history {
    background: rgba(16, 185, 129, 0.18);
    color: #86efac;
    border-color: rgba(16, 185, 129, 0.45);
}

[data-theme="dark"] .btn-inv-history:hover {
    background: #10b981;
    color: #ffffff;
}

.btn-inv-edit {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1.5px solid #93c5fd;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08);
}

.btn-inv-edit:hover {
    background: #2563eb;
    color: #ffffff;
    border-color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.22);
}

.btn-inv-delete {
    background: #fef2f2;
    color: #dc2626;
    border: 1.5px solid #fca5a5;
    box-shadow: 0 1px 2px rgba(220, 38, 38, 0.08);
}

.btn-inv-delete:hover {
    background: #dc2626;
    color: #ffffff;
    border-color: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.22);
}

[data-theme="dark"] .btn-inv-edit {
    background: rgba(37, 99, 235, 0.18);
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.45);
}

[data-theme="dark"] .btn-inv-edit:hover {
    background: #2563eb;
    color: #ffffff;
}

[data-theme="dark"] .btn-inv-delete {
    background: rgba(220, 38, 38, 0.18);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.45);
}

[data-theme="dark"] .btn-inv-delete:hover {
    background: #dc2626;
    color: #ffffff;
}

/* 2. กล่องระบุวันที่เติมสต๊อกและป้ายแสดงวันที่เติมสต๊อกย้อนหลัง */
.inv-date-record-box {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(16, 185, 129, 0.06));
    border: 1.5px solid rgba(37, 99, 235, 0.25);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.inv-date-box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
}

.inv-date-mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.inv-date-mode-badge.mode-edit {
    background: rgba(37, 99, 235, 0.14);
    color: #2563eb;
    border-color: rgba(37, 99, 235, 0.3);
}

.stock-date-cell-wrap {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.stock-date-cell-wrap:hover {
    background: rgba(37, 99, 235, 0.08);
}

.stock-date-main {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
}

.tx-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    white-space: nowrap;
}

.tx-badge-new {
    background: rgba(37, 99, 235, 0.12);
    color: #2563eb;
    border: 1px solid rgba(37, 99, 235, 0.25);
}

.tx-badge-refill {
    background: rgba(16, 185, 129, 0.14);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.28);
}

.tx-badge-adjust {
    background: rgba(245, 158, 11, 0.14);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.28);
}

/* 3. แถบตัวกรองช่วงเวลางบประมาณ (รายวัน / รายสัปดาห์ / รายเดือน / รายเทอม / รายปี) */
.inv-budget-period-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.inv-period-left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.inv-period-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
}

.inv-period-pills {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.inv-period-pill {
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.inv-period-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(37, 99, 235, 0.06);
}

.inv-period-pill.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.inv-period-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* 4. การ์ดสรุปงบประมาณและมูลค่าคลังพัสดุ (Inventory Budget KPI Grid) */
.inv-budget-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.inv-budget-kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.inv-budget-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.inv-kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    background: rgba(37, 99, 235, 0.1);
}

.kpi-stock-val .inv-kpi-icon {
    background: rgba(139, 92, 246, 0.12);
}

.kpi-refill-budget .inv-kpi-icon {
    background: rgba(37, 99, 235, 0.12);
}

.kpi-disbursed-budget .inv-kpi-icon {
    background: rgba(16, 185, 129, 0.12);
}

.kpi-procurement-plan .inv-kpi-icon {
    background: rgba(239, 68, 68, 0.12);
}

.inv-kpi-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.inv-kpi-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-sub);
}

.inv-kpi-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-main);
    margin: 2px 0;
    font-variant-numeric: tabular-nums;
}

.inv-kpi-sub {
    font-size: 11.5px;
    color: var(--text-sub);
}

/* 5. แท็บสลับมุมมองย่อยในหน้าคลังพัสดุ (Inventory Sub-tabs) */
.inv-subtabs-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.inv-subtab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-sub);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.inv-subtab-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.inv-subtab-btn.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.22);
}

.inv-tab-badge {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(37, 99, 235, 0.12);
    color: var(--primary);
}

.inv-subtab-btn.active .inv-tab-badge {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

/* 6. แผงสรุปงบประมาณแยกตามหมวดหมู่พัสดุ */
.inv-category-budget-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.inv-cat-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

.inv-cat-panel-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

.inv-cat-panel-header p {
    margin: 2px 0 0 0;
    font-size: 12px;
    color: var(--text-sub);
}

.inv-category-budget-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 12px;
}

.inv-cat-budget-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    transition: border-color 0.18s ease;
}

.inv-cat-budget-card:hover {
    border-color: var(--primary);
}

.inv-cat-budget-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.inv-cat-budget-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-sub);
    margin-top: 4px;
}

.inv-cat-budget-row strong {
    font-variant-numeric: tabular-nums;
}

/* 7. แถบสรุปหน้าประวัติการเติมสต๊อกย้อนหลัง */
.inv-refill-summary-banner {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.07), rgba(16, 185, 129, 0.07));
    border: 1px solid rgba(37, 99, 235, 0.22);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

/* ==================== 8. Material Procurement & Price Movement History Modal Styles ==================== */
.mph-quick-select-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* 4-Pillar Executive Stat Strip */
.mph-stat-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}

@media (max-width: 960px) {
    .mph-stat-strip {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 540px) {
    .mph-stat-strip {
        grid-template-columns: 1fr;
    }
}

.mph-stat-pillar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mph-stat-pillar:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.mph-stat-pillar-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.mph-stat-pillar-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.mph-stat-pillar-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-sub);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mph-stat-pillar-val-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 2px 0;
    flex-wrap: wrap;
}

.mph-stat-pillar-val {
    margin: 0;
    font-size: 17.5px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.mph-stat-pillar-badge {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    font-weight: 700;
}

.mph-stat-pillar-sub {
    font-size: 10.5px;
    color: var(--text-sub);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Control Toolbar & Toggles */
.mph-control-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.mph-view-toggles {
    display: inline-flex;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 3px;
    gap: 4px;
}

.mph-btn-toggle {
    border: none;
    background: transparent;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-sub);
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.mph-btn-toggle:hover {
    color: var(--text-main);
}

.mph-btn-toggle.active {
    background: var(--bg-card);
    color: var(--primary);
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.mph-chart-metric-toggles {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.mph-btn-pill {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-sub);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mph-btn-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.mph-btn-pill.active {
    background: rgba(37, 99, 235, 0.1);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 700;
}

/* Chart Section & Legends */
.mph-section-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
}

.mph-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.mph-chart-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-sub);
    flex-wrap: wrap;
}

.mph-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mph-legend-line {
    width: 18px;
    height: 3px;
    border-radius: 2px;
}

.mph-legend-line.price-line {
    background: #2563eb;
}

.mph-legend-line.wac-line {
    border-top: 2.5px dashed #7c3aed;
    height: 0;
}

.mph-legend-bar.volume-bar {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: rgba(16, 185, 129, 0.35);
    border: 1px solid #10b981;
}

.mph-chart-canvas-wrap {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px 4px 12px;
    overflow: hidden;
}

/* Tooltip ลอยอัจฉริยะสำหรับกราฟ */
.mph-chart-tooltip {
    position: absolute;
    z-index: 25;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 9px 13px;
    font-size: 11.5px;
    pointer-events: none;
    line-height: 1.45;
    transform: translate(-50%, -100%);
    margin-top: -12px;
    transition: opacity 0.15s ease, transform 0.15s ease;
    min-width: 190px;
}

.mph-chart-node {
    cursor: pointer;
    transition: r 0.15s ease;
}

.mph-chart-node:hover {
    r: 8px;
}

.mph-chart-bar {
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.mph-chart-bar:hover {
    opacity: 0.9;
}

/* Difference Pills */
.mph-diff-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
}

.mph-diff-cheaper {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.mph-diff-expensive {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.mph-diff-same {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
}

.mph-diff-first {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #7dd3fc;
}

[data-theme="dark"] .mph-diff-cheaper {
    background: rgba(16, 185, 129, 0.2);
    color: #86efac;
    border-color: rgba(16, 185, 129, 0.4);
}

[data-theme="dark"] .mph-diff-expensive {
    background: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
    border-color: rgba(220, 38, 38, 0.4);
}

[data-theme="dark"] .mph-diff-same {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
    border-color: rgba(100, 116, 139, 0.4);
}

[data-theme="dark"] .mph-diff-first {
    background: rgba(37, 99, 235, 0.2);
    color: #93c5fd;
    border-color: rgba(37, 99, 235, 0.4);
}

/* Compact Table & Row Highlighting */
.mph-compact-table tr {
    transition: background 0.2s ease;
}

.mph-compact-table tr.mph-row-highlight {
    background: rgba(37, 99, 235, 0.12) !important;
}

.mph-latest-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    background: #2563eb;
    color: #ffffff;
    padding: 1px 5px;
    border-radius: 4px;
    margin-left: 4px;
}




