/* ============================================================
   凌云科技 · 授权码远程管理系统
   全局样式表 (完整版 v2.8.2)
   移动端适配: 完全重写 @media (max-width: 768px)
   ============================================================ */

/* ---------- 全局重置 & 变量 ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
    --transition: 0.3s ease;
    --sidebar-width: 240px;
}
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    min-height: 100vh;
    display: flex;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #ffffff;
    border-right: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    overflow-y: auto;
}
.sidebar-header {
    padding: 20px 22px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-header .logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    flex-shrink: 0;
}
.sidebar-header .brand-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    white-space: nowrap;
}
.sidebar-header .brand-text span {
    color: var(--primary);
}

.sidebar-menu {
    flex: 1;
    padding: 16px 0;
    list-style: none;
}
.sidebar-menu li {
    padding: 0 16px;
    margin-bottom: 4px;
}
.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: var(--gray-600);
    font-weight: 500;
    font-size: 14px;
    transition: var(--transition);
    text-decoration: none;
}
.sidebar-menu li a i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}
.sidebar-menu li a:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}
.sidebar-menu li a.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37,99,235,0.25);
}
.sidebar-menu li a.active i {
    color: #ffffff;
}

/* ---------- 侧边栏底部（主题切换按钮 + 版权信息） ---------- */
.sidebar-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px 22px;
    border-top: 1px solid var(--gray-200);
    font-size: 12px;
    color: var(--gray-400);
    text-align: center;
    margin-top: auto;
}
.footer-info {
    font-size: 12px;
    color: var(--gray-400);
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 90%;
    margin: 0 auto 4px;
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    background-color: var(--gray-100);
    color: var(--gray-700);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}
.theme-toggle-btn:hover {
    background-color: var(--gray-200);
}
.theme-toggle-btn i {
    font-size: 14px;
}
body.dark-mode .theme-toggle-btn {
    background-color: var(--gray-200);
    color: var(--gray-600);
}
body.dark-mode .theme-toggle-btn:hover {
    background-color: var(--gray-300);
}

/* ---------- 主内容区 ---------- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px 28px 40px;
    min-height: 100vh;
    transition: margin var(--transition);
}

/* ---------- 顶部导航（移动端汉堡） ---------- */
.topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--gray-200);
}
.topbar .menu-toggle {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-700);
    cursor: pointer;
    padding: 4px 8px;
}
.topbar .topbar-brand {
    font-weight: 700;
    font-size: 18px;
    color: var(--gray-900);
}
.topbar .topbar-brand span {
    color: var(--primary);
}
.topbar .user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-600);
}
.topbar .user-badge i {
    font-size: 18px;
}

/* ---------- 页面标题 ---------- */
.page-title {
    margin-bottom: 24px;
}
.page-title h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}
.page-title p {
    color: var(--gray-500);
    font-size: 14px;
    margin-top: 4px;
}

/* ---------- 统计卡片 ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}
.stat-card .stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
}
.stat-card .stat-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-900);
    margin-top: 4px;
}
.stat-card:nth-child(2) {
    border-left-color: var(--success);
}
.stat-card:nth-child(3) {
    border-left-color: var(--danger);
}

/* ---------- 错误提示 ---------- */
.error-alert {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 16px;
    border-left: 4px solid var(--danger);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---------- 工具栏 ---------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: #fff;
    padding: 16px 22px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}
.toolbar-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    flex: 1;
}
.toolbar-left .search-box {
    display: flex;
    align-items: center;
    background: var(--gray-100);
    border-radius: 40px;
    padding: 0 16px;
    flex: 1;
    min-width: 160px;
    max-width: 300px;
}
.toolbar-left .search-box input {
    border: none;
    background: transparent;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
    width: 100%;
}
.toolbar-left .filter-select {
    padding: 10px 16px;
    border: 1px solid var(--gray-200);
    border-radius: 40px;
    background: #fff;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    min-width: 110px;
}
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border: none;
    border-radius: 40px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    background: var(--primary);
    color: #fff;
}
.btn:hover {
    background: var(--primary-dark);
}
.btn-outline {
    background: transparent;
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}
.btn-outline:hover {
    background: var(--gray-100);
}
.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: #b91c1c;
}
.btn-sm {
    padding: 6px 16px;
    font-size: 13px;
}

