/* ===== BASE STYLES & CROSS-PLATFORM SYSTEM (Windows, Mac, iOS, Android) ===== */
:root {
    --primary: #0284c7; /* Cyan / Blue */
    --primary-dark: #0369a1;
    --primary-light: #38bdf8;
    --secondary: #0ea5e9; 
    --background: #f0f9ff; /* Light Blue */
    --surface: rgba(255, 255, 255, 0.88);
    --surface-light: rgba(255, 255, 255, 0.65);
    --surface-border: rgba(224, 242, 254, 0.85);
    --text-main: #0f172a; /* Slate 900 */
    --text-muted: #475569; /* Slate 600 */
    
    /* Severity Colors */
    --sev-nhe: #3B82F6;
    --sev-nang: #F59E0B;
    --sev-nghiemtrong: #EF4444;

    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --radius-full: 9999px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== DARK MODE COLOR SYSTEM ===== */
[data-theme="dark"] {
    --primary: #38bdf8; /* Lighter cyan-blue for dark backgrounds */
    --primary-dark: #0284c7;
    --primary-light: #7dd3fc;
    --secondary: #0ea5e9;
    --background: #090e1a; /* Midnight navy */
    --surface: rgba(15, 23, 42, 0.90);
    --surface-light: rgba(30, 41, 59, 0.85);
    --surface-border: rgba(51, 65, 85, 0.75);
    --text-main: #f8fafc; /* Crisp white */
    --text-muted: #94a3b8; /* Slate 400 */
    
    color-scheme: dark;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: rgba(2, 132, 199, 0.1);
    border: 1px solid rgba(2, 132, 199, 0.25);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary);
    font-size: 18px;
    transition: var(--transition);
    outline: none;
    flex-shrink: 0;
    margin-right: 2px;
}

.theme-toggle-btn:hover {
    background: rgba(2, 132, 199, 0.22);
    transform: rotate(20deg) scale(1.08);
}

[data-theme="dark"] .theme-toggle-btn {
    background: rgba(253, 224, 71, 0.15);
    border-color: rgba(253, 224, 71, 0.35);
    color: #fde047; /* Yellow sun */
}

[data-theme="dark"] .theme-toggle-btn:hover {
    background: rgba(253, 224, 71, 0.28);
    transform: rotate(45deg) scale(1.08);
}

/* Universal Reset & Tap Optimization */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* Unified Slim Scrollbars for Windows, Mac & Linux */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(2, 132, 199, 0.35) transparent;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(2, 132, 199, 0.35);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(2, 132, 199, 0.65);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-image: url('background.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-color: var(--background); /* Fallback */
    color: var(--text-main);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Background gradient blobs */
.bg-shape {
    display: none;
}

/* ===== MAIN APP LAYOUT ===== */
.app-container {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    gap: 20px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* ===== SIDEBAR NAVIGATION ===== */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 26px 18px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 35px rgba(2, 132, 199, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    position: sticky;
    top: 20px;
    height: calc(100vh - 40px);
    height: calc(100dvh - 40px);
    z-index: 50;
    transition: var(--transition);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), #8B5CF6);
    border-radius: var(--radius-md);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(2, 132, 199, 0.35);
    flex-shrink: 0;
}

.logo h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
    padding-right: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 14.5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    width: 100%;
    font-family: inherit;
    min-height: 44px;
}

.nav-item i {
    font-size: 22px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.65);
    color: var(--primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.12);
    font-weight: 600;
    border-left: 3px solid var(--primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 18px;
    border-top: 1px solid var(--surface-border);
    margin-top: auto;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

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

.user-info .role {
    font-size: 12.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 20px;
    text-decoration: none;
    transition: var(--transition);
    background: transparent;
    flex-shrink: 0;
}

.logout-btn:hover {
    color: #EF4444;
    background: rgba(239, 68, 68, 0.1);
}

/* ===== MAIN CONTENT AREA ===== */
.main-content {
    flex: 1;
    min-width: 0; /* Crucial for preventing flex children from overflowing on Windows/Mac */
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
}

.top-bar {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 8px 30px rgba(2, 132, 199, 0.05);
    flex-wrap: wrap;
    gap: 15px;
}

.top-bar h1 {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(to right, var(--primary), #8B5CF6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.01em;
}

.search-bar {
    position: relative;
    width: 300px;
    max-width: 100%;
}

.search-bar i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
    pointer-events: none;
}

.search-bar input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
    font-family: inherit;
}

.search-bar input:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
    min-width: 0;
}

/* Sections & Tabs */
.tab-content {
    display: none;
    animation: fadeIn 0.35s ease-out;
}

.tab-content.active {
    display: block;
}

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

/* ===== GLASS PANELS & CARDS ===== */
.glass-panel {
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
}

.glass-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
}

.glass-card:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 12px 25px rgba(2, 132, 199, 0.08);
}

/* Heading & Subtitle styles */
.glass-panel h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 13.5px;
    line-height: 1.45;
    margin-bottom: 16px;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    min-height: 40px;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #0369a1);
    color: white;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0284c7, #0ea5e9);
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #e2e8f0;
    color: #1e293b;
    border: 1px solid #cbd5e1;
}

.btn-secondary:hover {
    background: #cbd5e1;
    color: #0f172a;
    border-color: #94a3b8;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

/* ===== BADGES ===== */
.badge {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-lldpe { background: #e0f2fe; color: #0284c7; }
.badge-hdpe { background: #dcfce7; color: #16a34a; }
.badge-mpe { background: #f3e8ff; color: #9333ea; }
.badge-bopp { background: #fef9c3; color: #ca8a04; }

.badge.severity.sev-nhe { background: var(--sev-nhe); color: white; }
.badge.severity.sev-nang { background: var(--sev-nang); color: white; }
.badge.severity.sev-nghiemtrong { background: var(--sev-nghiemtrong); color: white; }

/* ===== RESPONSIVE DATA TABLE CONTAINER ===== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    margin-top: 15px;
    margin-bottom: 15px;
}

.styled-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-main);
    text-align: left;
    font-size: 13.5px;
    min-width: 600px; /* Ensures nice horizontal scroll on small devices */
}

.styled-table th, .styled-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.styled-table th {
    background: rgba(2, 132, 199, 0.08);
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
}

.styled-table tbody tr:hover {
    background: rgba(2, 132, 199, 0.04);
}

/* ===== MATERIALS DOCUMENTS DATA TABLE ===== */
.local-search-bar {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-full);
    padding: 8px 16px;
    width: 320px;
    max-width: 100%;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
}

.local-search-bar i {
    color: var(--text-muted);
    font-size: 18px;
    margin-right: 8px;
    flex-shrink: 0;
}

.local-search-bar input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    color: var(--text-main);
    font-size: 13.5px;
    font-family: inherit;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-md);
    overflow: hidden;
    min-width: 900px;
}

.data-table th, .data-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    color: var(--text-main);
    font-size: 12px;
}

.data-table th {
    background: #0284c7;
    font-weight: 700;
    color: #fff;
    font-size: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    vertical-align: middle;
}

.data-table .sub-header-row th {
    background: #38bdf8;
    color: #0f172a;
    font-size: 11px;
}

.data-table tbody tr {
    transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
    background: rgba(2, 132, 199, 0.06);
}

.data-table td.center, .data-table th.center {
    text-align: center;
}

.pdf-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    background: transparent;
    color: #ef4444;
    font-size: 18px;
    transition: all 0.25s ease;
    text-decoration: none;
}

