/* ==========================================================================
   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;
}

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

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. แผงจำลองสถานะผู้นำเสนอ (Demo Switcher Bar) */
.demo-switcher-bar {
    background: linear-gradient(135deg, #1e1b4b 0%, #311042 100%);
    color: white;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
    position: sticky;
    top: 0;
}

.demo-switcher-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    flex-wrap: wrap;
    gap: 8px;
}

.demo-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.demo-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

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

.demo-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.demo-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 0 10px rgba(79, 70, 229, 0.4);
}

/* ส่วนจำลองหัวหน้าฝ่าย Dropdown ใน Switcher */
.dept-head-selector-wrapper {
    position: relative;
}

.dept-head-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--border-radius-md);
    margin-top: 5px;
    width: 260px;
    display: none;
    flex-direction: column;
    max-height: 300px;
    overflow-y: auto;
    z-index: 101;
    box-shadow: var(--shadow-lg);
}

.dept-head-dropdown.show {
    display: flex;
}

.dept-head-option {
    padding: 8px 12px;
    color: #cbd5e1;
    font-size: 12px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    width: 100%;
    display: flex;
    justify-content: space-between;
    transition: all var(--transition-fast);
}

.dept-head-option:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.dept-head-option.active {
    background: rgba(79, 70, 229, 0.2);
    color: var(--primary-light);
    font-weight: bold;
}

/* 4. โครงสร้าง Layout หลัก (App Container) */
.app-container {
    display: flex;
    flex: 1;
    height: calc(100vh - 43px); /* หักความสูงของ Demo bar */
    overflow: hidden;
}

/* เมนูด้านข้าง (Sidebar) */
.app-sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
    transition: width var(--transition-normal);
}

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

.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;
}

.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;
}

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

/* พื้นที่โปรไฟล์ผู้ใช้งานด้านล่างสไลด์บาร์ */
.sidebar-profile {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background-color: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
}

.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;
}

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

/* ส่วนหัวหลัก (Header) */
.app-header {
    height: 60px;
    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;
}

.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;
}

.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;
}

.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: 140px 1fr 40px;
    align-items: center;
    gap: 12px;
}

.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;
}

/* รายชื่อไอเทมเบิกบ่อย */
.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: 14px 16px;
    font-weight: 600;
    color: var(--text-sub);
    border-bottom: 1px solid var(--border-color);
}

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;
}

.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);
}

.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;
}

.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;
}

.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; }

/* ==================== หน้ารายการรออนุมัติและคลังพัสดุ (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;
    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;
}

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

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.6);
    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;
}

.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) {
    .app-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    
    .app-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .sidebar-brand {
        padding: 10px 16px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .brand-logo {
        width: 32px;
        height: 32px;
    }
    
    .brand-info h1 {
        font-size: 14px;
    }
    
    .brand-info .sub-brand {
        font-size: 9px;
    }
    
    .sidebar-menu {
        flex-direction: row;
        overflow-x: auto;
        padding: 6px 12px;
        gap: 6px;
        -webkit-overflow-scrolling: touch;
    }
    
    .menu-item {
        padding: 6px 10px;
        white-space: nowrap;
        font-size: 11px;
        border-radius: var(--border-radius-sm);
    }
    
    .menu-item.active::before {
        display: none;
    }
    
    .sidebar-profile {
        padding: 10px 16px !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.05);
    }
    
    .sidebar-profile > div:first-child {
        width: auto !important;
    }
    
    .profile-actions {
        width: auto !important;
        margin-top: 0 !important;
        flex-direction: row !important;
    }
    
    .profile-actions .btn {
        padding: 4px 8px !important;
        font-size: 10px !important;
    }
    
    .app-main {
        overflow: visible;
        padding: 16px 12px;
    }
    
    .app-header {
        padding: 10px 8px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .header-actions {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .approval-filter-bar, .inventory-filter-bar, .history-filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .filter-controls {
        flex-direction: column;
        gap: 8px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .modal-card {
        width: 95% !important;
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* ==================== สไตล์สำหรับระบบตะกร้าเบิกหลายรายการ (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;
}