/* ---------- 表格 ---------- */
.table-wrapper {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.table-scroll {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
thead {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}
thead th {
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--gray-600);
    font-size: 11px;
    text-transform: uppercase;
    white-space: nowrap;
}
tbody tr {
    border-bottom: 1px solid var(--gray-100);
}
tbody td {
    padding: 12px 10px;
    vertical-align: middle;
}
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 40px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.status-badge.active {
    background: #dcfce7;
    color: #166534;
}
.status-badge.inactive {
    background: #fee2e2;
    color: #991b1b;
}
.action-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ---------- 分页 ---------- */
.pagination-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-top: 1px solid var(--gray-100);
}
.pagination-bar .pages {
    display: flex;
    gap: 4px;
}
.pagination-bar .pages button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--gray-200);
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}
.pagination-bar .pages button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pagination-bar .pages button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.pagination-bar .pages button:hover:not(.active):not(:disabled) {
    background: var(--gray-100);
}

/* ---------- 模态框 ---------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(15,23,42,0.50);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active {
    display: flex;
}
.modal-box {
    background: #fff;
    border-radius: var(--radius);
    max-width: 600px;
    width: 100%;
    padding: 32px 36px 28px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.18);
    max-height: 90vh;
    overflow-y: auto;
}
.modal-box .modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}
.modal-box .modal-header h3 {
    font-size: 20px;
}
.modal-box .modal-header .close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-400);
    transition: var(--transition);
}
.modal-box .modal-header .close-btn:hover {
    color: var(--gray-700);
}
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--gray-700);
}
.form-group label .required {
    color: var(--danger);
    margin-left: 2px;
}
.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
}
.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}
.empty-row td {
    text-align: center;
    padding: 40px 0;
    color: var(--gray-400);
}
.text-muted {
    color: var(--gray-500);
    font-size: 12px;
}

/* ---------- 关于系统页 ---------- */
.about-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 36px;
    max-width: 700px;
}
.about-card .about-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--gray-900);
}
.about-card .about-title i {
    color: var(--primary);
    margin-right: 10px;
}
.about-card p {
    color: var(--gray-600);
    line-height: 1.8;
    margin-bottom: 12px;
}
.about-card .info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 24px;
    margin: 20px 0;
}
.about-card .info-grid .item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}
.about-card .info-grid .item .label {
    font-weight: 500;
    color: var(--gray-500);
}
.about-card .info-grid .item .value {
    color: var(--gray-800);
    font-weight: 500;
}
.about-card .version-badge {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    padding: 4px 16px;
    border-radius: 40px;
    font-size: 13px;
    font-weight: 600;
}