.pdf-link:hover {
    background: #ef4444;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(239, 68, 68, 0.3);
}

/* ===== FORM CONTROLS & GRIDS ===== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text-main);
}

.form-group input, 
.form-group select, 
.form-group textarea {
    padding: 10px 14px;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
    font-family: inherit;
    color: var(--text-main);
    -webkit-appearance: none;
    appearance: none;
}

@media (max-width: 768px) {
    .form-group input, 
    .form-group select, 
    .form-group textarea {
        font-size: 16px; /* iOS auto-zoom prevention */
    }
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* ===== CALCULATION SUB-TABS (Segmented Control phong cách Hiện đại, Thăng bằng đều, Haptic Touch) ===== */
.calc-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    background: rgba(2, 132, 199, 0.05);
    border: 1px solid var(--surface-border);
    border-radius: 14px;
    padding: 6px;
    margin-bottom: 22px;
    overflow: hidden;
    box-sizing: border-box;
    user-select: none;
}

.calc-tab-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.65);
    border-radius: 10px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    width: 100%;
    min-width: 0;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.calc-tab-btn i {
    font-size: 18px;
    transition: transform 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.calc-tab-btn .calc-tab-label-short {
    display: none;
}

.calc-tab-btn .calc-tab-label-full {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calc-tab-btn:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(2, 132, 199, 0.15);
}

.calc-tab-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, #0284c7 100%);
    color: white;
    font-weight: 700;
    border-color: rgba(2, 132, 199, 0.3);
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.calc-tab-btn.active i {
    transform: scale(1.1);
    color: #ffffff;
}

/* Hiệu ứng chạm Haptic trực quan (Visual Haptic Touch Feedback) */
.calc-tab-btn:active {
    transform: scale(0.93) translateY(1px);
    transition: transform 0.08s cubic-bezier(0.2, 0, 0.2, 1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

/* ===== CHATBOT STYLES ===== */
.chatbot-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px);
    height: calc(100dvh - 160px);
    min-height: 480px;
    padding: 0;
    overflow: hidden;
    border-radius: var(--radius-lg);
}

.chatbot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--surface-border);
    background: rgba(255, 255, 255, 0.6);
    flex-wrap: wrap;
    gap: 12px;
}

.chatbot-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-title i {
    font-size: 26px;
    color: var(--primary);
    background: white;
    padding: 8px;
    border-radius: 50%;
    box-shadow: 0 3px 8px rgba(0,0,0,0.06);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: rgba(240, 249, 255, 0.3);
}

.message {
    display: flex;
    max-width: 82%;
    animation: fadeIn 0.3s ease-out;
}

.message-content {
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.user-message {
    align-self: flex-end;
}

.user-message .message-content {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message {
    align-self: flex-start;
}

.ai-message .message-content {
    background: white;
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--surface-border);
}

.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.7);
    border-top: 1px solid var(--surface-border);
    align-items: center;
}

.chat-input-area textarea {
    flex: 1;
    padding: 10px 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--surface-border);
    outline: none;
    resize: none;
    font-size: 14.5px;
    font-family: inherit;
    background: white;
    min-height: 42px;
    max-height: 120px;
}

@media (max-width: 768px) {
    .chat-input-area textarea {
        font-size: 16px;
    }
}

/* ===== PRODUCT CATALOG & MODAL ===== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.product-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0,0,0,0.05);
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 25px rgba(2, 132, 199, 0.15);
}

.product-img-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #fff;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-img-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-title {
    padding: 14px 12px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    border-top: 1px solid #f1f5f9;
}

/* Modal Windows */
.modal, .modal-overlay {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal.show, .modal-overlay.show {
    display: flex;
    animation: fadeIn 0.25s ease-out;
}

.modal-content {
    background: white !important;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    position: relative;
    padding: 30px;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    box-sizing: border-box;
}

.close-modal, .close-btn {
    position: absolute;
    top: 16px;
    right: 18px;
    font-size: 28px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
    z-index: 10;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-modal:hover, .close-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* ===== RESPONSIVE MEDIA QUERIES ===== */

/* Tablet & Smaller Laptops (<= 1024px) */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        padding: 12px 10px;
        gap: 14px;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        height: auto;
        position: sticky;
        top: 10px;
        padding: 14px 16px;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        border-radius: var(--radius-md);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    }

    .logo {
        margin-bottom: 0;
        flex: 1;
    }

    .logo h2 {
        font-size: 16px;
    }

    .user-profile {
        margin-left: auto;
        padding-top: 0;
        border-top: none;
        margin-top: 0;
    }

    .user-info {
        display: none; /* Hide detailed role text on compact bar, keep avatar + logout */
    }

    .nav-menu {
        flex-direction: row;
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
        margin-top: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    .nav-menu::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        padding: 8px 14px;
        flex: 0 0 auto;
        border-radius: var(--radius-full);
        font-size: 13px;
        background: rgba(255, 255, 255, 0.6);
        min-height: 38px;
        width: auto;
        border-left: none;
    }

    .nav-item i {
        font-size: 18px;
    }

    .nav-item span {
        display: inline-block;
        white-space: nowrap;
    }

    .nav-item.active {
        background: var(--primary);
        color: white;
        box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
    }

    .top-bar {
        padding: 14px 18px;
        border-radius: var(--radius-md);
    }

    .top-bar h1 {
        font-size: 19px;
    }
}

/* Mobile Devices (<= 768px) */
@media (max-width: 768px) {
    .app-container {
        padding: 8px 6px;
        gap: 10px;
    }

    .glass-panel {
        padding: 16px 12px;
        border-radius: var(--radius-md);
    }

    .glass-card {
        padding: 14px;
    }

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 12px 14px;
    }

    .search-bar {
        width: 100%;
    }

    .chatbot-container {
        height: calc(100vh - 140px);
        height: calc(100dvh - 140px);
        min-height: 420px;
    }

    .chatbot-header {
        padding: 12px 14px;
    }

    .chat-messages {
        padding: 14px 10px;
    }

    .message {
        max-width: 92%;
    }

    .chat-input-area {
        padding: 10px 12px;
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .modal-content {
        padding: 22px 14px;
        border-radius: var(--radius-md);
    }
}

