/* === MODERN UI REVAMP === */

/* 1. ROOT VARIABLES & GLOBAL STYLES */
:root {
    --sidebar-width: 260px;
    --header-height: 60px;

    --bg-color: #f4f7fa;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: #334155;
    --accent-color: #3b82f6;
    --accent-color-hover: #2563eb;
    
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;

    --success-color: #16a34a;
    --warning-color: #f59e0b;
    --error-color: #dc2626;

    --border-radius: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.6;
    overflow-x: hidden;
}

#app-container {
    display: flex;
    height: 100%;
}

/* 2. SIDEBAR & NAVIGATION */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: transform 0.3s ease-in-out;
}

.sidebar-header {
    padding: 1rem 1.5rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    border-bottom: 1px solid #334155;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    color: var(--sidebar-text-hover);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#main-nav {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

#main-nav a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
    border-left: 4px solid transparent;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
}

#main-nav a:hover {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text-hover);
}

#main-nav a:active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text-hover);
    transform: scale(0.98);
}

#main-nav a.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text-hover);
    border-left-color: var(--accent-color);
}

#main-nav a i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    pointer-events: none; /* 防止图标阻止点击 */
}

/* 移动端导航优化 */
@media (max-width: 768px) {
    #main-nav {
        padding: 0;
    }

    .mobile-nav-item {
        display: flex !important;
        align-items: center;
        width: 100%;
        padding: 1rem 1.5rem;
        border: none;
        background: transparent;
        color: #ffffff !important; /* 纯白色文字 */
        font-size: 1rem;
        cursor: pointer !important;
        text-decoration: none;
        position: relative;
        transition: all 0.2s ease;
        min-height: 48px;
        -webkit-tap-highlight-color: rgba(59, 130, 246, 0.5);
        touch-action: manipulation;
        pointer-events: auto !important;
        user-select: none;
        border-left: 4px solid transparent;
        opacity: 1 !important; /* 确保不透明 */
        z-index: 1002 !important; /* 确保最高层级 */
    }

    .mobile-nav-item:hover {
        background-color: rgba(255, 255, 255, 0.15) !important;
        color: #ffffff !important;
    }

    .mobile-nav-item:active {
        background-color: rgba(59, 130, 246, 0.3) !important;
        color: #ffffff !important;
        transform: scale(0.98);
    }

    .mobile-nav-item.active {
        background-color: rgba(59, 130, 246, 0.2) !important;
        color: #ffffff !important;
        border-left-color: #3b82f6;
        font-weight: 600;
    }

    .mobile-nav-item.mobile-logout {
        background-color: rgba(239, 68, 68, 0.15) !important;
        border-top: 1px solid rgba(239, 68, 68, 0.3);
        margin-top: 0.5rem;
        color: #ffffff !important;
    }

    .mobile-nav-item.mobile-logout:active,
    .mobile-nav-item.mobile-logout:hover {
        background-color: rgba(239, 68, 68, 0.3) !important;
        color: #ffffff !important;
    }

    .mobile-nav-item i {
        width: 24px;
        font-size: 1.1rem;
        text-align: center;
        margin-right: 1rem;
        pointer-events: none; /* 防止图标阻止点击 */
        color: #ffffff !important;
        opacity: 1 !important;
    }

    .mobile-nav-item span {
        flex: 1;
        font-weight: 500;
        pointer-events: none; /* 防止文本阻止点击 */
        color: #ffffff !important;
        opacity: 1 !important;
    }

    /* 传统的a标签样式用于桌面端 */
    #main-nav a {
        min-height: 48px; /* iOS推荐的最小触摸目标 */
        padding: 1rem 1.5rem;
        font-size: 1rem;
        display: none; /* 在移动端隐藏传统的a标签 */
    }

    #main-nav a i {
        font-size: 1.1rem;
    }
}

/* 3. MAIN CONTENT AREA */
#main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    height: 100vh;
}

#top-header {
    display: flex;
    align-items: center;
    height: var(--header-height);
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

#menu-toggle {
    display: none; /* Hidden on desktop */
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
    margin-right: 1rem;
}

#page-title {
    font-size: 1.5rem;
    font-weight: 600;
}

main#app-content {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

/* 4. RESPONSIVE DESIGN (MOBILE-FIRST APPROACH) */

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    button, .btn, #main-nav a {
        min-height: 44px; /* iOS HIG recommended minimum */
        min-width: 44px;
    }

    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        min-height: 44px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Swipe gesture support */
.sidebar-swipe-area {
    position: fixed;
    top: 0;
    left: 0;
    width: 20px;
    height: 100vh;
    z-index: 998;
    background: transparent;
}