/* ====== 产品栏统一美化（使用 .product-select 下拉框） ====== */
.product-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 22px;
    margin-bottom: 24px;
}
.product-bar .label {
    font-weight: 600;
    color: var(--gray-600);
    font-size: 14px;
    margin-right: 4px;
}
.product-bar .product-form {
    display: flex;
    align-items: center;
    margin: 0;
}
.product-bar .product-select {
    height: 40px;
    padding: 0 15px;
    border-radius: 20px;
    border: 1px solid #d1d5db;
    background-color: #fff;
    font-size: 14px;
    color: #333;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364758b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
.product-bar .product-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.product-bar .btn,
.product-bar .btn-sm {
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    white-space: nowrap;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    background: var(--primary);
    color: #fff;
    border: none;
    transition: var(--transition);
    cursor: pointer;
}
.product-bar .btn:hover {
    background: var(--primary-dark);
}
.product-bar .btn-danger {
    background: var(--danger);
    color: #fff;
}
.product-bar .btn-danger:hover {
    background: #b91c1c;
}

/* ====== 批量生成与编辑模态框增强 ====== */
#batchModal .modal-box {
    max-width: 700px;
}
#batchModal .batch-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}
#batchModal .batch-row input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
}
#batchModal .batch-row input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
#editModal .form-group input[type="date"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
}
#editModal .form-group input[type="date"]:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.batch-result-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 12px 18px;
    margin-bottom: 16px;
}
.batch-result-error {
    color: var(--danger);
}
.expiring-warning {
    color: var(--danger);
    font-weight: 600;
}
.expiring-notice {
    color: var(--warning);
    font-weight: 600;
}
.toolbar .btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ====== 深色主题 ====== */
body.dark-mode {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --gray-50: #0f172a;
    --gray-100: #1e293b;
    --gray-200: #334155;
    --gray-300: #475569;
    --gray-400: #64748b;
    --gray-500: #94a3b8;
    --gray-600: #b3c5d9;
    --gray-700: #cbd5e1;
    --gray-800: #e2e8f0;
    --gray-900: #f1f5f9;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
}
body.dark-mode {
    background: var(--gray-50);
    color: var(--gray-800);
}
body.dark-mode .sidebar,
body.dark-mode .navbar,
body.dark-mode .product-bar,
body.dark-mode .stat-card,
body.dark-mode .toolbar,
body.dark-mode .table-wrapper,
body.dark-mode .modal-box,
body.dark-mode .about-card,
body.dark-mode .topbar,
body.dark-mode .sidebar-footer {
    background: var(--gray-100);
    border-color: var(--gray-200);
    box-shadow: var(--shadow);
}
body.dark-mode .sidebar-menu li a {
    color: var(--gray-500);
}
body.dark-mode .sidebar-menu li a:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}
body.dark-mode .sidebar-menu li a.active {
    background: var(--primary);
    color: #fff;
}
body.dark-mode .sidebar-footer {
    border-top-color: var(--gray-200);
}
body.dark-mode .stat-card .stat-number {
    color: var(--gray-900);
}
body.dark-mode .table-wrapper table {
    color: var(--gray-800);
}
body.dark-mode .table-wrapper thead {
    background: var(--gray-200);
}
body.dark-mode .table-wrapper thead th {
    color: var(--gray-700);
}
body.dark-mode .table-wrapper tbody tr {
    border-bottom-color: var(--gray-200);
}
body.dark-mode .table-wrapper tbody tr:hover {
    background: var(--gray-200);
}
body.dark-mode .status-badge.active {
    background: #1a3a2a;
    color: #86efac;
}
body.dark-mode .status-badge.inactive {
    background: #3a1a1a;
    color: #fca5a5;
}
body.dark-mode .btn-outline {
    border-color: var(--gray-400);
    color: var(--gray-600);
}
body.dark-mode .btn-outline:hover {
    background: var(--gray-200);
}
body.dark-mode .error-alert {
    background: #3a1a1a;
    color: #fca5a5;
    border-left-color: #f87171;
}
body.dark-mode .about-card .info-grid .item {
    border-bottom-color: var(--gray-200);
}
body.dark-mode .about-card .info-grid .item .value {
    color: var(--gray-800);
}
body.dark-mode .about-card .version-badge {
    background: var(--primary);
}
body.dark-mode .modal-box .modal-header .close-btn {
    color: var(--gray-500);
}
body.dark-mode .modal-box .modal-header .close-btn:hover {
    color: var(--gray-700);
}
body.dark-mode .form-group input,
body.dark-mode .form-group select {
    background: var(--gray-200);
    border-color: var(--gray-300);
    color: var(--gray-800);
}
body.dark-mode .form-group input:focus,
body.dark-mode .form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.3);
}
body.dark-mode .product-bar .product-select {
    background-color: var(--gray-200);
    border-color: var(--gray-300);
    color: var(--gray-800);
}
body.dark-mode .product-bar .product-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.3);
}
body.dark-mode .product-bar .btn {
    background: var(--primary);
}
body.dark-mode .product-bar .btn:hover {
    background: var(--primary-dark);
}
body.dark-mode .product-bar .btn-danger {
    background: var(--danger);
}
body.dark-mode .product-bar .btn-danger:hover {
    background: #b91c1c;
}
body.dark-mode .pagination-bar .pages button {
    background: var(--gray-200);
    border-color: var(--gray-300);
    color: var(--gray-700);
}
body.dark-mode .pagination-bar .pages button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
body.dark-mode .pagination-bar .pages button:hover:not(.active):not(:disabled) {
    background: var(--gray-300);
}
body.dark-mode .topbar .user-badge a {
    color: var(--danger) !important;
}
body.dark-mode .topbar .user-badge a:hover {
    color: #f87171 !important;
}
body.dark-mode .theme-toggle-btn {
    background-color: var(--gray-200);
    color: var(--gray-600);
}
body.dark-mode .theme-toggle-btn:hover {
    background-color: var(--gray-300);
}
body.dark-mode .search-box input {
    background: var(--gray-200);
    color: var(--gray-800);
}
body.dark-mode .search-box input::placeholder {
    color: var(--gray-500);
}