/* Small Mobile Devices (<= 400px) */
@media (max-width: 400px) {
    .product-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding: 10px 12px;
    }

    .logo-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .nav-item {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* ===== AGENDA / TIMELINE SCHEDULE VIEW (STYLE THEO FILE ĐÍNH KÈM) ===== */
.timeline-hero-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    padding: 8px 4px 6px 4px;
    margin-bottom: 2px;
}

.timeline-hero-date {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timeline-hero-month {
    font-size: 13px;
    font-weight: 800;
    color: #0284c7;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.timeline-hero-day {
    font-size: 26px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.2;
    margin: 0;
}

.timeline-hero-watermark {
    font-size: 60px;
    font-weight: 800;
    color: #cbd5e1;
    opacity: 0.55;
    line-height: 0.85;
    user-select: none;
    letter-spacing: -2px;
    font-family: inherit;
}

.timeline-hero-divider {
    height: 1.5px;
    background: #e2e8f0;
    width: 100%;
    margin-bottom: 22px;
}

/* View Switcher */
.task-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.view-switch-btns {
    display: inline-flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--surface-border);
}

.btn-view-mode {
    background: transparent;
    border: none;
    outline: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-view-mode.active {
    background: #ffffff;
    color: var(--primary-dark);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* Timeline Stream Container (Chỉ trượt lên và xuống, không trượt trái phải) */
.timeline-stream-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    padding: 4px 0 24px 0;
}

.timeline-item {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    padding-bottom: 24px;
}

/* Time / Due Date Column on Left */
.timeline-time-col {
    width: 66px;
    min-width: 66px;
    padding-right: 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    position: relative;
    flex-shrink: 0;
}

.timeline-due-label {
    font-size: 8px;
    font-weight: 800;
    color: #64748b;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 2px;
    white-space: nowrap;
}

.timeline-time-val {
    font-size: 15px;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.1;
    white-space: nowrap;
}

.timeline-time-ampm {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    margin-top: 3px;
}

.timeline-date-tag {
    font-size: 8.5px;
    color: var(--primary, #0284c7);
    background: rgba(2, 132, 199, 0.1);
    border: 1px solid rgba(2, 132, 199, 0.25);
    padding: 1.5px 5px;
    border-radius: 4px;
    margin-top: 4px;
    font-weight: 700;
    white-space: nowrap;
    display: inline-block;
    line-height: 1.2;
    letter-spacing: 0.2px;
}

.timeline-date-tag.overdue {
    color: #ef4444;
    background: #fef2f2;
    border-color: rgba(239, 68, 68, 0.35);
}

/* The vertical connecting line stem */
.timeline-stem-line {
    position: absolute;
    top: 32px;
    bottom: -8px;
    right: -1px;
    width: 2px;
    background: #e2e8f0;
}

.timeline-item:last-child .timeline-stem-line {
    display: none;
}

/* Card Column on Right */
.timeline-card-col {
    flex: 1;
    min-width: 0;
}

.timeline-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 5px solid #0284c7;
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    width: 100%;
}

.timeline-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

/* Status variants for left border and light tinted background */
.timeline-card.status-inprogress {
    border-left-color: #0284c7;
    background: rgba(240, 249, 255, 0.75);
}

.timeline-card.status-todo {
    border-left-color: #0ea5e9;
    background: #ffffff;
}

.timeline-card.status-testing {
    border-left-color: #8b5cf6;
    background: rgba(250, 245, 255, 0.75);
}

.timeline-card.status-done {
    border-left-color: #10b981;
    background: rgba(240, 253, 244, 0.75);
}

.timeline-card.is-overdue {
    border-left-color: #ef4444 !important;
}

/* Top Badge Pill Row */
.timeline-badge-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.tl-pill {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 3.5px 11px;
    font-size: 11px;
    font-weight: 700;
    color: #334155;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.tl-pill-project {
    background: rgba(2, 132, 199, 0.08);
    color: #0369a1;
    border: 1px solid rgba(2, 132, 199, 0.2);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 11.5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tl-pill-id {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 7px;
    border-radius: 4px;
    font-family: monospace;
}

.tl-pill-priority {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* Card Title */
.timeline-card-title {
    font-size: 17.5px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.4;
    margin-bottom: 12px;
    word-break: break-word;
}

/* Bullet points list */
.timeline-bullets {
    list-style: none;
    padding: 0;
    margin: 0 0 14px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-bullets li {
    position: relative;
    padding-left: 20px;
    font-size: 13.5px;
    line-height: 1.5;
    color: #334155;
    word-break: break-word;
}

.timeline-bullets li::before {
    content: "•";
    position: absolute;
    left: 5px;
    top: -1px;
    font-size: 17px;
    color: #475569;
    font-weight: 700;
}

/* Highlight Banner Callout at bottom */
.timeline-highlight-banner {
    border-radius: 10px;
    padding: 10px 14px;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.timeline-highlight-banner.banner-cyan {
    background: #0284c7;
}

.timeline-highlight-banner.banner-navy {
    background: #0f2b48;
}

.timeline-highlight-banner.banner-green {
    background: #059669;
}

.timeline-highlight-banner.banner-purple {
    background: #7c3aed;
}

.timeline-highlight-banner.banner-red {
    background: #dc2626;
}

.banner-star-icon {
    font-size: 17px;
    flex-shrink: 0;
}

.banner-body-text {
    font-size: 13px;
    line-height: 1.45;
    flex: 1;
}

.banner-body-text strong {
    font-weight: 700;
}

/* Card Action Footer */
.timeline-card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-wrap: wrap;
    gap: 8px;
}

.timeline-assignee-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

.timeline-action-btns {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== KANBAN BOARD & TO-DO LIST MODULE ===== */
.kanban-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.kanban-stat-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s, box-shadow 0.2s;
}

.kanban-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

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

.kanban-stat-info .stat-num {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.kanban-stat-info .stat-lbl {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.task-toolbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-bottom: 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

/* Mobile Bottom Navigation Bar (Mặc định ẩn trên màn hình lớn Desktop) */
.mobile-bottom-nav {
    display: none;
}

.task-toolbar .filter-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    flex: 1;
}

.task-search-box {
    position: relative;
    min-width: 220px;
    flex: 1;
    max-width: 320px;
}

.task-search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
    pointer-events: none;
}

.task-search-input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.9);
    outline: none;
    transition: var(--transition);
}

.task-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.custom-select {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--surface-border);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--text-main);
    outline: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.custom-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(280px, 1fr));
    gap: 18px;
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: 15px;
}