@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
        touch-action: pan-y; /* Allow vertical scrolling */
        z-index: 1000; /* Ensure it's above other content */
        opacity: 1 !important; /* 确保侧边栏不透明 */
        background-color: #1e293b !important; /* 确保背景色正确 */
    }

    body.sidebar-open #sidebar {
        transform: translateX(0);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
        opacity: 1 !important;
    }

    #main-content {
        margin-left: 0;
        width: 100%;
        touch-action: pan-y; /* Allow vertical scrolling when sidebar is closed */
    }

    body.sidebar-open #main-content {
        touch-action: none; /* Prevent scrolling when sidebar is open */
    }

    /* 确保导航链接在移动端可点击 */
    #main-nav {
        pointer-events: auto;
    }

    #main-nav a {
        position: relative;
        z-index: 1;
    }

    #menu-toggle {
        display: block;
        min-width: 44px;
        min-height: 44px;
        touch-action: manipulation; /* Improves touch responsiveness */
    }

    #overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999; /* 低于sidebar */
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s, left 0s;
        touch-action: manipulation;
        pointer-events: none; /* 默认不阻止点击 */
    }

    body.sidebar-open #overlay {
        opacity: 1;
        visibility: visible;
        pointer-events: auto; /* sidebar打开时可以点击overlay来关闭 */
        left: var(--sidebar-width); /* 不覆盖sidebar区域，只覆盖右边的main-content */
        width: calc(100% - var(--sidebar-width)); /* 调整宽度 */
    }

    /* 确保导航链接在移动端可点击 - 最高优先级 */
    #main-nav {
        pointer-events: auto !important;
        position: relative;
        z-index: 1001 !important; /* 确保高于overlay和sidebar */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #main-nav a {
        pointer-events: auto !important;
        position: relative;
        z-index: 10; /* 确保链接在最上层 */
        display: block;
        width: 100%;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    }

    #main-nav a i {
        pointer-events: none;
    }

    main#app-content {
        padding: 1rem;
        padding-bottom: env(safe-area-inset-bottom, 1rem); /* Handle notched screens */
    }

    #top-header {
        padding: 0 1rem;
        padding-top: env(safe-area-inset-top, 0); /* Handle status bar */
    }

    .product-list-header {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.6rem;
        align-items: flex-start;
    }

    .product-summary-meta {
        justify-content: space-between;
        width: 100%;
    }

    .product-list-panel {
        padding: 0.85rem 1rem 1rem;
    }

    .product-panel-content {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .product-panel-media {
        min-height: 180px;
    }

    .product-panel-actions {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .desktop-only {
        display: none;
    }

    .mobile-only,
    .activity-card-list,
    .log-card-list,
    .user-card-list {
        display: flex;
    }

    .action-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .activity-card-list {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-top: 1rem;
    }

    .log-card-list,
    .user-card-list {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .activity-card-mobile {
        padding: 0.85rem;
    }

    .activity-card-mobile header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 1rem;
    }

    .stat-card {
        padding: 1.1rem;
    }

    .stat-card p {
        font-size: clamp(1.8rem, 9vw, 2.2rem);
    }

    .charts-grid {
        margin-top: 1.25rem;
    }

    .chart-container {
        padding: 1rem;
        height: clamp(260px, 60vw, 340px);
        aspect-ratio: auto;
    }

    .chart-container canvas {
        min-height: 220px;
    }

    article,
    .card {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }

    /* Performance optimizations */
    * {
        -webkit-transform: translateZ(0); /* Enable hardware acceleration */
        transform: translateZ(0);
    }

    /* Reduce motion on mobile for better performance */
    @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;
        }
    }

    /* Optimize images for mobile */
    img {
        max-width: 100%;
        height: auto;
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        transform: translateZ(0);
        will-change: transform;
    }

    /* Optimize scrolling performance */
    main#app-content {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
    }

    /* Improve font rendering on mobile */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }

    /* Optimize animations for mobile */
    .sidebar-swipe-area {
        will-change: background-color;
    }

    #sidebar {
        will-change: transform;
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }

    /* Memory optimization for large lists */
    .product-list-wrapper,
    .activity-card-list,
    .mobile-card-list {
        contain: layout style paint;
    }

    /* Optimize chart rendering on mobile */
    canvas {
        max-width: 100%;
        height: auto !important;
    }
}

/* 5. MODERNIZED COMPONENTS */