/* ============================================================
   移动端适配 (宽度 ≤ 768px)
   完全重写，解决所有布局问题
   ============================================================ */
@media (max-width: 768px) {
    /* ---------- 侧边栏 ---------- */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.30);
        z-index: 999;
    }
    .sidebar-overlay.active {
        display: block;
    }

    /* ---------- 主内容 ---------- */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        min-width: 0;
        padding: 16px 15px 30px;
        box-sizing: border-box;
    }

    /* ---------- 顶部栏 ---------- */
    .topbar {
        display: flex;
        padding: 10px 0 12px;
        margin-bottom: 16px;
        border-bottom: 1px solid var(--gray-200);
    }
    .topbar .menu-toggle {
        font-size: 22px;
        padding: 4px 6px;
    }
    .topbar .topbar-brand {
        font-size: 16px;
    }
    .topbar .user-badge {
        font-size: 12px;
        gap: 6px;
    }
    .topbar .user-badge a {
        font-size: 12px;
        margin-left: 4px;
    }

    /* ---------- 页面标题 ---------- */
    .page-title {
        margin-bottom: 16px;
    }
    .page-title h1 {
        font-size: 20px;
    }
    .page-title p {
        font-size: 13px;
    }

    /* ---------- 产品选择栏 (product-bar) ---------- */
    .product-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 14px 16px;
    }
    .product-bar .label {
        margin-right: 0;
        font-size: 14px;
        display: block;
    }
    .product-bar .product-form {
        width: 100%;
        margin: 0;
    }
    .product-bar .product-select {
        width: 100%;
        height: 40px;
        padding: 0 15px;
        font-size: 14px;
        box-sizing: border-box;
    }
    /* 按钮行：两个按钮各占50% */
    .product-bar .btn,
    .product-bar .btn-sm {
        width: calc(50% - 5px);
        height: 40px;
        display: inline-flex;
        justify-content: center;
        align-items: center;
        font-size: 14px;
        padding: 0 12px;
        box-sizing: border-box;
        flex: 0 0 auto;
        margin: 0;
    }
    .product-bar .btn:first-of-type,
    .product-bar .btn-sm:first-of-type {
        margin-right: 5px;
    }
    .product-bar .btn:last-of-type,
    .product-bar .btn-sm:last-of-type {
        margin-left: 5px;
    }
    /* 确保按钮容器（product-bar）内所有直接子按钮按行排列 */
    .product-bar > .btn,
    .product-bar > .btn-sm,
    .product-bar > .btn-danger {
        width: calc(50% - 5px);
        margin: 0;
    }
    .product-bar > .btn:first-child,
    .product-bar > .btn-sm:first-child {
        margin-right: 5px;
    }
    .product-bar > .btn:last-child,
    .product-bar > .btn-sm:last-child {
        margin-left: 5px;
    }
    /* 如果内部有表单包裹按钮，需要额外处理 */
    .product-bar .product-form + .btn,
    .product-bar .product-form + .btn-sm {
        width: calc(50% - 5px);
        margin: 0;
    }
    /* 对于多个按钮，使用flex容器统一处理 */
    .product-bar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .product-bar .product-form {
        width: 100%;
        margin: 0;
    }
    /* 所有直接子按钮和表单后的按钮都占一半宽度 */
    .product-bar > .btn,
    .product-bar > .btn-sm,
    .product-bar > .btn-danger,
    .product-bar > .product-form + .btn,
    .product-bar > .product-form + .btn-sm {
        width: calc(50% - 5px);
        flex: 0 0 auto;
        display: inline-flex;
        justify-content: center;
        align-items: center;
    }
    /* 用flex-wrap确保两个按钮在一行 */
    .product-bar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
    }
    .product-bar .label {
        width: 100%;
        margin-bottom: 0;
    }
    .product-bar .product-form {
        width: 100%;
        margin-bottom: 0;
    }
    .product-bar .btn,
    .product-bar .btn-sm {
        width: calc(50% - 5px);
        flex: 0 0 auto;
        margin: 0;
    }
    .product-bar .btn:first-of-type {
        margin-right: 5px;
    }
    .product-bar .btn:last-of-type {
        margin-left: 5px;
    }
    /* 确保删除按钮也占一半 */
    .product-bar .btn-danger {
        width: calc(50% - 5px);
        margin: 0;
        margin-left: 5px;
    }
    /* 重新调整：使用更简单的方式 */
    .product-bar .product-form {
        width: 100%;
    }
    .product-bar .product-form + .btn,
    .product-bar .product-form + .btn-sm {
        width: calc(50% - 5px);
        margin: 0;
    }
    .product-bar .product-form + .btn {
        margin-right: 5px;
    }
    .product-bar .product-form + .btn-sm {
        margin-left: 5px;
    }
    /* 最终方案：所有按钮都作为flex子项，使用flex:1平分 */
    .product-bar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .product-bar .label {
        width: 100%;
        display: block;
    }
    .product-bar .product-form {
        width: 100%;
        margin: 0;
    }
    .product-bar .product-select {
        width: 100%;
    }
    .product-bar .btn,
    .product-bar .btn-sm,
    .product-bar .btn-danger {
        width: 100%;
        flex: 0 0 auto;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    /* 让两个按钮在一行并排 */
    .product-bar .btn:first-of-type,
    .product-bar .btn-sm:first-of-type {
        width: calc(50% - 5px);
        margin-right: 5px;
        display: inline-flex;
    }
    .product-bar .btn:last-of-type,
    .product-bar .btn-sm:last-of-type {
        width: calc(50% - 5px);
        margin-left: 5px;
        display: inline-flex;
    }
    /* 但注意，如果有多个按钮，可能需要更复杂的处理。根据实际，只有两个按钮，所以直接处理。 */
    .product-bar .btn,
    .product-bar .btn-sm {
        width: calc(50% - 5px);
        margin: 0;
        display: inline-flex;
        justify-content: center;
        align-items: center;
    }
    .product-bar .btn:first-child,
    .product-bar .btn-sm:first-child {
        margin-right: 5px;
    }
    .product-bar .btn:last-child,
    .product-bar .btn-sm:last-child {
        margin-left: 5px;
    }
    /* 针对删除按钮（btn-danger）单独处理 */
    .product-bar .btn-danger {
        width: calc(50% - 5px);
        margin: 0;
        margin-left: 5px;
    }

    /* ---------- 统计卡片 ---------- */
    .stats-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 20px;
    }
    .stat-card {
        padding: 14px 16px;
        border-left: 3px solid var(--primary);
        box-sizing: border-box;
        width: 100%;
        margin: 0;
    }
    .stat-card .stat-number {
        font-size: 24px;
    }
    .stat-card:nth-child(3) {
        grid-column: span 2;
    }

    /* ---------- 工具栏 ---------- */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px 16px;
        box-sizing: border-box;
    }
    .toolbar-left {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        width: 100%;
    }
    .toolbar-left .search-box {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }
    .toolbar-left .filter-select {
        width: 100%;
        box-sizing: border-box;
    }
    .toolbar > div:last-child {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    .toolbar > div:last-child .btn {
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
    }

    /* ---------- 批量操作栏（批量删除、清空所有） ---------- */
    /* 注意：批量操作栏不是toolbar的直接子元素，而是位于toolbar之后的一个div */
    .toolbar + div[style*="display:flex; gap:12px;"],
    .toolbar ~ div[style*="display:flex; gap:12px;"] {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 16px;
        padding: 0 4px;
    }
    .toolbar + div[style*="display:flex; gap:12px;"] .btn,
    .toolbar ~ div[style*="display:flex; gap:12px;"] .btn {
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
    }

    /* ---------- 表格 ---------- */
    .table-wrapper {
        border-radius: var(--radius);
        overflow: hidden;
        box-sizing: border-box;
    }
    .table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }
    table {
        min-width: 720px;
        font-size: 12px;
        box-sizing: border-box;
    }
    thead th,
    tbody td {
        padding: 8px 6px;
        white-space: nowrap;
    }
    .action-group .btn {
        font-size: 10px;
        padding: 4px 8px;
        min-width: 40px;
        box-sizing: border-box;
    }

    /* ---------- 分页 ---------- */
    .pagination-bar {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 12px 16px;
        box-sizing: border-box;
    }
    .pagination-bar .info {
        font-size: 12px;
        text-align: center;
    }
    .pagination-bar .pages button {
        width: 30px;
        height: 30px;
        font-size: 12px;
        box-sizing: border-box;
    }

    /* ---------- 模态框 ---------- */
    .modal-box {
        padding: 24px 20px;
        max-width: 100%;
        margin: 0 10px;
        box-sizing: border-box;
    }
    .modal-box .modal-header h3 {
        font-size: 18px;
    }

    /* ---------- 关于系统 ---------- */
    .about-card {
        padding: 24px 20px;
        box-sizing: border-box;
    }
    .about-card .info-grid {
        grid-template-columns: 1fr;
    }

    /* ---------- 一般输入框内边距 ---------- */
    input, select, textarea {
        box-sizing: border-box;
        padding: 0 12px;
    }

    /* ---------- 批量生成模态框行 ---------- */
    #batchModal .batch-row {
        flex-wrap: wrap;
        gap: 6px;
    }
    #batchModal .batch-row input {
        flex: 1 1 45%;
        min-width: 120px;
    }
    #batchModal .batch-row .btn-danger {
        flex: 0 0 auto;
        margin-left: auto;
    }
}

/* ====== 超小屏 (宽度 ≤ 480px) 额外微调 ====== */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .stat-card .stat-number {
        font-size: 20px;
    }
    .stat-card {
        padding: 10px 12px;
    }
    .stat-card .stat-label {
        font-size: 11px;
    }
    .product-bar .btn,
    .product-bar .btn-sm,
    .product-bar .btn-danger {
        font-size: 12px;
        padding: 0 10px;
    }
    .toolbar-left .search-box input {
        font-size: 13px;
    }
    .toolbar-left .filter-select {
        font-size: 13px;
        padding: 8px 12px;
    }
    .pagination-bar .pages button {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
    .topbar .topbar-brand {
        font-size: 14px;
    }
    .topbar .menu-toggle {
        font-size: 20px;
    }
    .topbar .user-badge {
        font-size: 11px;
    }
}