@media (max-width: 1200px) {
    .kanban-board {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

.kanban-column {
    background: rgba(241, 245, 249, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px dashed transparent;
    border-radius: var(--radius-md);
    padding: 14px;
    min-height: 480px;
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.kanban-column.drag-over {
    border-color: var(--primary);
    background: rgba(224, 242, 254, 0.85);
    transform: scale(1.01);
}

.kanban-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    font-weight: 700;
    font-size: 14.5px;
    color: var(--text-main);
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.05);
}

.kanban-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kanban-title-wrap i {
    font-size: 16px;
}

.kanban-badge {
    background: white;
    color: var(--text-muted);
    padding: 2px 9px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--surface-border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.task-list {
    min-height: 400px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.task-list.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
    border: 1px dashed rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    padding: 20px;
}

.task-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 14px;
    cursor: grab;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.18s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.18s ease;
    user-select: none;
    position: relative;
}

.task-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 18px rgba(0,0,0,0.08);
    border-color: rgba(2, 132, 199, 0.4);
}

.task-card.dragging {
    opacity: 0.45;
    cursor: grabbing;
    transform: scale(0.96);
    box-shadow: 0 12px 24px rgba(0,0,0,0.15);
}

.task-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}

.task-id-tag {
    font-size: 11px;
    font-weight: 700;
    color: #0369a1;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    letter-spacing: 0.2px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.task-project-tag {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--primary-dark);
    background: rgba(2, 132, 199, 0.1);
    padding: 2px 7px;
    border-radius: 4px;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.priority-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.priority-Gấp, .priority-Gap {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}

.priority-Cao {
    background: #fef3c7;
    color: #d97706;
    border: 1px solid #fcd34d;
}

.priority-Bình-thường, .priority-Binh-thuong, .priority-Normal {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.task-title {
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.45;
    color: var(--text-main);
    word-break: break-word;
}

.task-notes {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.4;
    background: rgba(248, 250, 252, 0.8);
    padding: 6px 8px;
    border-radius: 6px;
    border-left: 3px solid var(--primary-light);
    word-break: break-word;
}

.task-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding-top: 8px;
    margin-top: 6px;
}

.task-assignee {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    color: var(--text-main);
}

.avatar-sm {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(2, 132, 199, 0.3);
}

.task-due {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
}

.task-due.overdue {
    color: #dc2626;
    font-weight: 700;
    background: #fee2e2;
    padding: 2px 6px;
    border-radius: 4px;
}

.task-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px dashed rgba(0, 0, 0, 0.06);
    justify-content: flex-end;
}

.task-actions .custom-select {
    padding: 3px 6px;
    font-size: 11.5px;
    height: 26px;
    border-radius: 4px;
    background: #f8fafc;
}

.btn-task-action {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    border: 1px solid var(--surface-border);
    background: #f8fafc;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s ease;
}

.btn-task-action:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.btn-task-action.delete:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

/* Modal styling for Task Modal */
.task-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 2500;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.task-modal-backdrop.open {
    display: flex;
    animation: fadeIn 0.25s ease-out;
}

.task-modal-dialog {
    background: #ffffff;
    width: 100%;
    max-width: 540px;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--surface-border);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.task-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.task-modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.task-form-group {
    margin-bottom: 14px;
}

.task-form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-main);
}

.task-form-control {
    width: 100%;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 13.5px;
    outline: none;
    color: var(--text-main);
    background: #ffffff;
    box-sizing: border-box;
    font-family: inherit;
    transition: var(--transition);
}

.task-form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* ==========================================================================
   COMPREHENSIVE CROSS-PLATFORM & RESPONSIVE SYSTEM (WINDOWS, MAC, IOS, ANDROID)
   ========================================================================== */