/* Cards */
.card, article {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2, .card h3, .card h4,
article h2, article h3, article h4 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Forms */
form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

label {
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: block;
    color: var(--text-primary);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    background-color: var(--bg-color);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none; /* Remove default styling */
    appearance: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Mobile form optimizations */
@media (max-width: 768px) {
    form {
        gap: 1.25rem;
        padding: 0; /* Remove padding from forms on mobile */
    }

    .form-group {
        margin-bottom: 0;
    }

    .form-row {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .form-row.horizontal {
        flex-direction: row;
        gap: 0.75rem;
    }

    .form-row .form-group {
        flex: 1;
    }

    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    input[type="tel"],
    input[type="search"],
    select,
    textarea {
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 16px; /* Prevent zoom on iOS */
        border-radius: var(--border-radius);
        background-color: var(--card-bg);
        -webkit-appearance: none;
        appearance: none;
    }

    textarea {
        min-height: 100px;
        resize: vertical;
    }

    /* Better select styling on mobile */
    select {
        background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 0.75rem center;
        background-size: 1.5rem;
        padding-right: 2.5rem;
    }

    /* File input styling */
    input[type="file"] {
        display: none;
    }

    .file-input-label {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        min-height: 44px;
        padding: 0.75rem 1.5rem;
        border: 2px dashed var(--card-border);
        border-radius: var(--border-radius);
        background-color: var(--bg-color);
        color: var(--text-secondary);
        cursor: pointer;
        transition: all 0.2s ease;
        font-weight: 500;
    }

    .file-input-label:hover {
        border-color: var(--accent-color);
        background-color: rgba(59, 130, 246, 0.05);
        color: var(--accent-color);
    }

    .file-input-label.has-files {
        border-style: solid;
        border-color: var(--success-color);
        background-color: rgba(34, 197, 94, 0.05);
        color: var(--success-color);
    }

    /* Checkbox and radio improvements */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 20px;
        min-height: 20px;
        -webkit-appearance: none;
        appearance: none;
        border: 2px solid var(--card-border);
        border-radius: 4px;
        background-color: var(--card-bg);
        cursor: pointer;
        position: relative;
        transition: all 0.2s ease;
    }

    input[type="checkbox"]:checked,
    input[type="radio"]:checked {
        background-color: var(--accent-color);
        border-color: var(--accent-color);
    }

    input[type="checkbox"]:checked::after {
        content: '✓';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        color: white;
        font-size: 12px;
        font-weight: bold;
    }

    input[type="radio"] {
        border-radius: 50%;
    }

    input[type="radio"]:checked::after {
        content: '';
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background-color: white;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    /* Form validation styling */
    input:invalid,
    select:invalid,
    textarea:invalid {
        border-color: var(--error-color);
    }

    input:invalid:focus,
    select:invalid:focus,
    textarea:invalid:focus {
        box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
    }

    .error-message {
        display: block;
        color: var(--error-color);
        font-size: 0.85rem;
        margin-top: 0.25rem;
    }

    .success-message {
        display: block;
        color: var(--success-color);
        font-size: 0.85rem;
        margin-top: 0.25rem;
    }
}

/* Buttons */
button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on iOS */
}

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

/* Mobile-specific button improvements */
@media (max-width: 768px) {
    button, .btn {
        min-height: 44px; /* iOS HIG recommended minimum */
        padding: 0.75rem 1.25rem;
        font-size: 1rem;
        touch-action: manipulation; /* Improves touch responsiveness */
        -webkit-user-select: none; /* Prevent text selection on tap */
        user-select: none;
    }

    /* Small buttons on mobile */
    .btn-sm {
        min-height: 36px;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    /* Button groups with better spacing */
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }

    .btn-group.horizontal {
        flex-direction: row;
        gap: 0.5rem;
    }

    .btn-group .btn {
        flex: 1;
    }

    /* Improve touch targets for icon buttons */
    button.btn-icon, .btn-icon {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

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

.btn-secondary {
    background-color: var(--card-border);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background-color: #d1d5db;
}

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

/* Tables */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap; /* Prevent text wrapping in table cells */
}

thead th {
    background-color: #f8fafc;
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky; /* Sticky header for horizontal scroll */
    top: 0;
    z-index: 10;
}

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

tbody tr:hover {
    background-color: var(--bg-color);
}

/* Mobile-optimized table display */
@media (max-width: 768px) {
    .table-container {
        margin: 0 -1rem; /* Extend to screen edges */
        padding: 0 1rem;
        border-left: none;
        border-right: none;
        border-radius: 0;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 0.85rem;
        min-width: 600px; /* Ensure table has meaningful width */
    }

    th, td {
        padding: 0.6rem 0.8rem;
    }

    /* Improve table readability on small screens */
    .table-shadow {
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
    }

    /* Alternative card layout for tables on very small screens */
    @media (max-width: 480px) {
        .table-card-container {
            display: none; /* Hide table container */
        }

        .mobile-card-list {
            display: block;
        }

        .mobile-card-list .mobile-card-item {
            border: 1px solid var(--card-border);
            border-radius: var(--border-radius);
            background: var(--card-bg);
            margin-bottom: 1rem;
            padding: 1rem;
            box-shadow: var(--shadow-sm);
        }

        .mobile-card-item .card-row {
            display: flex;
            justify-content: space-between;
            padding: 0.3rem 0;
            border-bottom: 1px solid rgba(226, 232, 240, 0.5);
        }

        .mobile-card-item .card-row:last-child {
            border-bottom: none;
        }

        .mobile-card-item .card-label {
            font-weight: 600;
            color: var(--text-secondary);
            font-size: 0.85rem;
        }

        .mobile-card-item .card-value {
            text-align: right;
            color: var(--text-primary);
        }
    }
}

.mobile-card-list {
    display: none; /* Hidden by default, shown on very small screens */
}

.activity-card-list {
    display: none;
    gap: 1rem;
}

.activity-card-mobile {
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.activity-card-mobile header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.activity-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.activity-card-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0.15rem 0 0;
}

.activity-card-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .activity-card-list {
        display: grid;
    }
}

/* Log Card - Mobile */
.log-card-mobile {
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.log-card-mobile header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.log-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.log-card-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.15rem 0 0;
}

.log-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.log-card-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.log-card-row > div {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.log-card-row span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.log-card-row strong {
    font-size: 1rem;
    color: var(--text-primary);
}

.log-card-notes {
    padding: 0.5rem;
    background: var(--card-bg-alt);
    border-radius: 0.375rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-left: 3px solid var(--primary-color);
}

.log-card-notes span {
    font-weight: 600;
    color: var(--text-primary);
}

.log-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
    text-align: center;
}

.badge-inbound {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.badge-outbound {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

/* User Card - Mobile */
.user-card-mobile {
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.user-card-mobile header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.user-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.user-card-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.15rem 0 0;
}

.user-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.user-card-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--card-bg-alt);
    border-radius: 0.375rem;
}

.user-card-info span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.user-card-info strong {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.user-card-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.user-card-actions button {
    flex: 1;
    min-height: 44px;
    font-size: 0.9rem;
}

.user-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
    text-align: center;
}

.status-badge-pending {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.status-badge-active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.status-badge-disabled {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
}

/* Tabs Component */
.tabs-container {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.tabs-nav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--card-border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    flex: 1;
    min-width: fit-content;
    padding: 0.75rem 1.25rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    margin: 0;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: var(--card-bg-alt);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

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

.grid-cols-3-mobile-1 {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
    .tabs-nav {
        gap: 0;
        margin-bottom: 1rem;
    }

    .tab-btn {
        padding: 0.65rem 1rem;
        font-size: 0.875rem;
        min-height: 44px;
    }

    .grid-cols-3-mobile-1 {
        grid-template-columns: 1fr;
    }

    .tab-content {
        padding: 0;
    }
}

/* Export Page Styles */
.export-container {
    max-width: 1200px;
    margin: 0 auto;
}

.export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.export-card {
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    overflow: hidden;
}

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

.export-card-header {
    padding: 1.25rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1976d2 100%);
    color: white;
}

.export-card-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.export-card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.export-card-body p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.export-filters {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--card-bg-alt);
    border-radius: 0.375rem;
    border: 1px solid var(--card-border);
}

.export-filters .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.export-filters label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.export-filters input,
.export-filters select {
    min-height: 44px;
}

.export-history {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--card-border);
}

.export-history h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.export-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.export-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
}

