@media (max-width: 768px) {
    :root {
        --sidebar-width: 0;
    }
    
    .header {
        padding: 0 15px;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
        width: 280px;
    }
    
    .main-content {
        margin-left: 0;
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .mobile-table {
        font-size: 0.9rem;
    }
    
    .mobile-table th,
    .mobile-table td {
        padding: 10px;
    }
    
    /* 移动端表格特殊处理 */
    .mobile-table thead {
        display: none;
    }
    
    .mobile-table tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        background: white;
        padding: 15px;
    }
    
    .mobile-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .mobile-table td:last-child {
        border-bottom: none;
    }
    
    .mobile-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--dark-color);
        flex: 0 0 40%;
    }
    
    .mobile-table td:last-child {
        justify-content: flex-end;
        gap: 10px;
    }
    
    /* 模态框适配 */
    .modal-content {
        max-width: 100%;
        margin: 0 15px;
    }
    
    /* 按钮组适配 */
    .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .btn-group .btn {
        flex: 1;
        min-width: 120px;
        text-align: center;
        justify-content: center;
    }
    
    /* 表单适配 */
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    /* 隐藏非必要元素 */
    .desktop-only {
        display: none;
    }
    
    /* 显示移动端特定元素 */
    .mobile-only {
        display: block;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .card-header h2 {
        font-size: 1.1rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
}

/* 移动端优化 */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .menu-item,
    .page-link {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-control,
    select {
        font-size: 16px; /* 防止iOS自动缩放 */
    }
    
    input[type="date"] {
        min-height: 44px;
    }
}

/* 平板设备优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    
    .main-content {
        margin-left: 220px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --light-color: #1e293b;
        --dark-color: #f8fafc;
        --border-color: #334155;
    }
    
    body {
        background-color: #0f172a;
        color: #cbd5e1;
    }
    
    .header,
    .sidebar,
    .content-card,
    .stat-card {
        background-color: #1e293b;
        color: #cbd5e1;
    }
    
    .mobile-table tr {
        background-color: #1e293b;
        border-color: #334155;
    }
    
    .form-control {
        background-color: #334155;
        border-color: #475569;
        color: #cbd5e1;
    }
    
    .form-control::placeholder {
        color: #94a3b8;
    }
}