/* 1. Universal Anti-Zoom & Touch Target Enhancement for Mobile (iPhone / Android) */
@media (max-width: 768px) {
    /* Prevent iOS Safari from auto-zooming into inputs */
    input, select, textarea,
    .task-form-control, .custom-select,
    #chat-input, #global-search, #docSearchInput,
    #deleteTaskPasswordInput {
        font-size: 16px !important;
    }

    /* Enlarge touch targets for fingers */
    .btn, button, .nav-item, .btn-task-action, .close-modal, .task-modal-close {
        min-height: 42px;
        touch-action: manipulation;
    }

    /* Safe Area insets for iPhone notch and home indicator bar */
    .app-container {
        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(15px, env(safe-area-inset-bottom));
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }

    /* Mobile Top App Header (Logo gọn gàng + Avatar, triệt tiêu thanh tag cuộn ngang) */
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 1000;
        margin-bottom: 6px;
        padding: 8px 12px;
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        background: rgba(255, 255, 255, 0.95);
        border: none;
        border-bottom: 1px solid rgba(226, 232, 240, 0.9);
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
        border-radius: 0 0 16px 16px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
        width: 100%;
        box-sizing: border-box;
    }

    .sidebar .logo {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 0;
        flex: 1;
        min-width: 0;
    }

    .sidebar .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 13px;
        border-radius: 9px;
        flex-shrink: 0;
    }

    .sidebar .logo h2 {
        font-size: 13.5px;
        font-weight: 700;
        color: #0f172a;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 0;
    }

    /* ẨN TOÀN BỘ THANH TAG TRƯỢT NGANG Ở ĐỈNH TRÊN MOBILE - CHUYỂN XUỐNG ĐÁY MÀN HÌNH */
    .sidebar .nav-menu {
        display: none !important;
    }

    .sidebar .user-profile {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 0;
        padding: 0;
        border: none;
        flex-shrink: 0;
    }

    .sidebar .user-profile .avatar {
        width: 32px;
        height: 32px;
    }

    .sidebar .user-info {
        display: none !important;
    }

    .sidebar .logout-btn {
        font-size: 18px;
        padding: 4px;
        color: #64748b;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Tạo khoảng trống ở đáy cho Bottom Navigation Bar không che nội dung */
    body, .main-content {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 8px)) !important;
    }

    /* Mobile Bottom Navigation Bar (Cố định ở đáy, 6 tab vừa khít màn hình, chuẩn ngón cái) */
    .mobile-bottom-nav {
        display: grid !important;
        grid-template-columns: repeat(6, 1fr);
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: auto;
        min-height: 56px;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(226, 232, 240, 0.95);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.07);
        padding: 5px 2px calc(6px + env(safe-area-inset-bottom, 8px)) 2px;
        z-index: 1200;
        box-sizing: border-box;
        user-select: none;
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        outline: none;
        padding: 3px 1px;
        cursor: pointer;
        color: #64748b;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: 12px;
        min-width: 0;
    }

    .mobile-nav-icon-wrap {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 26px;
        border-radius: 13px;
        margin-bottom: 2px;
        transition: all 0.2s ease;
    }

    .mobile-nav-icon-wrap i {
        font-size: 20px;
        transition: transform 0.2s ease;
    }

    .mobile-nav-item span {
        font-size: 10px;
        font-weight: 600;
        line-height: 1.2;
        white-space: nowrap;
        letter-spacing: -0.3px;
        transition: color 0.2s ease, font-weight 0.2s ease;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Tab đang chọn trên Bottom Nav */
    .mobile-nav-item.active {
        color: var(--primary);
    }

    .mobile-nav-item.active .mobile-nav-icon-wrap {
        background: rgba(2, 132, 199, 0.14);
        color: var(--primary);
    }

    .mobile-nav-item.active .mobile-nav-icon-wrap i {
        transform: translateY(-1px) scale(1.08);
    }

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

    .mobile-nav-item:active {
        transform: scale(0.92);
    }

    /* STRICTLY VERTICAL SCROLL - NO HORIZONTAL SCROLL ON MOBILE */
    html, body, .app-container, .main-content, .tab-content, #tasks, .glass-panel {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    #tasks .glass-panel {
        padding: 14px 10px !important;
        margin: 0 !important;
        width: 100% !important;
        border-radius: 14px !important;
    }

    /* Mobile Timeline Hero Header */
    .timeline-hero-header {
        padding: 4px 2px 6px 2px;
    }

    .timeline-hero-month {
        font-size: 11.5px;
    }

    .timeline-hero-day {
        font-size: 20px;
    }

    .timeline-hero-watermark {
        font-size: 46px;
        line-height: 0.8;
    }

    .timeline-hero-divider {
        margin-bottom: 16px;
    }

    /* Mobile Responsive Stats Grid (2 rows x 3 columns) */
    .kanban-stats-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
        margin-bottom: 14px !important;
    }

    .kanban-stat-card {
        padding: 8px 6px !important;
        gap: 6px !important;
        border-radius: 8px !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }

    .kanban-stat-icon {
        width: 28px !important;
        height: 28px !important;
        font-size: 14px !important;
        border-radius: 6px !important;
    }

    .kanban-stat-info .stat-num {
        font-size: 15px !important;
    }

    .kanban-stat-info .stat-lbl {
        font-size: 9.5px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    /* Responsive Task Toolbar on Mobile */
    .task-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 10px;
        margin-bottom: 16px;
    }

    .task-toolbar .filter-group {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .task-search-box {
        grid-column: 1 / -1;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
    }

    .task-toolbar select {
        width: 100% !important;
        font-size: 12px !important;
        padding: 7px 8px !important;
    }

    .task-toolbar-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .view-switch-btns {
        width: 100%;
        display: flex;
    }

    .btn-view-mode {
        flex: 1;
        justify-content: center;
        padding: 8px 4px;
        font-size: 12px;
    }

    .btn-add-task-mobile {
        width: 100%;
        justify-content: center;
        padding: 9px !important;
        font-size: 14px !important;
    }

    /* Mobile Timeline Schedule Items */
    .timeline-item {
        gap: 8px;
        padding-bottom: 18px;
    }

    .timeline-time-col {
        width: 48px;
        min-width: 48px;
        padding-right: 10px;
    }

    .timeline-time-val {
        font-size: 13.5px;
    }

    .timeline-time-ampm {
        font-size: 10px;
    }

    .timeline-stem-line {
        top: 26px;
        bottom: -6px;
        right: -1px;
    }

    .timeline-card {
        padding: 13px 12px;
        border-radius: 14px;
        border-left-width: 4.5px;
    }

    .timeline-card-title {
        font-size: 15px;
        margin-bottom: 8px;
    }

    .timeline-bullets {
        margin-bottom: 10px;
        gap: 6px;
    }

    .timeline-bullets li {
        font-size: 12.5px;
        padding-left: 16px;
    }

    .timeline-bullets li::before {
        font-size: 14px;
        left: 4px;
    }

    .timeline-highlight-banner {
        padding: 8px 10px;
        gap: 8px;
        margin-bottom: 10px;
        border-radius: 8px;
    }

    .banner-star-icon {
        font-size: 14px;
    }

    .banner-body-text {
        font-size: 11.5px;
    }

    .timeline-card-actions {
        padding-top: 8px;
        gap: 6px;
    }

    .timeline-card-actions .custom-select {
        font-size: 11px !important;
        padding: 4px 6px !important;
        height: 30px !important;
    }

    .btn-task-action {
        width: 32px;
        height: 32px;
        font-size: 15px;
    }

    /* Fallback Kanban Board on Mobile (Vertical stacking instead of horizontal swipe) */
    .kanban-board {
        display: flex;
        flex-direction: column;
        gap: 16px;
        overflow-x: hidden;
        padding-bottom: 20px;
        margin: 0;
        width: 100%;
    }

    .kanban-column {
        flex: 1 1 auto;
        min-width: 100%;
        min-height: auto;
        background: rgba(248, 250, 252, 0.95);
        border: 1px solid var(--surface-border);
        border-radius: 12px;
        padding: 12px;
    }

    .task-card {
        padding: 12px;
    }

    .task-datetime-grid {
        grid-template-columns: 1fr !important;
    }

    /* Responsive AI Chatbot on Mobile (Full Viewport Height) */
    .chatbot-container {
        height: calc(100dvh - 160px);
        min-height: 520px;
        display: flex;
        flex-direction: column;
        border-radius: var(--radius-md);
    }

    .chatbot-header {
        padding: 12px 14px;
    }

    .chatbot-header h2 {
        font-size: 16px;
    }

    .chat-messages {
        flex: 1;
        padding: 12px 10px;
        gap: 12px;
        -webkit-overflow-scrolling: touch;
    }

    .message {
        max-width: 95%;
        font-size: 14px;
        line-height: 1.55;
    }

    .chat-input-area {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, 0.95);
    }

    #chat-input {
        min-height: 44px;
        font-size: 15px;
        padding: 10px 14px;
    }

    #send-chat {
        width: 44px;
        height: 44px;
        min-width: 44px;
        font-size: 20px;
    }

    /* Responsive Modals on Mobile */
    .task-modal-backdrop {
        padding: 0;
        align-items: flex-end; /* Bottom sheet style on small mobile */
        z-index: 2500 !important;
    }

    .task-modal-dialog {
        max-height: 88dvh;
        border-radius: 20px 20px 0 0;
        padding: 20px 16px calc(24px + env(safe-area-inset-bottom, 16px)) 16px;
        margin: 0;
        width: 100%;
        box-sizing: border-box;
    }

    /* Ẩn hoàn toàn bottom nav bar khi modal đang mở để không che khuất nút xác nhận/hủy */
    body:has(.task-modal-backdrop.open) .mobile-bottom-nav,
    body.modal-open .mobile-bottom-nav {
        display: none !important;
    }

    .task-modal-footer {
        display: flex;
        gap: 10px;
        width: 100%;
        box-sizing: border-box;
    }

    .task-modal-footer button {
        flex: 1;
        justify-content: center;
        text-align: center;
    }

    .task-modal-header h3 {
        font-size: 16px;
    }

    /* Tables Responsive on Mobile */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 12px;
        border-radius: var(--radius-sm);
    }

    .table-responsive table {
        min-width: 600px;
    }

    /* Packaging Calculation Tabs - Cân bằng 4 cột đều nhau, không trượt ngang, haptic touch */
    .calc-tabs {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 5px !important;
        padding: 4px !important;
        border-radius: 12px !important;
        margin-bottom: 16px !important;
        overflow-x: hidden !important;
        background: rgba(2, 132, 199, 0.06) !important;
    }

    .calc-tab-btn {
        flex-direction: column !important;
        gap: 3px !important;
        padding: 8px 2px !important;
        border-radius: 8px !important;
        min-height: 52px !important;
        background: rgba(255, 255, 255, 0.8) !important;
    }

    .calc-tab-btn i {
        font-size: 19px !important;
        margin-bottom: 1px !important;
    }

    .calc-tab-btn .calc-tab-label-full {
        display: none !important;
    }

    .calc-tab-btn .calc-tab-label-short {
        display: block !important;
        font-size: 10.5px !important;
        font-weight: 600 !important;
        line-height: 1.15 !important;
        text-align: center !important;
        letter-spacing: -0.2px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
    }

    /* Hiệu ứng chạm Haptic cực kỳ phản hồi trên mobile */
    .calc-tab-btn:active {
        transform: scale(0.90) !important;
        transition: transform 0.06s cubic-bezier(0.2, 0, 0.2, 1) !important;
    }

    /* Căn đệm nội dung để không bị che khuất bởi Bottom Navigation Bar */
    #calc {
        padding-bottom: calc(96px + env(safe-area-inset-bottom, 16px)) !important;
    }

    #calc .glass-panel.form-container {
        padding: 14px 10px !important;
        margin-bottom: calc(90px + env(safe-area-inset-bottom, 16px)) !important;
        border-radius: 14px !important;
    }

    .calc-tab-content {
        padding-bottom: 30px !important;
    }
}