.export-history-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.export-history-info strong {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.export-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.export-status {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.export-status.success {
    background: var(--success-color);
    color: white;
}

.export-status.failed {
    background: var(--error-color);
    color: white;
}

@media (max-width: 768px) {
    .export-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin: 1rem 0;
    }

    .export-card-header {
        padding: 1rem;
    }

    .export-card-header h3 {
        font-size: 1rem;
    }

    .export-card-body {
        padding: 1rem;
    }

    .export-filters {
        padding: 0.75rem;
    }

    .export-history {
        margin-top: 2rem;
        padding-top: 1.5rem;
    }

    .export-history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

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

/* Filter Panel - Collapsible */
.filter-panel {
    margin: 1.5rem 0;
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
}

.filter-panel-header {
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1976d2 100%);
    color: white;
    border-radius: var(--border-radius);
    font-weight: 600;
    transition: all 0.3s ease;
}

.filter-panel-header:hover {
    background: linear-gradient(135deg, #1976d2 0%, var(--primary-color) 100%);
}

.filter-panel-header::marker,
.filter-panel-header::-webkit-details-marker {
    display: none;
}

.filter-panel-header::after {
    content: '▼';
    font-size: 0.75rem;
    transition: transform 0.3s ease;
    margin-left: 0.5rem;
}

.filter-panel[open] .filter-panel-header::after {
    transform: rotate(180deg);
}

.filter-panel-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.filter-panel-count {
    padding: 0.25rem 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.filter-panel-body {
    padding: 1.25rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.filter-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .filter-panel {
        margin: 1rem 0;
    }

    .filter-panel-header {
        padding: 0.875rem 1rem;
    }

    .filter-panel-title {
        font-size: 0.95rem;
    }

    .filter-panel-body {
        padding: 1rem;
    }

    .filter-grid {
        grid-template-columns: 1fr;
        gap: 0.875rem;
    }

    .filter-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .filter-actions button {
        width: 100%;
        min-height: 44px;
    }
}

/* Status Badges */
.status-badge {
    padding: 0.25em 0.6em;
    border-radius: 999px;
    color: white;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
}
.status-pending { background-color: var(--warning-color); }
.status-active { background-color: var(--success-color); }
.status-disabled { background-color: var(--error-color); }


/* 6. UTILITY & MISC STYLES */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Loading Indicator */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none; /* 隐藏时不阻止点击 */
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* 显示时才可交互 */
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--bg-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-content {
    text-align: center;
}

.loading-text {
    margin-top: 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
}

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

/* Notification System */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    width: 350px;
    max-width: 90vw; /* 移动端不超出屏幕 */
    pointer-events: none; /* 容器本身不阻止点击 */
}

.notification-container > * {
    pointer-events: auto; /* 但通知本身可以点击 */
}

.notification {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-md);
    border-left: 4px solid var(--accent-color);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease-in-out;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

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

.notification-icon {
    font-size: 1.25rem;
    margin-top: 2px;
}
.notification.error .notification-icon { color: var(--error-color); }
.notification.success .notification-icon { color: var(--success-color); }
.notification.warning .notification-icon { color: var(--warning-color); }
.notification.info .notification-icon { color: var(--accent-color); }

.notification-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.notification-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.notification-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-light);
    cursor: pointer;
    margin-left: auto;
}

/* Specific Component Styles */

/* Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    padding: 1.5rem;
}

.stat-card h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-card p {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

#chart-container {
    margin-top: 2rem;
    height: 350px;
}

/* Product List */
.product-list-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.product-list-item {
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    background: var(--card-bg);
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.product-list-item:hover,
.product-list-item.expanded {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.product-list-item.alert-stock {
    border-color: var(--error-color);
}

.product-list-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.25rem;
    cursor: pointer;
}

.product-select input {
    width: 18px;
    height: 18px;
}

.product-summary h5 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.product-summary p {
    margin: 0.2rem 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.product-summary-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stock-label {
    font-weight: 600;
    color: var(--text-primary);
}

.stock-label.low {
    color: var(--error-color);
}

.toggle-details-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: none;
    background: var(--bg-color);
    color: var(--text-primary);
    padding: 0.35rem 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.toggle-details-btn i {
    transition: transform 0.2s ease;
}

.toggle-details-btn.expanded i {
    transform: rotate(180deg);
}

.toggle-details-btn:hover {
    background: var(--card-border);
}

.product-list-panel {
    border-top: 1px solid var(--card-border);
    padding: 1rem 1.25rem 1.25rem;
}

.product-panel-content {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(160px, 1fr);
    gap: 1.25rem;
    align-items: stretch;
}

.product-panel-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.product-panel-meta span {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.product-panel-meta strong {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-primary);
    font-weight: 600;
}

.product-panel-media {
    position: relative;
    border-radius: var(--border-radius);
    border: 1px solid var(--card-border);
    overflow: hidden;
    background: #f8fafc;
}

.product-panel-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-panel-actions {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem;
}

.product-panel-actions button.danger {
    background-color: var(--error-color);
    color: #fff;
}

.product-panel-actions button.danger:hover {
    background-color: #b91c1c;
}

@media (max-width: 600px) {
    .product-summary-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .toggle-details-btn {
        width: 100%;
        justify-content: center;
    }

    .product-panel-meta {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .product-panel-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .product-list-header {
        padding: 0.9rem 1rem;
    }

    .product-list-panel {
        padding: 0.75rem 1rem 0.9rem;
    }

    .product-panel-media {
        min-height: 140px;
    }

    article,
    .card {
        padding: 1rem;
    }
}

/* Scanner */
#scanner-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: auto;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: #000;
}

#scanner-video {
    width: 100%;
    display: block;
}

/* Dialog / Modal */
dialog {
   border: none;
   border-radius: var(--border-radius);
   box-shadow: var(--shadow-md);
   padding: 0;
   max-width: 500px;
   max-height: 90vh;
   width: 90vw;
   margin: auto; /* ✨ Magic centering ✨ */
   opacity: 0;
   transform: scale(0.95);
   transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out, display 0.2s allow-end;
   overflow: hidden;
}

dialog[open] {
   opacity: 1;
   transform: scale(1);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 0.2s ease-in-out, display 0.2s allow-end;
}

dialog[open]::backdrop {
   opacity: 1;
}

dialog article {
    padding: 0;
    border: none;
    box-shadow: none;
    margin: 0;
    margin-bottom: 0; /* 移除article默认的margin-bottom */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

dialog header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

dialog header h3 {
    margin: 0;
    flex: 1;
}

/* 关闭按钮样式 */
dialog header .close,
dialog header a[aria-label="Close"] {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1.5rem;
    line-height: 1;
    transition: all 0.2s ease;
    z-index: 10;
}

dialog header .close::before,
dialog header a[aria-label="Close"]::before {
    content: "×";
    font-size: 1.8rem;
    font-weight: 300;
    line-height: 1;
}

dialog header .close:hover,
dialog header a[aria-label="Close"]:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
    transform: rotate(90deg);
}

dialog header .close:active,
dialog header a[aria-label="Close"]:active {
    transform: scale(0.95) rotate(90deg);
}

/* 移动端优化 */
@media (max-width: 768px) {
    dialog {
        width: 95vw;
        max-width: none;
        max-height: 95vh;
    }

    dialog article {
        max-height: 95vh;
    }

    dialog header .close,
    dialog header a[aria-label="Close"] {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.8rem;
    }

    dialog header .close::before,
    dialog header a[aria-label="Close"]::before {
        font-size: 2rem;
    }

    dialog main,
    dialog article > form {
        padding: 1rem;
    }
}

/* 其他关闭按钮样式 */
.close-modal,
.close-btn {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.close-modal:hover,
.close-btn:hover {
    opacity: 0.8;
}

/* 作为×号的关闭按钮 */
button.close-modal:not([type="submit"]):not(.secondary) {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    padding: 0.25rem 0.5rem;
    color: var(--text-secondary);
    min-width: auto;
}

button.close-modal:not([type="submit"]):not(.secondary):hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

dialog main,
dialog article > form {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* 确保嵌套在form里的section不影响滚动 */
dialog form section {
    overflow: visible;
}

dialog footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--card-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    background-color: #f8fafc;
    position: sticky;
    bottom: 0;
    z-index: 99;
    flex-shrink: 0;
}

/* ============================================
   扫码器现代化UI样式 - 紧凑版
   ============================================ */

/* 紧凑型卡片容器 */
.result-card-compact {
    padding: 0;
}

.compact-header {
    padding: 0.75rem;
    border-bottom: 1px solid var(--card-border);
    background: var(--card-bg);
}

.product-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.product-title-row h5 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.product-id {
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--bg-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* 紧凑型图片预览 */
.compact-image-preview {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.mini-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--card-border);
}

.view-images-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.view-images-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.no-image-compact {
    text-align: center;
    padding: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* 紧凑型详情 */
.compact-details {
    padding: 0.75rem;
}

.detail-grid-compact {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    font-size: 0.875rem;
}

.detail-grid-compact .label {
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-grid-compact .value {
    color: var(--text-primary);
    font-weight: 600;
}

/* 库存信息卡片 - 紧凑版 */
.scanner-stock-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin: 0.75rem;
    padding: 0;
}

.stock-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    padding: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stock-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.stock-card.low-stock {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stock-card-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    flex-shrink: 0;
}

.stock-card-content {
    flex: 1;
    min-width: 0;
}

.stock-card-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0.125rem;
    font-weight: 500;
}

.stock-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    line-height: 1;
}

/* 数量选择区域 - 紧凑版 */
.scanner-quantity-section {
    margin: 0.75rem;
    padding: 0;
}

.quantity-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modern-quantity-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 10px;
    padding: 0.5rem;
    max-width: 240px;
    margin: 0 auto;
}

.modern-quantity-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: var(--primary-color);
    color: white;
    font-size: 1.125rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modern-quantity-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.modern-quantity-btn:active {
    transform: scale(0.95);
}

.modern-quantity-btn.decrease {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.modern-quantity-btn.increase {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.modern-quantity-selector input[type="number"] {
    width: 80px;
    height: 40px;
    text-align: center;
    font-weight: 700;
    font-size: 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    -moz-appearance: textfield;
}

.modern-quantity-selector input[type="number"]::-webkit-outer-spin-button,
.modern-quantity-selector input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.modern-quantity-selector input[type="number"]:focus {
    outline: none;
}

/* 操作按钮卡片 - 紧凑版 */
.scanner-action-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin: 0.75rem;
    padding: 0;
}

.scanner-action-card {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-height: 100px;
    position: relative;
    overflow: hidden;
}

.scanner-action-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(0, 0, 0, 0.03) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.scanner-action-card:hover::before {
    opacity: 1;
}

.scanner-action-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    border-color: transparent;
}

.scanner-action-card:active {
    transform: translateY(-2px);
}

.scanner-action-card.inbound {
    border-color: #10b981;
}

.scanner-action-card.inbound:hover {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.scanner-action-card.outbound {
    border-color: #f59e0b;
}

.scanner-action-card.outbound:hover {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.action-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(59, 130, 246, 0.1);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.scanner-action-card.inbound .action-card-icon {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.scanner-action-card.outbound .action-card-icon {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.scanner-action-card:hover .action-card-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: scale(1.05);
}

.action-card-content {
    text-align: center;
}

.action-card-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.125rem;
    color: var(--text-primary);
}

.scanner-action-card:hover .action-card-title {
    color: white;
}

.action-card-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.scanner-action-card:hover .action-card-desc {
    color: rgba(255, 255, 255, 0.9);
}

/* 扫描下一个按钮 - 紧凑版 */
.btn-scan-next {
    width: calc(100% - 1.5rem);
    padding: 0.875rem 1.25rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0.75rem;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.btn-scan-next:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

.btn-scan-next:active {
    transform: translateY(0);
}

/* 移动端优化 - 紧凑版 */
@media (max-width: 768px) {
    .compact-header {
        padding: 0.625rem;
    }

    .product-title-row h5 {
        font-size: 1rem;
    }

    .mini-thumbnail {
        width: 50px;
        height: 50px;
    }

    .view-images-btn {
        font-size: 0.8125rem;
        padding: 0.4rem 0.6rem;
    }

    .compact-details {
        padding: 0.625rem;
    }

    .detail-grid-compact {
        gap: 0.4rem;
        font-size: 0.8125rem;
    }

    .scanner-stock-cards {
        gap: 0.625rem;
        margin: 0.625rem;
    }

    .stock-card {
        padding: 0.75rem;
    }

    .stock-card-icon {
        width: 36px;
        height: 36px;
        font-size: 1.125rem;
    }

    .stock-card-label {
        font-size: 0.6875rem;
    }

    .stock-card-value {
        font-size: 1.375rem;
    }

    .scanner-quantity-section {
        margin: 0.625rem;
    }

    .modern-quantity-selector {
        max-width: 100%;
        padding: 0.4rem;
        gap: 0.625rem;
    }

    .modern-quantity-btn {
        width: 36px;
        height: 36px;
    }

    .modern-quantity-selector input[type="number"] {
        width: 70px;
        height: 36px;
        font-size: 1.125rem;
    }

    .scanner-action-buttons {
        gap: 0.625rem;
        margin: 0.625rem;
    }

    .scanner-action-card {
        padding: 0.875rem;
        min-height: 90px;
    }

    .action-card-icon {
        width: 44px;
        height: 44px;
        font-size: 1.375rem;
    }

    .action-card-title {
        font-size: 1rem;
    }

    .action-card-desc {
        font-size: 0.6875rem;
    }

    .btn-scan-next {
        margin: 0.625rem;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

/* 旧版样式兼容（保留用于其他页面） */
.quantity-selector {
   display: flex;
   align-items: center;
   justify-content: center;
   gap: 0.5rem;
   margin-bottom: 1rem;
}

.quantity-selector input[type="number"] {
   width: 80px;
   text-align: center;
   font-weight: bold;
   font-size: 1.2rem;
   -moz-appearance: textfield;
}

.quantity-selector input[type="number"]::-webkit-outer-spin-button,
.quantity-selector input[type="number"]::-webkit-inner-spin-button {
   -webkit-appearance: none;
   margin: 0;
}

.quantity-btn {
   width: 40px;
   height: 40px;
   border: 1px solid var(--card-border);
   background-color: var(--bg-color);
   color: var(--text-primary);
   font-size: 1.5rem;
   font-weight: bold;
   line-height: 1;
   border-radius: 50%;
   cursor: pointer;
   transition: background-color 0.2s;
}

.quantity-btn:hover {
   background-color: var(--card-border);
}
/* === Component-Specific Overrides & Enhancements === */

/* Modern Product List */
.modern-product-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.product-list-header {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.product-list-title h2 {
    margin: 0;
    color: var(--text-primary);
}

.product-list-title p {
    margin: 0.25rem 0 0;
    color: var(--text-secondary);
}

.product-list-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

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

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    background-color: var(--bg-color);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-box i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.filter-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.8rem;
    background-color: var(--bg-color);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.chip.active {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.chip .remove {
    margin-left: 0.25rem;
    cursor: pointer;
    font-weight: bold;
}

/* Modern Product Grid */
.product-grid {
    display: grid;
    gap: 1.5rem;
}

/* Desktop: Card Layout */
@media (min-width: 769px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
}

/* Mobile: List Layout */
@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

.modern-product-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
}

.modern-product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.modern-product-card.low-stock {
    border-color: var(--error-color);
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.1);
}

/* Desktop Card Layout */
@media (min-width: 769px) {
    .product-card-header {
        position: relative;
        height: 200px;
        overflow: hidden;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }

    .product-card-image {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.3s ease;
    }

    .modern-product-card:hover .product-card-image {
        transform: scale(1.05);
    }
}

/* Mobile List Layout */
@media (max-width: 768px) {
    .modern-product-card {
        display: flex;
        align-items: stretch;
        border-radius: var(--border-radius);
        min-height: 120px;
    }

    .modern-product-card.low-stock {
        border-left: 4px solid var(--error-color);
        box-shadow: none;
    }

    .product-card-header {
        width: 100px;
        min-width: 100px;
        height: auto;
        position: relative;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }

    .product-card-image {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .product-card-badges {
        position: absolute;
        top: 0.5rem;
        left: 0.5rem;
        right: 0.5rem;
        flex-direction: column;
        gap: 0.25rem;
    }

    .product-card-badges .left-badges,
    .product-card-badges .right-badges {
        display: flex;
        gap: 0.25rem;
    }

    .badge {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
        backdrop-filter: blur(8px);
    }

    .action-menu {
        position: absolute;
        top: 0.25rem;
        right: 0.25rem;
    }

    .action-menu-toggle {
        padding: 0.25rem;
        font-size: 0.8rem;
        background: rgba(255, 255, 255, 0.9);
        border-radius: 50%;
    }

    .product-card-body {
        flex: 1;
        padding: 1rem;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .product-card-title {
        font-size: 1rem;
        margin-bottom: 0.25rem;
        line-height: 1.2;
    }

    .product-card-subtitle {
        font-size: 0.85rem;
        margin-bottom: 0.75rem;
        color: var(--text-secondary);
    }

    .product-card-meta {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .meta-item {
        text-align: center;
    }

    .meta-label {
        font-size: 0.7rem;
        margin-bottom: 0.1rem;
    }

    .meta-value {
        font-size: 0.85rem;
    }

    .product-card-footer {
        padding: 0.5rem 1rem;
        border-top: 1px solid var(--card-border);
        background: var(--bg-color);
    }

    .product-card-actions {
        display: flex;
        gap: 0.25rem;
        justify-content: space-between;
    }

    .action-btn {
        flex: 1;
        padding: 0.4rem 0.25rem;
        font-size: 0.75rem;
        gap: 0.25rem;
        min-height: auto;
    }

    .action-btn i {
        font-size: 0.7rem;
    }
}

.product-card-badges {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    right: 0.75rem;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

.product-card-badges .left-badges,
.product-card-badges .right-badges {
    display: flex;
    gap: 0.5rem;
}

.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
}

.badge.low-stock {
    background: rgba(239, 68, 68, 0.9);
    color: white;
}

.badge.in-stock {
    background: rgba(34, 197, 94, 0.9);
    color: white;
}

.product-card-body {
    padding: 1.25rem;
}

.product-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.product-card-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.product-card-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.meta-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.meta-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.product-card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--card-border);
    background: var(--bg-color);
}

.product-card-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--card-border);
    border-radius: calc(var(--border-radius) / 2);
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.action-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: rgba(59, 130, 246, 0.05);
}

.action-btn.primary {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.action-btn.primary:hover {
    background: var(--accent-color-hover);
    border-color: var(--accent-color-hover);
}

.action-btn.danger {
    color: var(--error-color);
    border-color: var(--error-color);
}

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

.action-menu {
    position: relative;
}

.action-menu-toggle {
    padding: 0.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: calc(var(--border-radius) / 2);
    transition: all 0.2s ease;
}

.action-menu-toggle:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.action-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 50;
    min-width: 200px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
}

.action-menu.show .action-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(4px);
}

.action-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%;
    text-align: left;
}

.action-menu-item:hover {
    background: var(--bg-color);
}

.action-menu-item.danger {
    color: var(--error-color);
}

.action-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.action-menu-divider {
    height: 1px;
    background: var(--card-border);
    margin: 0.25rem 0;
}

/* Batch Selection Bar */
.batch-selection-bar {
    background: var(--accent-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.batch-selection-bar.show {
    display: flex;
}

.batch-selection-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.batch-selection-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.batch-selection-actions .btn {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.batch-selection-actions .btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.batch-selection-actions .btn.danger {
    background: rgba(239, 68, 68, 0.9);
    border-color: var(--error-color);
}

/* Empty State */
.empty-state-modern {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state-modern i {
    font-size: 4rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-modern h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state-modern p {
    margin-bottom: 1.5rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .product-list-header {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        min-width: 100%;
    }

    .product-list-actions {
        flex-direction: column;
        width: 100%;
    }

    .filter-chips {
        justify-content: center;
    }

    .product-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .product-card-actions {
        grid-template-columns: 1fr;
    }

    .batch-selection-bar {
        flex-direction: column;
        text-align: center;
    }

    .batch-selection-actions {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Dashboard Charts */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr; /* Default to single column */
    gap: 1.5rem;
    margin-top: 2rem;
}

/* On larger screens, show two charts side-by-side */
@media (min-width: 992px) {
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.chart-container {
    position: relative;
    padding: 1.5rem;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    /* Set a height and aspect ratio to prevent render loops */
    height: 400px; 
    aspect-ratio: 16 / 9;
}

.chart-container.full-width {
    grid-column: 1 / -1; /* Span full width if it's the only chart */
}

.chart-container h4 {
    margin-bottom: 1rem;
    text-align: center;
    color: var(--text-secondary);
}

/* Log Page Filters */
.filter-container {
    margin-bottom: 1.5rem;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* Choices.js Customizations */
.choices {
    width: 100%;
    margin-bottom: 0; /* Remove default margin */
}
.choices__inner {
    background-color: var(--bg-color);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 0.375rem 0.75rem; /* Match other inputs */
    font-size: 1rem;
    min-height: 48px; /* Match other inputs height */
    width: 100%;
}
.choices.is-focused .choices__inner {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.choices__list--multiple .choices__item {
    background-color: var(--accent-color);
    border: 1px solid var(--accent-color-hover);
    border-radius: 4px;
    font-size: 0.9rem;
    padding: 4px 8px;
    margin-bottom: 5px; /* Spacing between items */
    color: white;
}
.choices__item__close .choices__button {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>');
    opacity: 0.8;
    transition: opacity 0.2s;
}
.choices__item__close .choices__button:hover {
    opacity: 1;
}
.choices__list--dropdown {
    border-radius: var(--border-radius);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-md);
    margin-top: 4px;
    max-height: 250px; /* Control dropdown height */
    overflow-y: auto; /* Add scrollbar when needed */
}
.choices__item--choice {
    padding: 0.75rem 1rem;
}
.choices__item--choice.is-highlighted {
    background-color: var(--accent-color);
    color: white;
}
 *  Desktop / Mobile toggle utilities
 */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.badge-inbound {
    background: rgba(34, 197, 94, 0.15);
    color: #15803d;
}

.badge-outbound {
    background: rgba(239, 68, 68, 0.15);
    color: #b91c1c;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 1.5rem 1rem;
    background: var(--card-bg);
    border: 1px dashed var(--card-border);
    border-radius: var(--border-radius);
}
#product-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.product-card {
    display: flex;
    flex-direction: column;
    position: relative;
    border-radius: var(--border-radius);
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 0.2s ease;
}

.product-card:hover {
    transform: translateY(-3px);
}

.product-checkbox-container {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 2;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 999px;
    padding: 0.35rem;
    box-shadow: var(--shadow-sm);
}

.product-checkbox {
    width: 18px;
    height: 18px;
}

.product-card header {
    height: 180px;
    overflow: hidden;
}

.product-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover .product-thumbnail {
    transform: scale(1.05);
}

.product-card-body {
    padding: 1rem;
    flex-grow: 1;
}

.product-card footer {
    padding: 0 1rem 1rem;
    display: flex;
    gap: 0.5rem;
}

.product-card footer .btn,
.product-card footer button {
    flex: 1;
}

/* ===================================
   QR Code Management Styles
   =================================== */

/* Toolbar */
.qrcode-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.toolbar-left {
    flex: 1;
    min-width: 300px;
}

#qrcode-search {
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}

.size-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.size-selector label {
    font-weight: 500;
    white-space: nowrap;
}

.size-selector select {
    min-width: 120px;
}

/* QR Code Grid */
.qrcode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

/* QR Code Card */
.qrcode-card {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    position: relative;
}

.qrcode-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
}

.qrcode-card-header {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 10;
}

.qrcode-checkbox {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.qrcode-canvas-container {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 1rem 0;
    background: #f9fafb;
    border-radius: 8px;
}

.qrcode-canvas {
    border: 2px solid #e5e7eb;
    border-radius: 4px;
}

.qrcode-card-body {
    width: 100%;
    text-align: center;
}

.product-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-batch,
.product-spec {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0.25rem 0;
}

.qrcode-card-actions {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.qrcode-card-actions button {
    flex: 1;
    padding: 0.6rem;
    border: none;
    border-radius: 6px;
    background: var(--primary-color);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.qrcode-card-actions button:hover {
    background: #1976d2;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.download-single-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.download-single-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.print-single-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.print-single-btn:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.error-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--border-radius);
}

/* Mobile Optimization */
@media (max-width: 768px) {
    .qrcode-toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100%;
        flex-direction: column;
    }

    .toolbar-left {
        min-width: auto;
    }

    #qrcode-search {
        max-width: none;
        width: 100%;
    }

    .size-selector {
        width: 100%;
    }

    .size-selector select {
        flex: 1;
    }

    .qrcode-toolbar button {
        width: 100%;
        justify-content: center;
    }

    .qrcode-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .qrcode-card {
        padding: 1rem;
    }

    .qrcode-canvas {
        max-width: 200px;
    }
}

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

    .product-name {
        font-size: 1rem;
    }

    .qrcode-card-actions button {
        font-size: 0.85rem;
        padding: 0.5rem;
    }
}

/* Print Styles */
@media print {
    .qrcode-toolbar,
    .qrcode-card-header,
    .qrcode-card-actions {
        display: none !important;
    }

    .qrcode-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1cm;
    }

    .qrcode-card {
        page-break-inside: avoid;
        border: 1px solid #000;
        padding: 0.5cm;
    }

    .qrcode-canvas-container {
        background: white;
    }

    @page {
        size: A4;
        margin: 1cm;
    }
}

/* ===================================
   Modal Styles (模态框样式)
   =================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

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

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

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    line-height: 1;
}

.modal-close:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--card-border);
}

.modal-actions .btn {
    flex: 1;
}

.modal-cancel {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.modal-cancel:hover {
    background: var(--card-border);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        max-height: 85vh;
        border-radius: var(--border-radius) var(--border-radius) 0 0;
        animation: slideUpMobile 0.3s ease-out;
    }

    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .modal-header {
        padding: 1.25rem;
    }

    .modal-header h3 {
        font-size: 1.1rem;
    }

    .modal-body {
        padding: 1.25rem;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions .btn {
        width: 100%;
    }
}