/* 2. Extra Small Mobile Phones (iPhone SE, Galaxy A series <= 390px) */
@media (max-width: 390px) {
    .kanban-column {
        flex: 1 1 auto;
        width: 100%;
        min-width: 100%;
    }

    .kanban-toolbar > div {
        grid-template-columns: 1fr;
    }

    .nav-item span {
        font-size: 12px;
    }

    .top-bar h1 {
        font-size: 17px;
    }

    .mobile-nav-item span {
        font-size: 9px;
        letter-spacing: -0.4px;
    }

    .mobile-nav-icon-wrap {
        width: 34px;
        height: 24px;
    }

    .mobile-nav-icon-wrap i {
        font-size: 18px;
    }
}

/* 3. iPad & Tablets (769px to 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .kanban-board {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .chatbot-container {
        height: calc(100dvh - 180px);
    }
}

/* 4. Smooth Animations & Native Performance Optimization */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== COMPREHENSIVE DARK MODE OVERRIDES ===== */
[data-theme="dark"] body {
    background-color: var(--background);
    color: var(--text-main);
}

[data-theme="dark"] .bg-shape {
    opacity: 0.12;
    filter: blur(110px);
}

[data-theme="dark"] .shape-1 {
    background: radial-gradient(circle, #0284c7, transparent 70%);
}

[data-theme="dark"] .shape-2 {
    background: radial-gradient(circle, #38bdf8, transparent 70%);
}

/* Sidebar & Navigation */
[data-theme="dark"] .sidebar {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(51, 65, 85, 0.7);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .logo h2 {
    color: #f8fafc;
}

[data-theme="dark"] .nav-item {
    background: rgba(30, 41, 59, 0.6);
    color: #94a3b8;
}

[data-theme="dark"] .nav-item:hover {
    background: rgba(30, 41, 59, 0.95);
    color: #f8fafc;
}

[data-theme="dark"] .nav-item.active {
    background: var(--primary);
    color: #0f172a;
    font-weight: 700;
}

[data-theme="dark"] .top-bar {
    background: rgba(15, 23, 42, 0.90);
    border-color: rgba(51, 65, 85, 0.7);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .top-bar h1 {
    color: #f8fafc;
}

/* Panels & Glass Cards */
[data-theme="dark"] .glass-panel,
[data-theme="dark"] .glass-card,
[data-theme="dark"] .form-container,
[data-theme="dark"] .task-card,
[data-theme="dark"] .timeline-card {
    background: #1e293b;
    border-color: rgba(51, 65, 85, 0.75);
    color: #f8fafc;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

/* Inputs, Selects & Forms */
[data-theme="dark"] .task-form-control,
[data-theme="dark"] .custom-select,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="time"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

[data-theme="dark"] .task-form-control:focus,
[data-theme="dark"] .custom-select:focus,
[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus {
    border-color: #38bdf8 !important;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25) !important;
}

[data-theme="dark"] .task-form-label {
    color: #cbd5e1;
}

[data-theme="dark"] .task-form-group span,
[data-theme="dark"] .input-group-text {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

/* Modals */
[data-theme="dark"] .task-modal-backdrop {
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
}

[data-theme="dark"] .task-modal-dialog,
[data-theme="dark"] .modal-content {
    background: #1e293b;
    border: 1px solid #334155;
    color: #f8fafc;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] .task-modal-dialog h3,
[data-theme="dark"] .task-modal-dialog h2,
[data-theme="dark"] .modal-content h2,
[data-theme="dark"] .modal-content h3 {
    color: #f8fafc;
}

[data-theme="dark"] .task-modal-dialog p {
    color: #94a3b8;
}

/* Mobile Bottom Navigation Bar */
[data-theme="dark"] .mobile-bottom-nav {
    background: rgba(15, 23, 42, 0.96) !important;
    border-top: 1px solid rgba(51, 65, 85, 0.85) !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] .mobile-nav-item {
    color: #94a3b8;
}

[data-theme="dark"] .mobile-nav-item.active {
    color: #38bdf8;
}

[data-theme="dark"] .mobile-nav-item.active .mobile-nav-icon-wrap {
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
}

[data-theme="dark"] .mobile-nav-item.active span {
    color: #38bdf8;
}

/* Timeline & Agenda View in Dark Mode */
[data-theme="dark"] .timeline-hero-watermark {
    color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .timeline-hero-day {
    color: #f8fafc;
}

[data-theme="dark"] .timeline-hero-month {
    color: #38bdf8;
}

[data-theme="dark"] .timeline-hero-divider {
    background: linear-gradient(to right, rgba(56, 189, 248, 0.7), rgba(51, 65, 85, 0.4), transparent);
}

[data-theme="dark"] .timeline-time-val {
    color: #f8fafc;
}

[data-theme="dark"] .timeline-time-ampm {
    color: #38bdf8;
}

[data-theme="dark"] .timeline-stem-line {
    background: rgba(56, 189, 248, 0.25);
}

[data-theme="dark"] .tl-pill {
    background: #0f172a;
    border-color: #334155;
    color: #f8fafc;
}

[data-theme="dark"] .tl-pill-project {
    background: rgba(56, 189, 248, 0.15);
    color: #7dd3fc;
    border-color: rgba(56, 189, 248, 0.3);
}

[data-theme="dark"] .tl-pill-id {
    background: rgba(148, 163, 184, 0.15);
    color: #cbd5e1;
}

[data-theme="dark"] .timeline-card-title {
    color: #f8fafc;
}

[data-theme="dark"] .timeline-bullets li {
    color: #cbd5e1;
}

[data-theme="dark"] .timeline-bullets li strong {
    color: #f8fafc;
}

[data-theme="dark"] .timeline-assignee-tag {
    background: #0f172a;
    color: #cbd5e1;
    border-color: #334155;
}

[data-theme="dark"] .btn-task-action {
    background: #0f172a;
    border-color: #334155;
    color: #94a3b8;
}

[data-theme="dark"] .btn-task-action:hover {
    background: #334155;
    color: #f8fafc;
}

[data-theme="dark"] .task-toolbar {
    background: rgba(30, 41, 59, 0.75);
    border-color: #334155;
}

[data-theme="dark"] .kanban-stat-card {
    background: rgba(30, 41, 59, 0.7);
    border-color: #334155;
}

[data-theme="dark"] .kanban-stat-info .stat-num {
    color: #f8fafc;
}

[data-theme="dark"] .kanban-stat-info .stat-lbl {
    color: #94a3b8;
}

[data-theme="dark"] .btn-view-mode {
    background: #0f172a;
    border-color: #334155;
    color: #94a3b8;
}

[data-theme="dark"] .btn-view-mode.active {
    background: #38bdf8;
    color: #0f172a;
    font-weight: 700;
}

[data-theme="dark"] .task-list.empty-state {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
}

/* Chatbot in Dark Mode */
[data-theme="dark"] .chatbot-container {
    background: #0f172a;
    border-color: #334155;
}

[data-theme="dark"] .chatbot-header {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .chatbot-header h3 {
    color: #f8fafc;
}

[data-theme="dark"] .chat-bubble.bot {
    background: #1e293b;
    color: #f8fafc;
    border-color: #334155;
}

[data-theme="dark"] .chat-bubble.user {
    background: #0284c7;
    color: #ffffff;
}

[data-theme="dark"] .chat-input-area {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .chip-btn {
    background: #0f172a;
    border-color: #334155;
    color: #cbd5e1;
}

[data-theme="dark"] .chip-btn:hover {
    background: rgba(56, 189, 248, 0.18);
    color: #38bdf8;
    border-color: #38bdf8;
}

/* Calculations & TDS/MSDS */
[data-theme="dark"] .calc-tabs {
    background: rgba(15, 23, 42, 0.85) !important;
    border-color: #334155 !important;
}

[data-theme="dark"] .calc-tab-btn {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
}

[data-theme="dark"] .calc-tab-btn:hover {
    background: #253349 !important;
    color: #38bdf8 !important;
    border-color: #38bdf8 !important;
}

[data-theme="dark"] .calc-tab-btn.active {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    border-color: #38bdf8 !important;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35) !important;
}

[data-theme="dark"] .calc-tab-btn.active i {
    color: #ffffff !important;
}

[data-theme="dark"] .calc-result-box {
    background: #0f172a;
    border-color: #334155;
    color: #f8fafc;
}

[data-theme="dark"] .data-table {
    border-color: #334155;
}

[data-theme="dark"] .data-table th {
    background: #0f172a;
    color: #f8fafc;
    border-color: #334155;
}

[data-theme="dark"] .data-table td {
    border-color: #334155;
    color: #cbd5e1;
    background: #1e293b;
}

[data-theme="dark"] .data-table tr:hover td {
    background: rgba(56, 189, 248, 0.08);
}

[data-theme="dark"] .materials-card {
    background: #1e293b;
    border-color: #334155;
    color: #f8fafc;
}

[data-theme="dark"] .material-tag {
    background: #0f172a;
    color: #7dd3fc;
    border-color: #334155;
}

/* Card & Component Utility Classes for Perfect Theme Contrast */
.capability-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.capability-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.12);
}

.calc-stat-box {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
}

.calc-mini-stat {
    background: var(--surface-light);
    border: 1px solid var(--surface-border);
    padding: 10px;
    border-radius: 6px;
}

/* Dark Mode Comprehensive Enhancements */
[data-theme="dark"] .capability-card,
[data-theme="dark"] .calc-stat-box {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

[data-theme="dark"] .calc-mini-stat {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

[data-theme="dark"] .btn-secondary {
    background: #1e293b !important;
    color: #f8fafc !important;
    border: 1px solid #475569 !important;
}

[data-theme="dark"] .btn-secondary:hover {
    background: #334155 !important;
    color: #38bdf8 !important;
    border-color: #38bdf8 !important;
}

[data-theme="dark"] .btn-primary {
    background: linear-gradient(135deg, #0284c7, #0369a1) !important;
    color: #ffffff !important;
    border: 1px solid rgba(56, 189, 248, 0.4) !important;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4) !important;
}

[data-theme="dark"] .btn-primary:hover {
    background: linear-gradient(135deg, #0369a1, #0284c7) !important;
    box-shadow: 0 6px 18px rgba(56, 189, 248, 0.4) !important;
}

[data-theme="dark"] .view-switch-btns {
    background: #0f172a !important;
    border-color: #334155 !important;
}

[data-theme="dark"] option {
    background: #0f172a !important;
    color: #f8fafc !important;
}

/* Priority Badges in Dark Mode */
[data-theme="dark"] .priority-Bình-thường,
[data-theme="dark"] .priority-Binh-thuong,
[data-theme="dark"] .priority-Normal {
    background: rgba(148, 163, 184, 0.15) !important;
    color: #cbd5e1 !important;
    border: 1px solid rgba(148, 163, 184, 0.3) !important;
}

[data-theme="dark"] .priority-Cao {
    background: rgba(245, 158, 11, 0.2) !important;
    color: #fbbf24 !important;
    border: 1px solid rgba(245, 158, 11, 0.4) !important;
}

[data-theme="dark"] .priority-Gấp,
[data-theme="dark"] .priority-Gap {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
    border: 1px solid rgba(239, 68, 68, 0.4) !important;
}

/* Banners in Dark Mode */
[data-theme="dark"] .timeline-highlight-banner.banner-navy {
    background: #1e3a5f !important;
    border: 1px solid rgba(56, 189, 248, 0.3) !important;
}

[data-theme="dark"] .timeline-highlight-banner.banner-cyan {
    background: #0369a1 !important;
    border: 1px solid rgba(56, 189, 248, 0.35) !important;
}

[data-theme="dark"] .timeline-highlight-banner.banner-green {
    background: #065f46 !important;
    border: 1px solid rgba(16, 185, 129, 0.35) !important;
}

[data-theme="dark"] .timeline-highlight-banner.banner-purple {
    background: #5b21b6 !important;
    border: 1px solid rgba(168, 85, 247, 0.35) !important;
}

[data-theme="dark"] .timeline-highlight-banner.banner-red {
    background: #991b1b !important;
    border: 1px solid rgba(239, 68, 68, 0.35) !important;
}

/* Tailwind Utilities (COF Simulation Tab) in Dark Mode */
[data-theme="dark"] #calc-cof .bg-white,
[data-theme="dark"] .bg-white {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

[data-theme="dark"] #calc-cof .bg-slate-50,
[data-theme="dark"] #calc-cof .bg-slate-100,
[data-theme="dark"] .bg-slate-50,
[data-theme="dark"] .bg-slate-100 {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #cbd5e1 !important;
}

[data-theme="dark"] #calc-cof .border-slate-200,
[data-theme="dark"] #calc-cof .border-slate-300,
[data-theme="dark"] .border-slate-200,
[data-theme="dark"] .border-slate-300 {
    border-color: #334155 !important;
}

[data-theme="dark"] #calc-cof .text-slate-900,
[data-theme="dark"] #calc-cof .text-slate-800,
[data-theme="dark"] .text-slate-900,
[data-theme="dark"] .text-slate-800 {
    color: #f8fafc !important;
}

[data-theme="dark"] #calc-cof .text-slate-700,
[data-theme="dark"] #calc-cof .text-slate-600,
[data-theme="dark"] .text-slate-700,
[data-theme="dark"] .text-slate-600 {
    color: #cbd5e1 !important;
}

[data-theme="dark"] #calc-cof .text-slate-500,
[data-theme="dark"] #calc-cof .text-slate-400,
[data-theme="dark"] .text-slate-500,
[data-theme="dark"] .text-slate-400 {
    color: #94a3b8 !important;
}

[data-theme="dark"] #calc-cof input,
[data-theme="dark"] #calc-cof select {
    background-color: #0f172a !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

[data-theme="dark"] #calc-cof input[type="range"] {
    background-color: #334155 !important;
}

[data-theme="dark"] #calc-cof tr.hover\:bg-slate-50:hover {
    background-color: #253349 !important;
}

[data-theme="dark"] #calc-cof thead th {
    background-color: #0f172a !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

/* Sub-header in Materials Table */
[data-theme="dark"] .sub-header-row th {
    border-color: #334155 !important;
}

[data-theme="dark"] .sub-header-row th[style*="#fed7aa"] {
    background-color: rgba(249, 115, 22, 0.22) !important;
    color: #fb923c !important;
}

/* ==========================================================================
   POST MODULE (Sự cố & Sự kiện 5M+1E) STYLES
   ========================================================================== */

/* 5M+1E Stat Cards */
.post-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
}

.post-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
}

.post-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
    border-color: var(--primary);
}

.post-stat-card.active {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.06);
    box-shadow: 0 0 0 2px var(--primary);
}

.post-stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

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

.post-stat-count {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
}

.post-stat-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Category Colors */
.cat-machine { background: rgba(59, 130, 246, 0.12); color: #2563eb; }
.cat-material { background: rgba(16, 185, 129, 0.12); color: #059669; }
.cat-method { background: rgba(139, 92, 246, 0.12); color: #7c3aed; }
.cat-measure { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.cat-man { background: rgba(236, 72, 153, 0.12); color: #db2777; }
.cat-other { background: rgba(100, 116, 139, 0.12); color: #475569; }

/* Category Pills in Modal */
.post-category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

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

.cat-pill {
    padding: 10px 12px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-body);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    transition: all 0.2s ease;
}

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

.cat-pill.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.cat-pill.selected i {
    color: #ffffff;
}

/* Upload Dropzone */
.post-upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    padding: 20px 16px;
    text-align: center;
    background: var(--bg-body);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.post-upload-zone:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.03);
}

/* Preview Box */
.post-preview-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.post-preview-thumb-wrap {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    flex-shrink: 0;
}

.post-preview-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Word Counter Badge */
.post-word-badge.warning {
    background: #fee2e2 !important;
    color: #dc2626 !important;
    border: 1px solid #fca5a5;
}

/* Posts Feed List */
.posts-feed-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.post-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    border-left: 5px solid #64748b;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

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

.post-card.cat-border-machine { border-left-color: #3b82f6; }
.post-card.cat-border-material { border-left-color: #10b981; }
.post-card.cat-border-method { border-left-color: #8b5cf6; }
.post-card.cat-border-measure { border-left-color: #f59e0b; }
.post-card.cat-border-man { border-left-color: #ec4899; }
.post-card.cat-border-other { border-left-color: #64748b; }

.post-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.post-id-badge {
    font-family: 'SF Mono', Consolas, Monaco, monospace;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.post-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-muted);
}

.post-badge-category {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.post-badge-reporter {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(100, 116, 139, 0.08);
    padding: 2px 8px;
    border-radius: 6px;
}

.post-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.35;
    margin: 0;
}

.post-card-desc {
    font-size: 13px;
    color: var(--text-main);
    line-height: 1.55;
    white-space: pre-line;
    word-break: break-word;
}

.post-card-image-wrap {
    margin-top: 4px;
    border-radius: 8px;
    overflow: hidden;
    max-width: 240px;
    max-height: 160px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    position: relative;
    background: #0f172a;
}

.post-card-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.post-card-image-wrap:hover img {
    transform: scale(1.05);
}

.post-card-image-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 20px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.post-card-image-wrap:hover .post-card-image-overlay {
    opacity: 1;
}

.post-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
    font-size: 11.5px;
    color: var(--text-muted);
}

/* Lightbox Modal */
.post-lightbox-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(6px);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.post-lightbox-modal img {
    max-width: 90vw;
    max-height: 80vh;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    object-fit: contain;
}

.post-lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    font-size: 32px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.post-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.4);
}

.post-lightbox-caption {
    color: #f1f5f9;
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
    max-width: 600px;
}

/* Dark Mode Overrides for Post Module */
[data-theme="dark"] .post-stat-card {
    background: var(--bg-card);
    border-color: var(--border-color);
}

[data-theme="dark"] .post-stat-card.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: #60a5fa;
}

[data-theme="dark"] .cat-machine { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
[data-theme="dark"] .cat-material { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
[data-theme="dark"] .cat-method { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }
[data-theme="dark"] .cat-measure { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
[data-theme="dark"] .cat-man { background: rgba(236, 72, 153, 0.2); color: #f9a8d4; }
[data-theme="dark"] .cat-other { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }

[data-theme="dark"] .cat-pill {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .cat-pill:hover {
    background: #334155;
}

[data-theme="dark"] .post-upload-zone {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .post-preview-box {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .post-card {
    background: var(--bg-card);
    border-color: var(--border-color);
}

[data-theme="dark"] .post-badge-reporter {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}


